Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions | Variables
chan_ooh323.c File Reference
#include "chan_ooh323.h"
#include <math.h>
Include dependency graph for chan_ooh323.c:

Go to the source code of this file.

Data Structures

struct  ast_peer_list
 
struct  ast_user_list
 
struct  ooh323_config
 
struct  ooh323_peer
 
struct  ooh323_pvt
 
struct  ooh323_user
 

Macros

#define DEFAULT_CONTEXT   "default"
 
#define DEFAULT_H323ACCNT   "ast_h323"
 
#define DEFAULT_H323ID   "Asterisk PBX"
 
#define DEFAULT_LOGFILE   "h323_log"
 
#define FAXDETECT_CNG   1
 
#define FAXDETECT_T38   2
 
#define FORMAT   "%-15.15s %-15.15s %-23.23s %-s\n"
 
#define FORMAT1   "%-15.15s %-15.15s %-15.15s %-s\n"
 
#define FORMAT_STRING_SIZE   512
 
#define H323_ALREADYGONE   (1<<5)
 
#define H323_DISABLEGK   (1<<7)
 
#define H323_FASTSTART   (1<<3)
 
#define H323_GKROUTED   (1<<1)
 
#define H323_NEEDDESTROY   (1<<6)
 
#define H323_NEEDSTART   (1<<8)
 
#define H323_OUTGOING   (1<<4)
 
#define H323_SILENCESUPPRESSION   (1<<0)
 
#define H323_TUNNELING   (1<<2)
 
#define IPTOS_MINCOST   0x02
 
#define MAXT30   240
 
#define T38_DISABLED   0
 
#define T38_ENABLED   1
 
#define T38_FAXGW   1
 
#define T38TOAUDIOTIMEOUT   30
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static struct ooh323_peerbuild_peer (const char *name, struct ast_variable *v, int friend_type)
 
static struct ooh323_userbuild_user (const char *name, struct ast_variable *v)
 
void close_rtp_connection (ooCallData *call)
 
void close_udptl_connection (ooCallData *call)
 
int configure_local_rtp (struct ooh323_pvt *p, ooCallData *call)
 
int delete_peers ()
 
int delete_users ()
 
static void * do_monitor (void *data)
 
static struct ooh323_pvtfind_call (ooCallData *call)
 
struct ooh323_peerfind_friend (const char *name, int port)
 
struct ooh323_peerfind_peer (const char *name, int port)
 
struct ooh323_userfind_user (const char *name, const char *ip)
 
static int function_ooh323_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 OOH323 Dialplan function - reads ooh323 settings. More...
 
static int function_ooh323_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 OOH323 Dialplan function - writes ooh323 settings. More...
 
char * handle_cli_ooh323_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_set_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_show_config (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_show_gk (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_show_peer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_show_peers (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_show_user (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_ooh323_show_users (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int load_module (void)
 
int onAlerting (ooCallData *call)
 
int onCallCleared (ooCallData *call)
 
int onCallEstablished (ooCallData *call)
 
void onModeChanged (ooCallData *call, int t38mode)
 
int onNewCallCreated (ooCallData *call)
 
int onOutgoingCall (ooCallData *call)
 
int onProgress (ooCallData *call)
 
static struct ooh323_pvtooh323_alloc (int callref, char *callToken)
 
static int ooh323_answer (struct ast_channel *ast)
 
static int ooh323_call (struct ast_channel *ast, const char *dest, int timeout)
 
int ooh323_convert_hangupcause_asteriskToH323 (int cause)
 
int ooh323_convert_hangupcause_h323ToAsterisk (int cause)
 
int ooh323_convertAsteriskCapToH323Cap (struct ast_format *format)
 
void ooh323_delete_peer (struct ooh323_peer *peer)
 
int ooh323_destroy (struct ooh323_pvt *p)
 
static int ooh323_digit_begin (struct ast_channel *ast, char digit)
 
static int ooh323_digit_end (struct ast_channel *ast, char digit, unsigned int duration)
 
static int ooh323_do_reload (void)
 
static int ooh323_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
 
static void ooh323_get_codec (struct ast_channel *chan, struct ast_format_cap *result)
 
static enum ast_rtp_glue_result ooh323_get_rtp_peer (struct ast_channel *chan, struct ast_rtp_instance **rtp)
 
static enum ast_rtp_glue_result ooh323_get_vrtp_peer (struct ast_channel *chan, struct ast_rtp_instance **rtp)
 
static int ooh323_hangup (struct ast_channel *ast)
 
static int ooh323_indicate (struct ast_channel *ast, int condition, const void *data, size_t datalen)
 
static struct ast_channelooh323_new (struct ooh323_pvt *i, int state, const char *host, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
 
int ooh323_onReceivedDigit (OOH323CallData *call, const char *digit)
 
int ooh323_onReceivedSetup (ooCallData *call, Q931Message *pmsg)
 
static int ooh323_queryoption (struct ast_channel *ast, int option, void *data, int *datalen)
 
static struct ast_frameooh323_read (struct ast_channel *ast)
 
static struct ast_channelooh323_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
 
struct ast_frameooh323_rtp_read (struct ast_channel *ast, struct ooh323_pvt *p)
 
void ooh323_set_read_format (ooCallData *call, struct ast_format *fmt)
 
static int ooh323_set_rtp_peer (struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active)
 
void ooh323_set_write_format (ooCallData *call, struct ast_format *fmt, int txframes)
 
static int ooh323_write (struct ast_channel *ast, struct ast_frame *f)
 
int reload_config (int reload)
 
static int reload_module (void)
 
int restart_monitor (void)
 Start the channel monitor thread. More...
 
void setup_rtp_connection (ooCallData *call, const char *remoteIp, int remotePort)
 
void setup_rtp_remote (ooCallData *call, const char *remoteIp, int remotePort)
 
void setup_udptl_connection (ooCallData *call, const char *remoteIp, int remotePort)
 
static int unload_module (void)
 
int update_our_aliases (ooCallData *call, struct ooh323_pvt *p)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Objective Systems H323 Channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, .requires = "udptl", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
struct ast_sockaddr bindaddr
 
static long callnumber = 0
 
static struct ast_cli_entry cli_ooh323 []
 
static const char config [] = "ooh323.conf"
 
static struct ast_jb_conf default_jbconf
 
static int g729onlyA = 0
 
static char gAccountcode [80] = DEFAULT_H323ACCNT
 
static struct ooAliases * gAliasList
 
static int gAMAFLAGS
 
static int gANIasDNI = 0
 
static int gBeMaster = 0
 
static char gCallerID [AST_MAX_EXTENSION] = ""
 
static struct ast_format_capgCap
 
static char gContext [AST_MAX_EXTENSION] = DEFAULT_CONTEXT
 
static int gDirectRTP = 0
 
static int gDTMFCodec = 101
 
static int gDTMFMode = H323_DTMF_RFC2833
 
static int gEarlyDirect = 0
 
static int gFastStart = 1
 
static int gFAXdetect = FAXDETECT_CNG
 
static char gGatekeeper [100]
 
OOBOOL gH323Debug = FALSE
 
OOH323EndPoint gH323ep
 
static int gIncomingLimit = 1024
 
static char gInitError [256] = ""
 
static char gIP [2+8 *4+7]
 
static int gIsGateway = 0
 
static struct ast_jb_conf global_jbconf
 
static char gLogFile [PATH_MAX] = DEFAULT_LOGFILE
 
static int gMediaWaitForConnect = 0
 
static int gNat = FALSE
 
static int gOutgoingLimit = 1024
 
static int gPort = 1720
 
static enum RasGatekeeperMode gRasGkMode = RasNoGatekeeper
 
static char gRASIP [2+8 *4+7]
 
static int gRTDRCount = 0
 
static int gRTDRInterval = 0
 
static int gRTPTimeout = 60
 
static int gT38Support = T38_FAXGW
 
static int gTOS = 0
 
static int gTRCLVL = OOTRCLVLERR
 
static int gTunneling = 1
 
static ast_mutex_t h323_reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static int h323_reloading = 0
 
static struct ooh323_pvtiflist = NULL
 
static ast_mutex_t iflock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct io_contextio
 
static int manufacturer = 0
 
static pthread_t monitor_thread = AST_PTHREADT_NULL
 
static ast_mutex_t monlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
struct ast_modulemyself
 
static struct ooh323_config ooconfig
 
static struct ast_rtp_glue ooh323_rtp
 
static struct ast_channel_tech ooh323_tech
 
static ast_mutex_t ooh323c_cn_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct ast_peer_list peerl
 
static struct ast_sched_contextsched
 
static int t35countrycode = 0
 
static int t35extensions = 0
 
static const char tdesc [] = "Objective Systems H323 Channel Driver"
 
static const char type [] = "OOH323"
 
static int usecnt = 0
 
static ast_mutex_t usecnt_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct ast_user_list userl
 
int v6mode = 0
 
static char vendor [AST_MAX_EXTENSION] = ""
 
static char version [AST_MAX_EXTENSION] = ""
 

Macro Definition Documentation

◆ DEFAULT_CONTEXT

#define DEFAULT_CONTEXT   "default"

Definition at line 83 of file chan_ooh323.c.

Referenced by reload_config().

◆ DEFAULT_H323ACCNT

#define DEFAULT_H323ACCNT   "ast_h323"

Definition at line 86 of file chan_ooh323.c.

Referenced by reload_config().

◆ DEFAULT_H323ID

#define DEFAULT_H323ID   "Asterisk PBX"

Definition at line 84 of file chan_ooh323.c.

Referenced by reload_config().

◆ DEFAULT_LOGFILE

#define DEFAULT_LOGFILE   "h323_log"

Definition at line 85 of file chan_ooh323.c.

Referenced by reload_config().

◆ FAXDETECT_CNG

#define FAXDETECT_CNG   1

◆ FAXDETECT_T38

#define FAXDETECT_T38   2

◆ FORMAT

#define FORMAT   "%-15.15s %-15.15s %-23.23s %-s\n"

◆ FORMAT1

#define FORMAT1   "%-15.15s %-15.15s %-15.15s %-s\n"

◆ FORMAT_STRING_SIZE

#define FORMAT_STRING_SIZE   512

Definition at line 80 of file chan_ooh323.c.

Referenced by handle_cli_ooh323_show_config(), and handle_cli_ooh323_show_gk().

◆ H323_ALREADYGONE

#define H323_ALREADYGONE   (1<<5)

Definition at line 94 of file chan_ooh323.c.

Referenced by onCallCleared(), ooh323_hangup(), and ooh323_indicate().

◆ H323_DISABLEGK

#define H323_DISABLEGK   (1<<7)

Definition at line 96 of file chan_ooh323.c.

Referenced by ooh323_alloc(), ooh323_call(), and ooh323_onReceivedSetup().

◆ H323_FASTSTART

#define H323_FASTSTART   (1<<3)

Definition at line 92 of file chan_ooh323.c.

◆ H323_GKROUTED

#define H323_GKROUTED   (1<<1)

Definition at line 90 of file chan_ooh323.c.

◆ H323_NEEDDESTROY

#define H323_NEEDDESTROY   (1<<6)

Definition at line 95 of file chan_ooh323.c.

Referenced by do_monitor(), onCallCleared(), ooh323_hangup(), and ooh323_onReceivedSetup().

◆ H323_NEEDSTART

#define H323_NEEDSTART   (1<<8)

Definition at line 97 of file chan_ooh323.c.

◆ H323_OUTGOING

#define H323_OUTGOING   (1<<4)

◆ H323_SILENCESUPPRESSION

#define H323_SILENCESUPPRESSION   (1<<0)

Definition at line 89 of file chan_ooh323.c.

◆ H323_TUNNELING

#define H323_TUNNELING   (1<<2)

Definition at line 91 of file chan_ooh323.c.

◆ IPTOS_MINCOST

#define IPTOS_MINCOST   0x02

Definition at line 77 of file chan_ooh323.c.

Referenced by reload_config().

◆ MAXT30

#define MAXT30   240

Definition at line 99 of file chan_ooh323.c.

◆ T38_DISABLED

#define T38_DISABLED   0

◆ T38_ENABLED

#define T38_ENABLED   1

◆ T38_FAXGW

#define T38_FAXGW   1

◆ T38TOAUDIOTIMEOUT

#define T38TOAUDIOTIMEOUT   30

Definition at line 100 of file chan_ooh323.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 5250 of file chan_ooh323.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 5250 of file chan_ooh323.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 5250 of file chan_ooh323.c.

◆ build_peer()

static struct ooh323_peer* build_peer ( const char *  name,
struct ast_variable v,
int  friend_type 
)
static

Definition at line 2515 of file chan_ooh323.c.

References ooh323_peer::accountcode, ooh323_peer::amaflags, ast_calloc, ast_channel_string2amaflag(), ast_copy_string(), ast_false(), ast_format_cap_alloc, ast_format_cap_append_from_cap(), ast_format_cap_update_by_allow_disallow(), ast_free, ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_mutex_init, ast_parse_arg(), ast_sockaddr_stringify_host(), ast_strdup, ast_strdupa, ast_true(), ast_verb, buf, ooh323_peer::cap, ooh323_peer::directrtp, ooh323_peer::dtmfcodec, ooh323_peer::dtmfmode, ooh323_peer::e164, ooh323_peer::earlydirect, ooh323_peer::email, ooh323_peer::faststart, ooh323_peer::faxdetect, FAXDETECT_CNG, FAXDETECT_T38, ooh323_pvt::g729onlyA, ooh323_peer::g729onlyA, gAccountcode, gAMAFLAGS, gDirectRTP, gDTMFCodec, gDTMFMode, gEarlyDirect, gFastStart, gFAXdetect, gH323Debug, gNat, gRTPTimeout, gT38Support, gTunneling, ooh323_peer::h245tunneling, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_INBANDRELAX, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_peer::h323id, ooh323_peer::ip, ast_variable::lineno, ooh323_peer::lock, LOG_ERROR, LOG_WARNING, ooh323_peer::mFriend, ast_variable::name, ooh323_peer::name, ooh323_peer::nat, ast_variable::next, ooh323_pvt::next, NULL, ooh323_delete_peer(), ooh323_peer::outgoinglimit, PARSE_ADDR, ooh323_pvt::peer, ooh323_peer::port, ooh323_peer::rtdrcount, ooh323_peer::rtdrinterval, ooh323_peer::rtpmask, ooh323_peer::rtpmaskstr, ooh323_peer::rtptimeout, strsep(), T38_DISABLED, T38_ENABLED, T38_FAXGW, ooh323_peer::t38support, tmp(), ooh323_peer::url, and ast_variable::value.

Referenced by reload_config().

2516 {
2517  struct ooh323_peer *peer = NULL;
2518 
2519  if (gH323Debug)
2520  ast_verb(0, "--- build_peer\n");
2521 
2522  peer = ast_calloc(1, sizeof(*peer));
2523  if (peer) {
2524  memset(peer, 0, sizeof(struct ooh323_peer));
2525  if (!(peer->cap = ast_format_cap_alloc(0))) {
2526  ast_free(peer);
2527  return NULL;
2528  }
2529  ast_mutex_init(&peer->lock);
2530  ast_copy_string(peer->name, name, sizeof(peer->name));
2532  peer->rtptimeout = gRTPTimeout;
2533  peer->nat = gNat;
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;
2545  peer->port = 1720;
2546  if (0 == friend_type) {
2547  peer->mFriend = 1;
2548  }
2549 
2550  while (v) {
2551  if (!strcasecmp(v->name, "h323id")) {
2552  if (!(peer->h323id = ast_strdup(v->value))) {
2553  ast_log(LOG_ERROR, "Could not allocate memory for h323id of "
2554  "peer %s\n", name);
2555  ooh323_delete_peer(peer);
2556  return NULL;
2557  }
2558  } else if (!strcasecmp(v->name, "e164")) {
2559  int valid = 1;
2560  const char *tmp;
2561  for(tmp = v->value; *tmp; tmp++) {
2562  if (!isdigit(*tmp)) {
2563  valid = 0;
2564  break;
2565  }
2566  }
2567  if (valid) {
2568  if (!(peer->e164 = ast_strdup(v->value))) {
2569  ast_log(LOG_ERROR, "Could not allocate memory for e164 of "
2570  "peer %s\n", name);
2571  ooh323_delete_peer(peer);
2572  return NULL;
2573  }
2574  } else {
2575  ast_log(LOG_ERROR, "Invalid e164: %s for peer %s\n", v->value, name);
2576  }
2577  } else if (!strcasecmp(v->name, "email")) {
2578  if (!(peer->email = ast_strdup(v->value))) {
2579  ast_log(LOG_ERROR, "Could not allocate memory for email of "
2580  "peer %s\n", name);
2581  ooh323_delete_peer(peer);
2582  return NULL;
2583  }
2584  } else if (!strcasecmp(v->name, "url")) {
2585  if (!(peer->url = ast_strdup(v->value))) {
2586  ast_log(LOG_ERROR, "Could not allocate memory for h323id of "
2587  "peer %s\n", name);
2588  ooh323_delete_peer(peer);
2589  return NULL;
2590  }
2591  } else if (!strcasecmp(v->name, "port")) {
2592  peer->port = atoi(v->value);
2593  } else if (!strcasecmp(v->name, "host") || !strcasecmp(v->name, "ip")) {
2594  struct ast_sockaddr p;
2595  if (!ast_parse_arg(v->value, PARSE_ADDR, &p)) {
2596  ast_copy_string(peer->ip, ast_sockaddr_stringify_host(&p), sizeof(peer->ip));
2597  } else {
2598  ast_copy_string(peer->ip, v->value, sizeof(peer->ip));
2599  }
2600 
2601  } else if (!strcasecmp(v->name, "outgoinglimit")) {
2602  int val = atoi(v->value);
2603  if (val < 0) {
2604  peer->outgoinglimit = 0;
2605  } else {
2606  peer->outgoinglimit = val;
2607  }
2608  } else if (!strcasecmp(v->name, "accountcode")) {
2609  ast_copy_string(peer->accountcode, v->value, sizeof(peer->accountcode));
2610  } else if (!strcasecmp(v->name, "faststart")) {
2611  peer->faststart = ast_true(v->value);
2612  } else if (!strcasecmp(v->name, "h245tunneling")) {
2613  peer->h245tunneling = ast_true(v->value);
2614  } else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) {
2615  peer->directrtp = ast_true(v->value);
2616  peer->earlydirect = ast_true(v->value);
2617  } else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) {
2618  peer->earlydirect = ast_true(v->value);
2619  } else if (!strcasecmp(v->name, "g729onlyA")) {
2620  peer->g729onlyA = ast_true(v->value);
2621  } else if (!strcasecmp(v->name, "nat")) {
2622  peer->nat = ast_true(v->value);
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)
2630  == 0)) {
2631  ast_mutex_init(&peer->rtpmask->lock);
2632  peer->rtpmask->inuse = 1;
2633  ast_copy_string(peer->rtpmaskstr, v->value,
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";
2642  }
2643  ast_format_cap_update_by_allow_disallow(peer->cap, tcodecs, 1);
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"))
2657  else if (!strcasecmp(v->value, "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")) {
2666  if (ast_true(v->value)) {
2668  } else if (ast_false(v->value)) {
2669  peer->faxdetect = 0;
2670  } else {
2671  char *buf = ast_strdupa(v->value);
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;
2679  } else {
2680  ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
2681  }
2682  }
2683 
2684  }
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;
2694  }
2695  v = v->next;
2696  }
2697  }
2698 
2699  if (gH323Debug)
2700  ast_verb(0, "+++ build_peer\n");
2701 
2702  return peer;
2703 }
struct ast_variable * next
unsigned outgoinglimit
Definition: chan_ooh323.c:287
char accountcode[20]
Definition: chan_ooh323.c:290
#define T38_ENABLED
Definition: chan_ooh323.c:102
static int gFastStart
Definition: chan_ooh323.c:367
static int gDTMFCodec
Definition: chan_ooh323.c:359
static int gTunneling
Definition: chan_ooh323.c:368
Definition: ast_expr2.c:325
char * email
Definition: chan_ooh323.c:300
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
static int gDirectRTP
Definition: chan_ooh323.c:371
static int tmp()
Definition: bt_open.c:389
char * url
Definition: chan_ooh323.c:301
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
Socket address structure.
Definition: netsock2.h:97
#define ast_verb(level,...)
Definition: logger.h:463
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
#define T38_FAXGW
Definition: chan_ooh323.c:103
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
int ast_format_cap_update_by_allow_disallow(struct ast_format_cap *cap, const char *list, int allowing)
Parse an "allow" or "deny" list and modify a format capabilities structure accordingly.
Definition: format_cap.c:320
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition: channel.c:4405
int h245tunneling
Definition: chan_ooh323.c:308
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
#define ast_log
Definition: astobj2.c:42
static int gFAXdetect
Definition: chan_ooh323.c:360
struct ast_format_cap * cap
Definition: chan_ooh323.c:289
static int gNat
Definition: chan_ooh323.c:384
#define H323_DTMF_Q931
Definition: ooh323cDriver.h:27
int rtdrinterval
Definition: chan_ooh323.c:306
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int gRTPTimeout
Definition: chan_ooh323.c:374
char rtpmaskstr[120]
Definition: chan_ooh323.c:305
void ooh323_delete_peer(struct ooh323_peer *peer)
Definition: chan_ooh323.c:2328
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
#define LOG_ERROR
Definition: logger.h:285
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".
Definition: main/utils.c:1951
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
#define T38_DISABLED
Definition: chan_ooh323.c:101
ast_mutex_t lock
Definition: chan_ooh323.c:285
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Definition: main/config.c:3657
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
char * strsep(char **str, const char *delims)
static struct ast_format_cap * gCap
Definition: chan_ooh323.c:357
struct OOH323Regex * rtpmask
Definition: chan_ooh323.c:304
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
Definition: main/utils.c:1968
static int gAMAFLAGS
Definition: chan_ooh323.c:377
static int gEarlyDirect
Definition: chan_ooh323.c:372
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
#define ast_mutex_init(pmutex)
Definition: lock.h:184
char * e164
Definition: chan_ooh323.c:302
int ast_format_cap_append_from_cap(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
Append the formats of provided type in src to dst.
Definition: format_cap.c:269
char name[256]
Definition: chan_ooh323.c:286
#define H323_DTMF_INBAND
Definition: ooh323cDriver.h:30
#define H323_DTMF_INBANDRELAX
Definition: ooh323cDriver.h:32
static int gDTMFMode
Definition: chan_ooh323.c:358
static int g729onlyA
Definition: chan_ooh323.c:375
static int gT38Support
Definition: chan_ooh323.c:361
char * h323id
Definition: chan_ooh323.c:299
char ip[4 *8+7+2]
Definition: chan_ooh323.c:297
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
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...
Definition: netsock2.h:331
short word
static char gAccountcode[80]
Definition: chan_ooh323.c:376

◆ build_user()

static struct ooh323_user* build_user ( const char *  name,
struct ast_variable v 
)
static

Definition at line 2368 of file chan_ooh323.c.

References ooh323_user::accountcode, ooh323_user::amaflags, ooh323_user::aniasdni, ast_calloc, ast_channel_string2amaflag(), ast_copy_string(), ast_false(), ast_format_cap_alloc, ast_format_cap_append_from_cap(), ast_format_cap_update_by_allow_disallow(), ast_free, ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_mutex_init, ast_parse_arg(), ast_sockaddr_stringify_addr(), ast_strdupa, ast_true(), ast_verb, buf, ooh323_user::cap, ooh323_user::context, ooh323_user::directrtp, ooh323_user::dtmfcodec, ooh323_user::dtmfmode, ooh323_user::earlydirect, ooh323_user::faststart, ooh323_user::faxdetect, FAXDETECT_CNG, FAXDETECT_T38, ooh323_pvt::g729onlyA, ooh323_user::g729onlyA, gAccountcode, gAMAFLAGS, gContext, gDirectRTP, gDTMFCodec, gDTMFMode, gEarlyDirect, gFastStart, gFAXdetect, gH323Debug, gNat, gRTPTimeout, gT38Support, gTunneling, ooh323_user::h245tunneling, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_INBANDRELAX, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_user::incominglimit, ast_variable::lineno, ooh323_user::lock, LOG_WARNING, ooh323_user::mIP, ooh323_user::mUseIP, ast_variable::name, ooh323_user::name, ooh323_user::nat, ast_variable::next, ooh323_pvt::next, NULL, PARSE_ADDR, ooh323_user::rtdrcount, ooh323_user::rtdrinterval, ooh323_user::rtpmask, ooh323_user::rtpmaskstr, ooh323_user::rtptimeout, strsep(), T38_DISABLED, T38_ENABLED, T38_FAXGW, ooh323_user::t38support, ooh323_pvt::user, and ast_variable::value.

Referenced by reload_config().

2369 {
2370  struct ooh323_user *user = NULL;
2371 
2372  if (gH323Debug)
2373  ast_verb(0, "--- build_user\n");
2374 
2375  user = ast_calloc(1,sizeof(struct ooh323_user));
2376  if (user) {
2377  memset(user, 0, sizeof(struct ooh323_user));
2378  if (!(user->cap = ast_format_cap_alloc(0))) {
2379  ast_free(user);
2380  return NULL;
2381  }
2382  ast_mutex_init(&user->lock);
2383  ast_copy_string(user->name, name, sizeof(user->name));
2385  user->rtptimeout = gRTPTimeout;
2386  user->nat = gNat;
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;
2396  /* set default context */
2397  ast_copy_string(user->context, gContext, sizeof(user->context));
2398  ast_copy_string(user->accountcode, gAccountcode, sizeof(user->accountcode));
2399  user->amaflags = gAMAFLAGS;
2400 
2401  while (v) {
2402  if (!strcasecmp(v->name, "context")) {
2403  ast_copy_string(user->context, v->value, sizeof(user->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")) {
2409  ast_copy_string(user->accountcode, v->value, sizeof(user->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")) {
2413  user->faststart = ast_true(v->value);
2414  } else if (!strcasecmp(v->name, "h245tunneling")) {
2415  user->h245tunneling = ast_true(v->value);
2416  } else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) {
2417  user->directrtp = ast_true(v->value);
2418  user->earlydirect = ast_true(v->value);
2419  } else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) {
2420  user->earlydirect = ast_true(v->value);
2421  } else if (!strcasecmp(v->name, "g729onlyA")) {
2422  user->g729onlyA = ast_true(v->value);
2423  } else if (!strcasecmp(v->name, "nat")) {
2424  user->nat = ast_true(v->value);
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)
2432  == 0)) {
2433  ast_mutex_init(&user->rtpmask->lock);
2434  user->rtpmask->inuse = 1;
2435  ast_copy_string(user->rtpmaskstr, v->value,
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";
2444  }
2445  ast_format_cap_update_by_allow_disallow(user->cap, tcodecs, 1);
2446  } else if (!strcasecmp(v->name, "amaflags")) {
2448  } else if (!strcasecmp(v->name, "ip") || !strcasecmp(v->name, "host")) {
2449  struct ast_sockaddr p;
2450  if (!ast_parse_arg(v->value, PARSE_ADDR, &p)) {
2451  ast_copy_string(user->mIP, ast_sockaddr_stringify_addr(&p), sizeof(user->mIP)-1);
2452  } else {
2453  ast_copy_string(user->mIP, v->value, sizeof(user->mIP)-1);
2454  }
2455  user->mUseIP = 1;
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"))
2465  else if (!strcasecmp(v->value, "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")) {
2474  if (ast_true(v->value)) {
2476  } else if (ast_false(v->value)) {
2477  user->faxdetect = 0;
2478  } else {
2479  char *buf = ast_strdupa(v->value);
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;
2487  } else {
2488  ast_log(LOG_WARNING, "Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
2489  }
2490  }
2491 
2492  }
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")) {
2503  user->aniasdni = ast_true(v->value);
2504  }
2505  v = v->next;
2506  }
2507  }
2508 
2509  if (gH323Debug)
2510  ast_verb(0, "+++ build_user\n");
2511 
2512  return user;
2513 }
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition: netsock2.h:290
static char user[512]
struct ast_variable * next
#define T38_ENABLED
Definition: chan_ooh323.c:102
static char gContext[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:378
static int gFastStart
Definition: chan_ooh323.c:367
static int gDTMFCodec
Definition: chan_ooh323.c:359
static int gTunneling
Definition: chan_ooh323.c:368
char context[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:258
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
static int gDirectRTP
Definition: chan_ooh323.c:371
char name[256]
Definition: chan_ooh323.c:257
#define NULL
Definition: resample.c:96
Socket address structure.
Definition: netsock2.h:97
#define ast_verb(level,...)
Definition: logger.h:463
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
#define T38_FAXGW
Definition: chan_ooh323.c:103
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
int ast_format_cap_update_by_allow_disallow(struct ast_format_cap *cap, const char *list, int allowing)
Parse an "allow" or "deny" list and modify a format capabilities structure accordingly.
Definition: format_cap.c:320
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition: channel.c:4405
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
#define ast_log
Definition: astobj2.c:42
static int gFAXdetect
Definition: chan_ooh323.c:360
char rtpmaskstr[120]
Definition: chan_ooh323.c:272
static int gNat
Definition: chan_ooh323.c:384
#define H323_DTMF_Q931
Definition: ooh323cDriver.h:27
int h245tunneling
Definition: chan_ooh323.c:275
ast_mutex_t lock
Definition: chan_ooh323.c:256
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int gRTPTimeout
Definition: chan_ooh323.c:374
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
struct OOH323Regex * rtpmask
Definition: chan_ooh323.c:271
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".
Definition: main/utils.c:1951
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
#define T38_DISABLED
Definition: chan_ooh323.c:101
int incominglimit
Definition: chan_ooh323.c:259
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Definition: main/config.c:3657
struct ast_format_cap * cap
Definition: chan_ooh323.c:263
structure to hold users read from users.conf
char accountcode[20]
Definition: chan_ooh323.c:261
char mIP[4 *8+7+2]
Definition: chan_ooh323.c:270
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
char * strsep(char **str, const char *delims)
static struct ast_format_cap * gCap
Definition: chan_ooh323.c:357
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
Definition: main/utils.c:1968
static int gAMAFLAGS
Definition: chan_ooh323.c:377
static int gEarlyDirect
Definition: chan_ooh323.c:372
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
#define ast_mutex_init(pmutex)
Definition: lock.h:184
int ast_format_cap_append_from_cap(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
Append the formats of provided type in src to dst.
Definition: format_cap.c:269
#define H323_DTMF_INBAND
Definition: ooh323cDriver.h:30
#define H323_DTMF_INBANDRELAX
Definition: ooh323cDriver.h:32
static int gDTMFMode
Definition: chan_ooh323.c:358
static int g729onlyA
Definition: chan_ooh323.c:375
static int gT38Support
Definition: chan_ooh323.c:361
int rtdrinterval
Definition: chan_ooh323.c:273
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
short word
static char gAccountcode[80]
Definition: chan_ooh323.c:376

◆ close_rtp_connection()

void close_rtp_connection ( ooCallData *  call)

Definition at line 4810 of file chan_ooh323.c.

References ast_log, ast_mutex_lock, ast_mutex_unlock, ast_rtp_instance_stop(), ast_verb, find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, and ooh323_pvt::rtp.

Referenced by ooh323c_stop_transmit_channel().

4811 {
4812  struct ooh323_pvt *p = NULL;
4813 
4814  if(gH323Debug)
4815  ast_verb(0, "--- close_rtp_connection\n");
4816 
4817  p = find_call(call);
4818  if (!p) {
4819  ast_log(LOG_ERROR, "Couldn't find matching call to close rtp "
4820  "connection\n");
4821  return;
4822  }
4823  ast_mutex_lock(&p->lock);
4824  if (p->rtp) {
4826  }
4827  ast_mutex_unlock(&p->lock);
4828 
4829  if(gH323Debug)
4830  ast_verb(0, "+++ close_rtp_connection\n");
4831 
4832  return;
4833 }
#define ast_mutex_lock(a)
Definition: lock.h:187
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
#define ast_log
Definition: astobj2.c:42
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
Definition: rtp_engine.c:2183
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define LOG_ERROR
Definition: logger.h:285
struct ast_rtp_instance * rtp
Definition: chan_ooh323.c:187
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ close_udptl_connection()

void close_udptl_connection ( ooCallData *  call)

Definition at line 4901 of file chan_ooh323.c.

References ast_channel_trylock, ast_channel_unlock, AST_CONTROL_T38_PARAMETERS, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_queue_control_data(), AST_T38_TERMINATED, ast_verb, DEADLOCK_AVOIDANCE, find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, ooh323_pvt::owner, ast_control_t38_parameters::request_response, T38_ENABLED, ooh323_pvt::t38_tx_enable, and ooh323_pvt::t38support.

Referenced by ooh323c_stop_transmit_datachannel().

4902 {
4903  struct ooh323_pvt *p = NULL;
4904 
4905  if(gH323Debug)
4906  ast_verb(0, "--- close_udptl_connection\n");
4907 
4908  p = find_call(call);
4909  if (!p) {
4910  ast_log(LOG_ERROR, "Couldn't find matching call to close udptl "
4911  "connection\n");
4912  return;
4913  }
4914  ast_mutex_lock(&p->lock);
4915  if (p->owner) {
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);
4919  }
4920  if (!p->owner) {
4921  ast_mutex_unlock(&p->lock);
4922  ast_log(LOG_ERROR, "Channel has no owner\n");
4923  return;
4924  }
4925  } else {
4926  ast_mutex_unlock(&p->lock);
4927  ast_log(LOG_ERROR, "Channel has no owner\n");
4928  return;
4929  }
4930 
4931  p->t38_tx_enable = 0;
4932  if (p->t38support == T38_ENABLED) {
4933  struct ast_control_t38_parameters parameters = { .request_response = 0 };
4934  parameters.request_response = AST_T38_TERMINATED;
4935  ast_queue_control_data(p->owner, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
4936  }
4937 
4939  ast_mutex_unlock(&p->lock);
4940 
4941  if(gH323Debug)
4942  ast_verb(0, "+++ close_udptl_connection\n");
4943 
4944  return;
4945 }
#define T38_ENABLED
Definition: chan_ooh323.c:102
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:374
enum ast_control_t38 request_response
int t38support
Definition: chan_ooh323.c:191
#define ast_mutex_lock(a)
Definition: lock.h:187
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
int t38_tx_enable
Definition: chan_ooh323.c:197
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define LOG_ERROR
Definition: logger.h:285
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_channel * owner
Definition: chan_ooh323.c:203
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.
Definition: channel.c:1238
#define ast_channel_trylock(chan)
Definition: channel.h:2947
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ configure_local_rtp()

int configure_local_rtp ( struct ooh323_pvt p,
ooCallData *  call 
)

Definition at line 4599 of file chan_ooh323.c.

References ao2_ref, ast_channel_set_fd(), ast_channel_trylock, ast_channel_unlock, ast_copy_string(), ast_debug, ast_format_cap_count(), ast_format_cap_get_format(), ast_format_cap_get_framing(), ast_log, ast_mutex_unlock, ast_parse_arg(), ast_rtp_codecs_payloads_set_rtpmap_type(), ast_rtp_codecs_set_framing(), ast_rtp_instance_fd(), ast_rtp_instance_get_codecs(), ast_rtp_instance_get_local_address(), ast_rtp_instance_new(), ast_rtp_instance_set_prop(), ast_rtp_instance_set_qos(), ast_rtp_instance_set_timeout(), AST_RTP_PROPERTY_DTMF, AST_RTP_PROPERTY_NAT, AST_RTP_PROPERTY_RTCP, ast_sockaddr_copy(), ast_sockaddr_port, ast_sockaddr_stringify_addr(), ast_udptl_fd(), ast_udptl_get_us(), ast_udptl_new_with_bindaddr(), ast_udptl_set_far_max_datagram(), ast_verb, bindaddr, ooh323_pvt::cap, DEADLOCK_AVOIDANCE, ooh323_pvt::dtmfcodec, ooh323_pvt::dtmfmode, errno, format, gH323Debug, gTOS, H323_DTMF_CISCO, H323_DTMF_RFC2833, ooh323_pvt::lock, LOG_ERROR, LOG_WARNING, ooh323_pvt::nat, NULL, ooh323_convertAsteriskCapToH323Cap(), ooh323_pvt::owner, PARSE_ADDR, ooh323_pvt::rtdrcount, ooh323_pvt::rtdrinterval, ooh323_pvt::rtp, ooh323_pvt::rtptimeout, and ooh323_pvt::udptl.

Referenced by onNewCallCreated(), onOutgoingCall(), and ooh323_onReceivedSetup().

4600 {
4601  char lhost[INET6_ADDRSTRLEN];
4602  unsigned lport = 0;
4603  struct ast_sockaddr tmp;
4604  ooMediaInfo mediaInfo;
4605  int x;
4606 
4607  if (gH323Debug)
4608  ast_verb(0, "--- configure_local_rtp\n");
4609 
4610  memset(&mediaInfo, 0, sizeof(mediaInfo));
4611  if (ast_parse_arg(call->localIP, PARSE_ADDR, &tmp)) {
4613  }
4614  if (!(p->rtp = ast_rtp_instance_new("asterisk", sched, &tmp, NULL))) {
4615  ast_log(LOG_WARNING, "Unable to create RTP session: %s\n",
4616  strerror(errno));
4617  return 0;
4618  }
4619 
4620  ast_rtp_instance_set_qos(p->rtp, gTOS, 0, "ooh323-rtp");
4621 
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",
4624  strerror(errno));
4625  return 0;
4626  }
4628 
4629  if (p->owner) {
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);
4633  }
4634  if (!p->owner) {
4635  ast_mutex_unlock(&p->lock);
4636  ast_log(LOG_ERROR, "Channel has no owner\n");
4637  return 0;
4638  }
4639  } else {
4640  ast_log(LOG_ERROR, "Channel has no owner\n");
4641  return 0;
4642  }
4643 
4647 
4649 
4650  if (p->rtp) {
4651  if (p->cap) {
4654  }
4655  if (p->nat) {
4657  }
4658  if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
4661  p->rtp, p->dtmfcodec, "audio", "telephone-event", 0);
4662  }
4663  if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) {
4666  p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
4667  }
4668  /* figure out our local RTP port and tell the H.323 stack about it*/
4670  ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
4671  lport = ast_sockaddr_port(&tmp);
4672 
4673  if (p->rtptimeout) {
4675  }
4677 
4678  }
4679 
4680  if (p->rtdrcount) {
4681  if (gH323Debug)
4682  ast_verb(0, "Setup RTDR info: %d, %d\n", p->rtdrinterval, p->rtdrcount);
4683  call->rtdrInterval = p->rtdrinterval;
4684  call->rtdrCount = p->rtdrcount;
4685  }
4686 
4687 
4688  ast_copy_string(mediaInfo.lMediaIP, lhost, sizeof(mediaInfo.lMediaIP));
4689  mediaInfo.lMediaPort = lport;
4690  mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort + 1;
4691  for (x = 0; x < ast_format_cap_count(p->cap); x++) {
4693 
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);
4705 
4706  strcpy(mediaInfo.dir, "transmit");
4707  mediaInfo.cap = OO_G729B;
4708  ooAddMediaInfo(call, mediaInfo);
4709  strcpy(mediaInfo.dir, "receive");
4710  ooAddMediaInfo(call, mediaInfo);
4711  }
4712 
4713  ao2_ref(format, -1);
4714  }
4715 
4716  if (p->udptl) {
4717  ast_udptl_get_us(p->udptl, &tmp);
4718  ast_copy_string(lhost, ast_sockaddr_stringify_addr(&tmp), sizeof(lhost));
4719  lport = ast_sockaddr_port(&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);
4728  }
4729 
4730  if (gH323Debug)
4731  ast_verb(0, "+++ configure_local_rtp\n");
4732 
4733  return 1;
4734 }
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition: netsock2.h:290
unsigned int ast_format_cap_get_framing(const struct ast_format_cap *cap)
Get the global framing.
Definition: format_cap.c:438
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
Definition: netsock2.h:171
int rtptimeout
Definition: chan_ooh323.c:194
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
Definition: rtp_engine.c:727
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:374
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
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.
Definition: rtp_engine.c:2169
Definition: sched.c:76
Definition of a media format.
Definition: format.c:43
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
Definition: rtp_engine.c:2670
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...
Definition: udptl.c:997
static int call(void *data)
Definition: chan_pjsip.c:2358
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
Definition: rtp_engine.c:1558
#define NULL
Definition: resample.c:96
struct ast_udptl * udptl
Definition: chan_ooh323.c:195
Socket address structure.
Definition: netsock2.h:97
#define ast_verb(level,...)
Definition: logger.h:463
static int gTOS
Definition: chan_ooh323.c:373
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
void ast_udptl_get_us(const struct ast_udptl *udptl, struct ast_sockaddr *us)
Definition: udptl.c:1140
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
Definition: netsock2.h:521
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static struct io_context * io
Definition: chan_ooh323.c:401
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_format_cap * cap
Definition: chan_ooh323.c:229
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.
Definition: rtp_engine.c:1428
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define LOG_ERROR
Definition: logger.h:285
int rtdrinterval
Definition: chan_ooh323.c:245
int errno
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int ast_udptl_fd(const struct ast_udptl *udptl)
Definition: udptl.c:730
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
Definition: main/config.c:3657
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Definition: rtp_engine.c:2192
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.
Definition: rtp_engine.c:643
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2431
struct ast_udptl * ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *in)
Definition: udptl.c:1028
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
struct ast_channel * owner
Definition: chan_ooh323.c:203
struct ast_rtp_instance * rtp
Definition: chan_ooh323.c:187
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.
Definition: rtp_engine.c:705
#define ast_channel_trylock(chan)
Definition: channel.h:2947
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
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.
Definition: rtp_engine.c:465
static snd_pcm_format_t format
Definition: chan_alsa.c:102
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
struct ast_sockaddr bindaddr
Definition: chan_ooh323.c:353
#define ast_mutex_unlock(a)
Definition: lock.h:188
int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format)
Definition: chan_ooh323.c:4506

◆ delete_peers()

int delete_peers ( void  )

Definition at line 4230 of file chan_ooh323.c.

References ast_free, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_peer_list::lock, ooh323_peer::next, NULL, peerl, and ast_peer_list::peers.

Referenced by reload_config(), and unload_module().

4231 {
4232  struct ooh323_peer *cur = NULL, *prev = NULL;
4234  cur = peerl.peers;
4235  while (cur) {
4236  prev = cur;
4237  cur = cur->next;
4238 
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);
4244  if(prev->rtpmask) {
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);
4252  }
4253  }
4254  ast_free(prev);
4255 
4256  if (cur == peerl.peers) {
4257  break;
4258  }
4259  }
4260  peerl.peers = NULL;
4262  return 0;
4263 }
static struct ast_peer_list peerl
struct ooh323_peer * next
Definition: chan_ooh323.c:312
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
ast_mutex_t lock
Definition: chan_ooh323.c:324
#define ast_free(a)
Definition: astmm.h:182
#define ast_mutex_destroy(a)
Definition: lock.h:186
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ delete_users()

int delete_users ( void  )

Definition at line 4265 of file chan_ooh323.c.

References ao2_cleanup, ast_free, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_user_list::lock, ooh323_user::next, NULL, userl, and ast_user_list::users.

Referenced by reload_config(), and unload_module().

4266 {
4267  struct ooh323_user *cur = NULL, *prev = NULL;
4269  cur = userl.users;
4270  while (cur) {
4271  prev = cur;
4272  cur = cur->next;
4273  ast_mutex_destroy(&prev->lock);
4274 
4275  if(prev->rtpmask) {
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);
4283  }
4284  }
4285  ao2_cleanup(prev->cap);
4286  ast_free(prev);
4287  if (cur == userl.users) {
4288  break;
4289  }
4290  }
4291  userl.users = NULL;
4293  return 0;
4294 }
struct ooh323_user * next
Definition: chan_ooh323.c:280
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct ast_user_list userl
ast_mutex_t lock
Definition: chan_ooh323.c:319
#define ast_free(a)
Definition: astmm.h:182
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define ast_mutex_destroy(a)
Definition: lock.h:186
struct ooh323_user * users
Definition: chan_ooh323.c:318
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ do_monitor()

static void* do_monitor ( void *  data)
static

Definition at line 3998 of file chan_ooh323.c.

References ast_channel_name(), ast_channel_trylock, ast_channel_unlock, ast_io_wait(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_rtp_instance_sendcng(), ast_sched_runq(), ast_sched_wait(), ast_sockaddr_isnull(), AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), ast_test_flag, ast_verb, gGatekeeper, gH323ep, gRasGkMode, gRASIP, H323_NEEDDESTROY, h323_reload_lock, h323_reloading, iflist, iflock, ooh323_pvt::lastrtprx, ooh323_pvt::lastrtptx, LOG_NOTICE, monlock, ooh323_pvt::next, NULL, ooh323_destroy(), ooh323_do_reload(), ooh323_pvt::owner, ooh323_pvt::redirip, ooh323_pvt::rtp, and ooh323_pvt::rtptimeout.

Referenced by restart_monitor().

3999 {
4000  int res;
4001  int reloading;
4002  struct ooh323_pvt *h323 = NULL;
4003  time_t t;
4004 
4005  for (;;) {
4006  struct ooh323_pvt *h323_next;
4007  /* Check for a reload request */
4009  reloading = h323_reloading;
4010  h323_reloading = 0;
4012  if (reloading) {
4013  ast_verb(1, "Reloading H.323\n");
4014  ooh323_do_reload();
4015  }
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);
4022  }
4023 
4024  /* Check for interfaces needing to be killed */
4026  time(&t);
4027  h323 = iflist;
4028  while (h323) {
4029  h323_next = h323->next;
4030 
4031  if (h323->rtp && h323->rtptimeout && h323->lastrtptx &&
4032  h323->lastrtptx + h323->rtptimeout < t) {
4033  ast_rtp_instance_sendcng(h323->rtp, 0);
4034  h323->lastrtptx = time(NULL);
4035  }
4036 
4037  if (h323->rtp && h323->owner && h323->rtptimeout &&
4038  h323->lastrtprx && ast_sockaddr_isnull(&h323->redirip) &&
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);
4044  }
4045 
4046  }
4047 
4048  if (ast_test_flag(h323, H323_NEEDDESTROY)) {
4049  ooh323_destroy (h323);
4050  } /* else if (ast_test_flag(h323, H323_NEEDSTART) && h323->owner) {
4051  ast_channel_lock(h323->owner);
4052  if (ast_pbx_start(h323->owner)) {
4053  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", h323->owner->name);
4054  ast_channel_unlock(h323->owner);
4055  ast_hangup(h323->owner);
4056  }
4057  ast_channel_unlock(h323->owner);
4058  ast_clear_flag(h323, H323_NEEDSTART);
4059  } */
4060  h323 = h323_next;
4061  }
4063  pthread_testcancel();
4064 
4065  /* Wait for sched or io */
4066  res = ast_sched_wait(sched);
4067  if ((res < 0) || (res > 1000)) {
4068  res = 1000;
4069  }
4070  res = ast_io_wait(io, res);
4071  pthread_testcancel();
4073  if (res >= 0) {
4075  }
4077  }
4078  /* Never reached */
4079  return NULL;
4080 }
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
Definition: io.c:278
struct ooh323_pvt * next
Definition: chan_ooh323.c:248
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
Definition: sched.c:755
#define ast_test_flag(p, flag)
Definition: utils.h:63
static int h323_reloading
Definition: chan_ooh323.c:328
int rtptimeout
Definition: chan_ooh323.c:194
struct ast_sockaddr redirip
Definition: chan_ooh323.c:188
time_t lastrtprx
Definition: chan_ooh323.c:209
Definition: sched.c:76
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
time_t lastrtptx
Definition: chan_ooh323.c:208
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.
Definition: netsock2.h:127
#define ast_log
Definition: astobj2.c:42
static int ooh323_do_reload(void)
Definition: chan_ooh323.c:2705
static ast_mutex_t monlock
Definition: chan_ooh323.c:405
static struct io_context * io
Definition: chan_ooh323.c:401
OOH323EndPoint gH323ep
#define H323_NEEDDESTROY
Definition: chan_ooh323.c:95
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
Definition: rtp_engine.c:2772
static char gRASIP[2+8 *4+7]
Definition: chan_ooh323.c:363
static ast_mutex_t h323_reload_lock
Definition: chan_ooh323.c:329
#define LOG_NOTICE
Definition: logger.h:263
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2463
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel * owner
Definition: chan_ooh323.c:203
static char gGatekeeper[100]
Definition: chan_ooh323.c:362
int ooh323_destroy(struct ooh323_pvt *p)
Definition: chan_ooh323.c:4117
static struct ooh323_pvt * iflist
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.
Definition: sched.c:431
struct ast_rtp_instance * rtp
Definition: chan_ooh323.c:187
static enum RasGatekeeperMode gRasGkMode
Definition: chan_ooh323.c:364
#define ast_channel_trylock(chan)
Definition: channel.h:2947
static ast_mutex_t iflock
Definition: chan_ooh323.c:252
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_call()

static struct ooh323_pvt* find_call ( ooCallData *  call)
static

Definition at line 810 of file chan_ooh323.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verb, ooh323_pvt::callToken, gH323Debug, iflist, iflock, and ooh323_pvt::next.

Referenced by close_rtp_connection(), close_udptl_connection(), onAlerting(), onCallCleared(), onCallEstablished(), onModeChanged(), onNewCallCreated(), onOutgoingCall(), onProgress(), ooh323_onReceivedDigit(), ooh323_set_read_format(), ooh323_set_write_format(), setup_rtp_connection(), setup_rtp_remote(), and setup_udptl_connection().

811 {
812  struct ooh323_pvt *p;
813 
814  if (gH323Debug)
815  ast_verb(0, "--- find_call\n");
816 
818 
819  for (p = iflist; p; p = p->next) {
820  if (p->callToken && !strcmp(p->callToken, call->callToken)) {
821  break;
822  }
823  }
825 
826  if (gH323Debug)
827  ast_verb(0, "+++ find_call\n");
828 
829  return p;
830 }
struct ooh323_pvt * next
Definition: chan_ooh323.c:248
#define ast_mutex_lock(a)
Definition: lock.h:187
static int call(void *data)
Definition: chan_pjsip.c:2358
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
char * callToken
Definition: chan_ooh323.c:212
static struct ooh323_pvt * iflist
static ast_mutex_t iflock
Definition: chan_ooh323.c:252
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_friend()

struct ooh323_peer * find_friend ( const char *  name,
int  port 
)

Definition at line 858 of file chan_ooh323.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verb, gH323Debug, ooh323_peer::ip, ast_peer_list::lock, ooh323_peer::next, ooh323_pvt::peer, peerl, ast_peer_list::peers, and ooh323_peer::port.

859 {
860  struct ooh323_peer *peer;
861 
862  if (gH323Debug)
863  ast_verb(0, "--- find_friend \"%s\"\n", name);
864 
865 
867  for (peer = peerl.peers; peer; peer = peer->next) {
868  if (gH323Debug) {
869  ast_verb(0, " comparing with \"%s\"\n", peer->ip);
870  }
871  if (!strcmp(peer->ip, name)) {
872  if (port <= 0 || (port > 0 && peer->port == port)) {
873  break;
874  }
875  }
876  }
878 
879  if (gH323Debug) {
880  if (peer) {
881  ast_verb(0, " found matching friend\n");
882  }
883  ast_verb(0, "+++ find_friend \"%s\"\n", name);
884  }
885 
886  return peer;
887 }
static struct ast_peer_list peerl
struct ooh323_peer * next
Definition: chan_ooh323.c:312
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
ast_mutex_t lock
Definition: chan_ooh323.c:324
static const char name[]
Definition: cdr_mysql.c:74
char ip[4 *8+7+2]
Definition: chan_ooh323.c:297
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_peer()

struct ooh323_peer* find_peer ( const char *  name,
int  port 
)

Definition at line 890 of file chan_ooh323.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verb, ooh323_peer::e164, gH323Debug, ooh323_peer::h323id, ooh323_peer::ip, ast_peer_list::lock, ooh323_peer::name, ooh323_peer::next, ooh323_pvt::peer, peerl, and ast_peer_list::peers.

Referenced by ooh323_request().

891 {
892  struct ooh323_peer *peer;
893 
894  if (gH323Debug)
895  ast_verb(0, "--- find_peer \"%s\"\n", name);
896 
897 
899  for (peer = peerl.peers; peer; peer = peer->next) {
900  if (gH323Debug) {
901  ast_verb(0, " comparing with \"%s\"\n", peer->ip);
902  }
903  if (!strcasecmp(peer->name, name))
904  break;
905  if (peer->h323id && !strcasecmp(peer->h323id, name))
906  break;
907  if (peer->e164 && !strcasecmp(peer->e164, name))
908  break;
909  /*
910  if (!strcmp(peer->ip, name)) {
911  if (port > 0 && peer->port == port) { break; }
912  else if (port <= 0) { break; }
913  }
914  */
915  }
917 
918  if (gH323Debug) {
919  if (peer) {
920  ast_verb(0, " found matching peer\n");
921  }
922  ast_verb(0, "+++ find_peer \"%s\"\n", name);
923  }
924 
925  return peer;
926 }
static struct ast_peer_list peerl
struct ooh323_peer * next
Definition: chan_ooh323.c:312
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
ast_mutex_t lock
Definition: chan_ooh323.c:324
static const char name[]
Definition: cdr_mysql.c:74
char * e164
Definition: chan_ooh323.c:302
char name[256]
Definition: chan_ooh323.c:286
char * h323id
Definition: chan_ooh323.c:299
char ip[4 *8+7+2]
Definition: chan_ooh323.c:297
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_user()

struct ooh323_user* find_user ( const char *  name,
const char *  ip 
)

Definition at line 832 of file chan_ooh323.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verb, gH323Debug, ast_user_list::lock, ooh323_user::mIP, ooh323_user::mUseIP, ooh323_user::name, ooh323_user::next, ooh323_pvt::user, userl, and ast_user_list::users.

Referenced by ooh323_destroy(), and ooh323_onReceivedSetup().

833 {
834  struct ooh323_user *user;
835 
836  if (gH323Debug)
837  ast_verb(0, "--- find_user: %s, %s\n",name,ip);
838 
840 
841  for (user = userl.users; user; user = user->next) {
842  if (ip && user->mUseIP && !strcmp(user->mIP, ip)) {
843  break;
844  }
845  if (name && !strcmp(user->name, name)) {
846  break;
847  }
848  }
849 
851 
852  if (gH323Debug)
853  ast_verb(0, "+++ find_user\n");
854 
855  return user;
856 }
static char user[512]
char name[256]
Definition: chan_ooh323.c:257
struct ooh323_user * next
Definition: chan_ooh323.c:280
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
static struct ast_user_list userl
ast_mutex_t lock
Definition: chan_ooh323.c:319
static const char name[]
Definition: cdr_mysql.c:74
char mIP[4 *8+7+2]
Definition: chan_ooh323.c:270
struct ooh323_user * users
Definition: chan_ooh323.c:318
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ function_ooh323_read()

static int function_ooh323_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

OOH323 Dialplan function - reads ooh323 settings.

Definition at line 3685 of file chan_ooh323.c.

References ast_channel_lock, ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_copy_string(), ast_log, ast_mutex_lock, ast_mutex_unlock, ooh323_pvt::callee_dialedDigits, ooh323_pvt::callee_email, ooh323_pvt::callee_h323id, ooh323_pvt::callee_url, ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_email, ooh323_pvt::caller_h323id, ooh323_pvt::caller_url, ooh323_pvt::faxdetect, ooh323_pvt::lock, LOG_ERROR, ooh323_pvt::t38support, and type.

3686 {
3687  struct ooh323_pvt *p = ast_channel_tech_pvt(chan);
3688 
3689  ast_channel_lock(chan);
3690  if (!p) {
3691  ast_channel_unlock(chan);
3692  return -1;
3693  }
3694 
3695  if (strcmp(ast_channel_tech(chan)->type, "OOH323")) {
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);
3698  return -1;
3699  }
3700 
3701  ast_mutex_lock(&p->lock);
3702  if (!strcasecmp(data, "faxdetect")) {
3703  ast_copy_string(buf, p->faxdetect ? "1" : "0", len);
3704  } else if (!strcasecmp(data, "t38support")) {
3705  ast_copy_string(buf, p->t38support ? "1" : "0", len);
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")) {
3722  }
3723  ast_mutex_unlock(&p->lock);
3724 
3725  ast_channel_unlock(chan);
3726  return 0;
3727 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_tech_pvt(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
char callee_dialedDigits[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:222
char caller_h323id[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:217
char callee_h323id[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:221
int t38support
Definition: chan_ooh323.c:191
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_log
Definition: astobj2.c:42
char callee_email[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:223
ast_mutex_t lock
Definition: chan_ooh323.c:185
char caller_email[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:219
#define LOG_ERROR
Definition: logger.h:285
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
char callee_url[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:224
char caller_dialedDigits[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:218
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
char caller_url[256]
Definition: chan_ooh323.c:220
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ function_ooh323_write()

static int function_ooh323_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

OOH323 Dialplan function - writes ooh323 settings.

Definition at line 3730 of file chan_ooh323.c.

References ast_channel_lock, ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_false(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_strdupa, ast_true(), buf, ooh323_pvt::faxdetect, FAXDETECT_CNG, FAXDETECT_T38, ooh323_pvt::lock, LOG_ERROR, LOG_WARNING, ooh323_pvt::next, strsep(), ooh323_pvt::t38support, and type.

3731 {
3732  struct ooh323_pvt *p = ast_channel_tech_pvt(chan);
3733  int res = -1;
3734 
3735  ast_channel_lock(chan);
3736  if (!p) {
3737  ast_channel_unlock(chan);
3738  return -1;
3739  }
3740 
3741  if (strcmp(ast_channel_tech(chan)->type, "OOH323")) {
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);
3744  return -1;
3745  }
3746 
3747  ast_mutex_lock(&p->lock);
3748  if (!strcasecmp(data, "faxdetect")) {
3749  if (ast_true(value)) {
3750  p->faxdetect = 1;
3751  res = 0;
3752  } else if (ast_false(value)) {
3753  p->faxdetect = 0;
3754  res = 0;
3755  } else {
3756  char *buf = ast_strdupa(value);
3757  char *word, *next = buf;
3758  p->faxdetect = 0;
3759  res = 0;
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;
3765  } else {
3766  ast_log(LOG_WARNING, "Unknown faxdetect mode '%s'.\n", word);
3767  res = -1;
3768  }
3769  }
3770 
3771  }
3772  } else if (!strcasecmp(data, "t38support")) {
3773  if (ast_true(value)) {
3774  p->t38support = 1;
3775  res = 0;
3776  } else {
3777  p->t38support = 0;
3778  res = 0;
3779  }
3780  }
3781  ast_mutex_unlock(&p->lock);
3782  ast_channel_unlock(chan);
3783 
3784  return res;
3785 }
static const char type[]
Definition: chan_ooh323.c:109
struct ooh323_pvt * next
Definition: chan_ooh323.c:248
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_tech_pvt(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
int t38support
Definition: chan_ooh323.c:191
#define ast_mutex_lock(a)
Definition: lock.h:187
int value
Definition: syslog.c:37
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define LOG_ERROR
Definition: logger.h:285
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".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
char * strsep(char **str, const char *delims)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
Definition: main/utils.c:1968
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
short word
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ handle_cli_ooh323_reload()

char* handle_cli_ooh323_reload ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)

Definition at line 2778 of file chan_ooh323.c.

References ast_cli_args::argc, ast_mutex_lock, ast_mutex_unlock, ast_verb, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, gH323Debug, h323_reload_lock, h323_reloading, NULL, restart_monitor(), and ast_cli_entry::usage.

2779 {
2780 
2781  switch (cmd) {
2782  case CLI_INIT:
2783  e->command = "ooh323 reload";
2784  e->usage =
2785  "Usage: ooh323 reload\n"
2786  " Reload OOH323 config.\n";
2787  return NULL;
2788  case CLI_GENERATE:
2789  return NULL;
2790  }
2791 
2792  if (a->argc != 2)
2793  return CLI_SHOWUSAGE;
2794 
2795  if (gH323Debug)
2796  ast_verb(0, "--- ooh323_reload\n");
2797 
2799  if (h323_reloading) {
2800  ast_verb(0, "Previous OOH323 reload not yet done\n");
2801  } else {
2802  h323_reloading = 1;
2803  }
2805  restart_monitor();
2806 
2807  if (gH323Debug)
2808  ast_verb(0, "+++ ooh323_reload\n");
2809 
2810  return 0;
2811 }
static int h323_reloading
Definition: chan_ooh323.c:328
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
int restart_monitor(void)
Start the channel monitor thread.
Definition: chan_ooh323.c:4082
#define CLI_SHOWUSAGE
Definition: cli.h:45
static ast_mutex_t h323_reload_lock
Definition: chan_ooh323.c:329
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ handle_cli_ooh323_set_debug()

static char* handle_cli_ooh323_set_debug ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3466 of file chan_ooh323.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, FALSE, ast_cli_args::fd, gH323Debug, NULL, RESULT_SUCCESS, TRUE, and ast_cli_entry::usage.

3467 {
3468  switch (cmd) {
3469  case CLI_INIT:
3470  e->command = "ooh323 set debug [off]";
3471  e->usage =
3472  "Usage: ooh323 set debug [off]\n"
3473  " Enables/Disables debugging of OOH323 channel driver\n";
3474  return NULL;
3475  case CLI_GENERATE:
3476  return NULL;
3477  }
3478 
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;
3483 
3484  gH323Debug = (a->argc == 4) ? FALSE : TRUE;
3485  ast_cli(a->fd, "OOH323 Debugging %s\n", gH323Debug ? "Enabled" : "Disabled");
3486 
3487  return CLI_SUCCESS;
3488 }
#define FALSE
Definition: app_minivm.c:521
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
const int fd
Definition: cli.h:159
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define TRUE
Definition: app_minivm.c:518

◆ handle_cli_ooh323_show_config()

static char* handle_cli_ooh323_show_config ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3558 of file chan_ooh323.c.

References ast_cli_args::argc, ast_channel_amaflags2string(), ast_cli(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_str_alloca, callnumber, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, FAXDETECT_CNG, FAXDETECT_T38, ast_cli_args::fd, FORMAT_STRING_SIZE, gAccountcode, gAliasList, gAMAFLAGS, gCallerID, gContext, gDirectRTP, gDTMFCodec, gDTMFMode, gEarlyDirect, gFastStart, gFAXdetect, gGatekeeper, gH323ep, gIP, gLogFile, gMediaWaitForConnect, gPort, gRasGkMode, gRTDRCount, gRTDRInterval, gT38Support, gTunneling, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_INBANDRELAX, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_config::mTCPPortEnd, ooh323_config::mTCPPortStart, NULL, ooconfig, T38_DISABLED, T38_FAXGW, ast_cli_entry::usage, and value.

3559 {
3560  char value[FORMAT_STRING_SIZE];
3561  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
3562  ooAliases *pAlias = NULL, *pAliasNext = NULL;;
3563 
3564  switch (cmd) {
3565  case CLI_INIT:
3566  e->command = "ooh323 show config";
3567  e->usage =
3568  "Usage: ooh323 show config\n"
3569  " Shows global configuration of H.323 channel driver\n";
3570  return NULL;
3571  case CLI_GENERATE:
3572  return NULL;
3573  }
3574 
3575  if (a->argc != 3)
3576  return CLI_SHOWUSAGE;
3577 
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");
3588 
3589 #if (0)
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");
3597 #endif
3598 
3599  if (gRasGkMode == RasNoGatekeeper) {
3600  snprintf(value, sizeof(value), "%s", "No Gatekeeper");
3601  } else if (gRasGkMode == RasDiscoverGatekeeper) {
3602  snprintf(value, sizeof(value), "%s", "Discover");
3603  } else {
3604  snprintf(value, sizeof(value), "%s", gGatekeeper);
3605  }
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:",
3610  ast_format_cap_get_names(gCap, &codec_buf));
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");
3625  ast_cli(a->fd, "%s\n", "inband-relaxed");
3626  } else if (gDTMFMode & H323_DTMF_INBAND) {
3627  ast_cli(a->fd, "%s\n", "inband");
3628  } else {
3629  ast_cli(a->fd, "%s\n", "unknown");
3630  }
3631 
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/chan_sip compatible");
3637  }
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");
3644  } else {
3645  ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No");
3646  }
3647 
3648  if (gRTDRCount && gRTDRInterval) {
3649  ast_cli(a->fd, "%-20.15s%d,%d\n", "RoundTrip: ", gRTDRCount, gRTDRInterval);
3650  }
3651 
3652  ast_cli(a->fd, "%-20s%ld\n", "Call counter: ", callnumber);
3653  ast_cli(a->fd, "%-20s%s\n", "AccountCode: ", gAccountcode);
3654  ast_cli(a->fd, "%-20s%s\n", "AMA flags: ", ast_channel_amaflags2string(gAMAFLAGS));
3655 
3656  pAlias = gAliasList;
3657  if(pAlias) {
3658  ast_cli(a->fd, "%-20s\n", "Aliases: ");
3659  }
3660  while (pAlias) {
3661  pAliasNext = pAlias->next;
3662  if (pAliasNext) {
3663  ast_cli(a->fd,"\t%-30s\t%-30s\n",pAlias->value, pAliasNext->value);
3664  pAlias = pAliasNext->next;
3665  } else {
3666  ast_cli(a->fd,"\t%-30s\n",pAlias->value);
3667  pAlias = pAlias->next;
3668  }
3669  }
3670  return CLI_SUCCESS;
3671 }
static char gContext[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:378
static struct ooAliases * gAliasList
Definition: chan_ooh323.c:356
static int gFastStart
Definition: chan_ooh323.c:367
static int gDTMFCodec
Definition: chan_ooh323.c:359
static int gTunneling
Definition: chan_ooh323.c:368
static int gPort
Definition: chan_ooh323.c:351
static char gIP[2+8 *4+7]
Definition: chan_ooh323.c:352
const int argc
Definition: cli.h:160
static int gRTDRInterval
Definition: chan_ooh323.c:383
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
static int gDirectRTP
Definition: chan_ooh323.c:371
Definition: cli.h:152
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition: channel.c:4418
static int gRTDRCount
Definition: chan_ooh323.c:383
#define ast_str_alloca(init_len)
Definition: strings.h:800
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
#define T38_FAXGW
Definition: chan_ooh323.c:103
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
static int gFAXdetect
Definition: chan_ooh323.c:360
static char gCallerID[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:355
#define H323_DTMF_Q931
Definition: ooh323cDriver.h:27
const int fd
Definition: cli.h:159
OOH323EndPoint gH323ep
static long callnumber
Definition: chan_ooh323.c:335
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#define CLI_SHOWUSAGE
Definition: cli.h:45
static int gMediaWaitForConnect
Definition: chan_ooh323.c:370
#define T38_DISABLED
Definition: chan_ooh323.c:101
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:736
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
static struct ast_format_cap * gCap
Definition: chan_ooh323.c:357
static int gAMAFLAGS
Definition: chan_ooh323.c:377
static char gGatekeeper[100]
Definition: chan_ooh323.c:362
static int gEarlyDirect
Definition: chan_ooh323.c:372
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
static enum RasGatekeeperMode gRasGkMode
Definition: chan_ooh323.c:364
#define H323_DTMF_INBAND
Definition: ooh323cDriver.h:30
#define H323_DTMF_INBANDRELAX
Definition: ooh323cDriver.h:32
static int gDTMFMode
Definition: chan_ooh323.c:358
static int gT38Support
Definition: chan_ooh323.c:361
#define FORMAT_STRING_SIZE
Definition: chan_ooh323.c:80
static struct ooh323_config ooconfig
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
static char gLogFile[PATH_MAX]
Definition: chan_ooh323.c:349
static char gAccountcode[80]
Definition: chan_ooh323.c:376

◆ handle_cli_ooh323_show_gk()

static char* handle_cli_ooh323_show_gk ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3497 of file chan_ooh323.c.

References ast_cli_args::argc, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, FORMAT_STRING_SIZE, gGatekeeper, gH323ep, gRasGkMode, NULL, ast_cli_entry::usage, and value.

3498 {
3499  char value[FORMAT_STRING_SIZE];
3500 
3501  switch (cmd) {
3502  case CLI_INIT:
3503  e->command = "ooh323 show gk";
3504  e->usage =
3505  "Usage: ooh323 show gk\n"
3506  " Shows Gatekeeper connection state\n";
3507  return NULL;
3508  case CLI_GENERATE:
3509  return NULL;
3510  }
3511 
3512  if (a->argc != 3)
3513  return CLI_SHOWUSAGE;
3514 
3515  ast_cli(a->fd, "\nGateKeeper connection state:\n");
3516  if (!gH323ep.gkClient) {
3517  ast_cli(a->fd, "No Gatekeeper is configured\n");
3518  return CLI_SUCCESS;
3519  }
3520 
3521  if (gRasGkMode == RasNoGatekeeper) {
3522  snprintf(value, sizeof(value), "%s", "No Gatekeeper");
3523  } else if (gRasGkMode == RasDiscoverGatekeeper) {
3524  snprintf(value, sizeof(value), "%s", "Discover");
3525  } else {
3526  snprintf(value, sizeof(value), "%s", gGatekeeper);
3527  }
3528  ast_cli(a->fd, "%-20s%s\n", "Gatekeeper:", value);
3529  switch(gH323ep.gkClient->state) {
3530  case GkClientIdle:
3531  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Idle");
3532  break;
3533  case GkClientDiscovered:
3534  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Discovered");
3535  break;
3536  case GkClientRegistered:
3537  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Registered");
3538  break;
3539  case GkClientUnregistered:
3540  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Unregistered");
3541  break;
3542  case GkClientGkErr:
3543  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Error");
3544  break;
3545  case GkClientFailed:
3546  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Failed");
3547  break;
3548  case GkClientStopped:
3549  ast_cli(a->fd, "%-20s%s\n", "GK state:", "Shutdown");
3550  break;
3551  default:
3552  break;
3553  }
3554 
3555  return CLI_SUCCESS;
3556 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const int fd
Definition: cli.h:159
OOH323EndPoint gH323ep
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
static char gGatekeeper[100]
Definition: chan_ooh323.c:362
static enum RasGatekeeperMode gRasGkMode
Definition: chan_ooh323.c:364
#define FORMAT_STRING_SIZE
Definition: chan_ooh323.c:80

◆ handle_cli_ooh323_show_peer()

static char* handle_cli_ooh323_show_peer ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3188 of file chan_ooh323.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_channel_amaflags2string(), ast_cli(), ast_mutex_lock, ast_mutex_unlock, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, FAXDETECT_CNG, FAXDETECT_T38, ast_cli_args::fd, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_INBANDRELAX, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_peer::lock, ast_peer_list::lock, NULL, ooh323_pvt::peer, peerl, ast_peer_list::peers, T38_DISABLED, T38_FAXGW, and ast_cli_entry::usage.

3189 {
3190  char ip_port[64];
3191  struct ooh323_peer *prev = NULL, *peer = NULL;
3192 
3193  switch (cmd) {
3194  case CLI_INIT:
3195  e->command = "ooh323 show peer";
3196  e->usage =
3197  "Usage: ooh323 show peer <name>\n"
3198  " List details of specific OOH323 peer.\n";
3199  return NULL;
3200  case CLI_GENERATE:
3201  return NULL;
3202  }
3203 
3204  if (a->argc != 4)
3205  return CLI_SHOWUSAGE;
3206 
3208  peer = peerl.peers;
3209  while (peer) {
3210  ast_mutex_lock(&peer->lock);
3211  if (!strcmp(peer->name, a->argv[3])) {
3212  break;
3213  } else {
3214  prev = peer;
3215  peer = peer->next;
3216  ast_mutex_unlock(&prev->lock);
3217  }
3218  }
3219 
3220  if (peer) {
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");
3244  } else {
3245  ast_cli(a->fd, "%s\n", "unknown");
3246  }
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/chan_sip compatible");
3252  }
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");
3259  } else {
3260  ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No");
3261  }
3262 
3263  ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode);
3264  ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_channel_amaflags2string(peer->amaflags));
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);
3271  }
3272  if (peer->rtdrcount && peer->rtdrinterval) {
3273  ast_cli(a->fd, "%-15.15s%d,%d\n", "RoundTrip: ", peer->rtdrcount, peer->rtdrinterval);
3274  }
3275  ast_mutex_unlock(&peer->lock);
3276  } else {
3277  ast_cli(a->fd, "Peer %s not found\n", a->argv[3]);
3278  ast_cli(a->fd, "\n");
3279  }
3281 
3282  return CLI_SUCCESS;
3283 }
static struct ast_peer_list peerl
struct ooh323_peer * next
Definition: chan_ooh323.c:312
const int argc
Definition: cli.h:160
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
Definition: cli.h:152
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition: channel.c:4418
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
#define T38_FAXGW
Definition: chan_ooh323.c:103
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
ast_mutex_t lock
Definition: chan_ooh323.c:324
#define H323_DTMF_Q931
Definition: ooh323cDriver.h:27
const int fd
Definition: cli.h:159
const char *const * argv
Definition: cli.h:161
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define T38_DISABLED
Definition: chan_ooh323.c:101
ast_mutex_t lock
Definition: chan_ooh323.c:285
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
#define H323_DTMF_INBAND
Definition: ooh323cDriver.h:30
#define H323_DTMF_INBANDRELAX
Definition: ooh323cDriver.h:32
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ handle_cli_ooh323_show_peers()

static char* handle_cli_ooh323_show_peers ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3285 of file chan_ooh323.c.

References ast_cli_args::argc, ast_cli(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_mutex_lock, ast_mutex_unlock, ast_str_alloca, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, FORMAT, ooh323_peer::lock, ast_peer_list::lock, NULL, ooh323_pvt::peer, peerl, ast_peer_list::peers, and ast_cli_entry::usage.

3286 {
3287  struct ooh323_peer *prev = NULL, *peer = NULL;
3288  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
3289  char ip_port[64];
3290 #define FORMAT "%-15.15s %-15.15s %-23.23s %-s\n"
3291 
3292  switch (cmd) {
3293  case CLI_INIT:
3294  e->command = "ooh323 show peers";
3295  e->usage =
3296  "Usage: ooh323 show peers\n"
3297  " Lists all known OOH323 peers.\n";
3298  return NULL;
3299  case CLI_GENERATE:
3300  return NULL;
3301  }
3302 
3303  if (a->argc != 3)
3304  return CLI_SHOWUSAGE;
3305 
3306  ast_cli(a->fd, FORMAT, "Name", "Accountcode", "ip:port", "Formats");
3307 
3309  peer = peerl.peers;
3310  while (peer) {
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,
3314  peer->accountcode,
3315  ip_port,
3316  ast_format_cap_get_names(peer->cap, &codec_buf));
3317  prev = peer;
3318  peer = peer->next;
3319  ast_mutex_unlock(&prev->lock);
3320 
3321  }
3323 #undef FORMAT
3324  return CLI_SUCCESS;
3325 }
static struct ast_peer_list peerl
struct ooh323_peer * next
Definition: chan_ooh323.c:312
const int argc
Definition: cli.h:160
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_str_alloca(init_len)
Definition: strings.h:800
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
ast_mutex_t lock
Definition: chan_ooh323.c:324
const int fd
Definition: cli.h:159
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define FORMAT
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:736
ast_mutex_t lock
Definition: chan_ooh323.c:285
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ handle_cli_ooh323_show_user()

static char* handle_cli_ooh323_show_user ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3327 of file chan_ooh323.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_channel_amaflags2string(), ast_cli(), ast_mutex_lock, ast_mutex_unlock, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, FAXDETECT_CNG, FAXDETECT_T38, ast_cli_args::fd, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_INBANDRELAX, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_user::lock, ast_user_list::lock, NULL, T38_DISABLED, T38_FAXGW, ast_cli_entry::usage, ooh323_pvt::user, userl, and ast_user_list::users.

3328 {
3329  struct ooh323_user *prev = NULL, *user = NULL;
3330 
3331  switch (cmd) {
3332  case CLI_INIT:
3333  e->command = "ooh323 show user";
3334  e->usage =
3335  "Usage: ooh323 show user <name>\n"
3336  " List details of specific OOH323 user.\n";
3337  return NULL;
3338  case CLI_GENERATE:
3339  return NULL;
3340  }
3341 
3342  if (a->argc != 4)
3343  return CLI_SHOWUSAGE;
3344 
3345 
3347  user = userl.users;
3348  while (user) {
3349  ast_mutex_lock(&user->lock);
3350  if (!strcmp(user->name, a->argv[3])) {
3351  break;
3352  } else {
3353  prev = user;
3354  user = user->next;
3355  ast_mutex_unlock(&prev->lock);
3356  }
3357  }
3358 
3359  if (user) {
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");
3382  } else {
3383  ast_cli(a->fd, "%s\n", "unknown");
3384  }
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/chan_sip compatible");
3390  }
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");
3397  } else {
3398  ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "No");
3399  }
3400 
3401  ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", user->accountcode);
3402  ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", ast_channel_amaflags2string(user->amaflags));
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);
3410  }
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);
3414  }
3415  } else {
3416  ast_cli(a->fd, "User %s not found\n", a->argv[3]);
3417  ast_cli(a->fd, "\n");
3418  }
3420 
3421  return CLI_SUCCESS;
3422 }
static char user[512]
const int argc
Definition: cli.h:160
Definition: cli.h:152
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Definition: channel.c:4418
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
#define T38_FAXGW
Definition: chan_ooh323.c:103
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
#define H323_DTMF_Q931
Definition: ooh323cDriver.h:27
const int fd
Definition: cli.h:159
ast_mutex_t lock
Definition: chan_ooh323.c:256
static struct ast_user_list userl
ast_mutex_t lock
Definition: chan_ooh323.c:319
const char *const * argv
Definition: cli.h:161
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
#define CLI_SHOWUSAGE
Definition: cli.h:45
#define T38_DISABLED
Definition: chan_ooh323.c:101
char * command
Definition: cli.h:186
structure to hold users read from users.conf
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
#define FAXDETECT_CNG
Definition: chan_ooh323.c:105
#define H323_DTMF_INBAND
Definition: ooh323cDriver.h:30
#define H323_DTMF_INBANDRELAX
Definition: ooh323cDriver.h:32
struct ooh323_user * users
Definition: chan_ooh323.c:318
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ handle_cli_ooh323_show_users()

static char* handle_cli_ooh323_show_users ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3424 of file chan_ooh323.c.

References ast_cli_args::argc, ast_cli(), ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_mutex_lock, ast_mutex_unlock, ast_str_alloca, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, ast_cli_args::fd, FORMAT1, ooh323_user::lock, ast_user_list::lock, NULL, RESULT_SUCCESS, ast_cli_entry::usage, ooh323_pvt::user, userl, and ast_user_list::users.

3425 {
3426  struct ooh323_user *prev = NULL, *user = NULL;
3427  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
3428 #define FORMAT1 "%-15.15s %-15.15s %-15.15s %-s\n"
3429 
3430  switch (cmd) {
3431  case CLI_INIT:
3432  e->command = "ooh323 show users";
3433  e->usage =
3434  "Usage: ooh323 show users \n"
3435  " Lists all known OOH323 users.\n";
3436  return NULL;
3437  case CLI_GENERATE:
3438  return NULL;
3439  }
3440 
3441  if (a->argc != 3)
3442  return CLI_SHOWUSAGE;
3443 
3444 
3445  ast_cli(a->fd, FORMAT1, "Username", "Accountcode", "Context", "Formats");
3446 
3448  user = userl.users;
3449  while(user)
3450  {
3451  ast_mutex_lock(&user->lock);
3452  ast_cli(a->fd, FORMAT1, user->name,
3453  user->accountcode, user->context,
3454  ast_format_cap_get_names(user->cap, &codec_buf));
3455  prev = user;
3456  user = user->next;
3457  ast_mutex_unlock(&prev->lock);
3458 
3459  }
3461 #undef FORMAT1
3462  return RESULT_SUCCESS;
3463 
3464 }
static char user[512]
const int argc
Definition: cli.h:160
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
#define FORMAT1
Definition: cli.h:152
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_str_alloca(init_len)
Definition: strings.h:800
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const int fd
Definition: cli.h:159
ast_mutex_t lock
Definition: chan_ooh323.c:256
static struct ast_user_list userl
ast_mutex_t lock
Definition: chan_ooh323.c:319
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
#define CLI_SHOWUSAGE
Definition: cli.h:45
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:736
char * command
Definition: cli.h:186
structure to hold users read from users.conf
const char * usage
Definition: cli.h:177
#define RESULT_SUCCESS
Definition: cli.h:40
struct ooh323_user * users
Definition: chan_ooh323.c:318
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ load_module()

static int load_module ( void  )
static

Definition at line 3787 of file chan_ooh323.c.

References ao2_ref, ast_channel_register(), ast_cli_register_multiple, ast_debug, ast_format_cap_alloc, ast_format_cap_append, ast_format_cap_append_by_type(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_ulaw, ast_log, AST_MEDIA_TYPE_UNKNOWN, AST_MODULE_LOAD_DECLINE, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_register_atexit(), ast_rtp_glue_register, ast_sched_context_create(), ast_channel_tech::capabilities, ooh323_peer::e164, ooh323_peer::email, gAliasList, gBeMaster, gCallerID, gDTMFCodec, gDTMFMode, gFastStart, gGatekeeper, gInitError, gIP, gIsGateway, gLogFile, gMediaWaitForConnect, gPort, gRasGkMode, gRASIP, gTRCLVL, gTunneling, ooh323_peer::h323id, io_context_create(), ast_user_list::lock, ast_peer_list::lock, LOG_ERROR, LOG_WARNING, manufacturer, ooh323_config::mTCPPortEnd, ooh323_config::mTCPPortStart, ooh323_peer::next, NULL, onAlerting(), onCallCleared(), onCallEstablished(), onModeChanged(), onNewCallCreated(), onOutgoingCall(), onProgress(), ooconfig, ooh323_onReceivedDigit(), ooh323_onReceivedSetup(), ooh323c_set_capability(), ooh323c_start_stack_thread(), ooh323_pvt::peer, peerl, ast_peer_list::peers, reload_config(), restart_monitor(), ast_module_info::self, setup_rtp_remote(), t35countrycode, t35extensions, type, ooh323_peer::url, userl, ast_user_list::users, v6mode, vendor, and version.

Referenced by ooh323_convert_hangupcause_h323ToAsterisk().

3788 {
3789  struct ooAliases * pNewAlias = NULL;
3790  struct ooh323_peer *peer = NULL;
3791  OOH225MsgCallbacks h225Callbacks = {0, 0, 0, 0};
3792 
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,
3805  };
3807  return AST_MODULE_LOAD_DECLINE;
3808  }
3810  ao2_ref(gCap, -1);
3811  gCap = NULL;
3812  return AST_MODULE_LOAD_DECLINE;
3813  }
3816 
3818 
3819  h225Callbacks.onReceivedSetup = &ooh323_onReceivedSetup;
3820 
3821  userl.users = NULL;
3823  peerl.peers = NULL;
3825 
3826 #if 0
3827  ast_register_atexit(&ast_ooh323c_exit);
3828 #endif
3829 
3830  if (!(sched = ast_sched_context_create())) {
3831  ast_log(LOG_WARNING, "Unable to create schedule context\n");
3832  }
3833  if (!(io = io_context_create())) {
3834  ast_log(LOG_WARNING, "Unable to create I/O context\n");
3835  }
3836 
3837 
3838  if (!reload_config(0)) {
3839 
3840  /* fire up the H.323 Endpoint */
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);
3844  ao2_ref(gCap, -1);
3845  gCap = NULL;
3848  return AST_MODULE_LOAD_DECLINE;
3849  }
3850 
3851  /* Make sure we can register our OOH323 channel type */
3853  ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
3854  ao2_ref(gCap, -1);
3855  gCap = NULL;
3858  return AST_MODULE_LOAD_DECLINE;
3859  }
3861  ast_cli_register_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry));
3862 
3863  if (gIsGateway)
3864  ooH323EpSetAsGateway();
3865 
3866  ooH323EpSetVersionInfo(t35countrycode, t35extensions, manufacturer,
3867  vendor, version);
3868  ooH323EpDisableAutoAnswer();
3869  ooH323EpSetH225MsgCallbacks(h225Callbacks);
3870  ooH323EpSetTraceLevel(gTRCLVL);
3871  ooH323EpSetLocalAddress(gIP, gPort);
3872  if (v6mode) {
3873  ast_debug(1, "OOH323 channel is in IP6 mode\n");
3874  }
3875  ooH323EpSetCallerID(gCallerID);
3876 
3877  if(ooH323EpSetTCPPortRange(ooconfig.mTCPPortStart, ooconfig.mTCPPortEnd) == OO_FAILED) {
3878  ast_log(LOG_ERROR, "h225portrange: Failed to set range\n");
3879  }
3880 
3881  /* Set aliases if any */
3882  for (pNewAlias = gAliasList; pNewAlias; pNewAlias = pNewAlias->next) {
3883  switch (pNewAlias->type) {
3884  case T_H225AliasAddress_h323_ID:
3885  ooH323EpAddAliasH323ID(pNewAlias->value);
3886  break;
3887  case T_H225AliasAddress_dialedDigits:
3888  ooH323EpAddAliasDialedDigits(pNewAlias->value);
3889  break;
3890  case T_H225AliasAddress_email_ID:
3891  ooH323EpAddAliasEmailID(pNewAlias->value);
3892  break;
3893  default:
3894  ;
3895  }
3896  }
3897 
3899  peer = peerl.peers;
3900  while (peer) {
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);
3905  peer = peer->next;
3906  }
3908 
3909 
3911  ooH323EpEnableMediaWaitForConnect();
3912  else
3913  ooH323EpDisableMediaWaitForConnect();
3914 
3915  /* Fast start and tunneling options */
3916  if (gFastStart)
3917  ooH323EpEnableFastStart();
3918  else
3919  ooH323EpDisableFastStart();
3920 
3921  if (!gTunneling)
3922  ooH323EpDisableH245Tunneling();
3923 
3924  if (gBeMaster)
3925  ooH323EpTryBeMaster(1);
3926 
3927  ooH323EpEnableManualRingback();
3928 
3929  /* Gatekeeper */
3930  if (gRasGkMode == RasUseSpecificGatekeeper)
3931  ooGkClientInit(gRasGkMode, gGatekeeper, gRASIP, 0);
3932  else if (gRasGkMode == RasDiscoverGatekeeper)
3933  ooGkClientInit(gRasGkMode, 0, gRASIP, 0);
3934 
3935  /* Register callbacks */
3936  ooH323EpSetH323Callbacks(h323Callbacks);
3937 
3938  /* Add endpoint capabilities */
3940  ast_log(LOG_ERROR, "Capabilities failure for OOH323. OOH323 Disabled.\n");
3941  ao2_ref(gCap, -1);
3942  gCap = NULL;
3945  return 1;
3946  }
3947 
3948  /* Create H.323 listener */
3949  if (ooCreateH323Listener() != OO_OK) {
3950  ast_log(LOG_ERROR, "OOH323 Listener Creation failure. "
3951  "OOH323 DISABLED\n");
3952 
3953  ooH323EpDestroy();
3954  ao2_ref(gCap, -1);
3955  gCap = NULL;
3958  return 1;
3959  }
3960 
3961  if (ooh323c_start_stack_thread() < 0) {
3962  ast_log(LOG_ERROR, "Failed to start OOH323 stack thread. "
3963  "OOH323 DISABLED\n");
3964  ooH323EpDestroy();
3965  ao2_ref(gCap, -1);
3966  gCap = NULL;
3969  return 1;
3970  }
3971  /* And start the monitor for the first time */
3972  restart_monitor();
3973  } else {
3974  ast_log(LOG_ERROR, "Can't load ooh323 config file, OOH323 Disabled\n");
3975  return AST_MODULE_LOAD_DECLINE;
3976  }
3977 
3978  return 0;
3979 }
static const char type[]
Definition: chan_ooh323.c:109
static struct ooAliases * gAliasList
Definition: chan_ooh323.c:356
static int gFastStart
Definition: chan_ooh323.c:367
static int gDTMFCodec
Definition: chan_ooh323.c:359
static struct ast_cli_entry cli_ooh323[]
Definition: chan_ooh323.c:3673
static int manufacturer
Definition: chan_ooh323.c:389
static int gTunneling
Definition: chan_ooh323.c:368
static int gPort
Definition: chan_ooh323.c:351
static struct ast_peer_list peerl
static char gIP[2+8 *4+7]
Definition: chan_ooh323.c:352
struct ooh323_peer * next
Definition: chan_ooh323.c:312
char * email
Definition: chan_ooh323.c:300
int onNewCallCreated(ooCallData *call)
Definition: chan_ooh323.c:2089
struct ast_module * myself
Definition: chan_ooh323.c:113
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
descriptor for a cli entry.
Definition: cli.h:171
#define LOG_WARNING
Definition: logger.h:274
#define ast_rtp_glue_register(glue)
Definition: rtp_engine.h:847
struct ooh323_peer * peers
Definition: chan_ooh323.c:323
Definition: sched.c:76
char * url
Definition: chan_ooh323.c:301
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
Definition: format_cap.c:216
int onOutgoingCall(ooCallData *call)
Definition: chan_ooh323.c:2016
#define ast_mutex_lock(a)
Definition: lock.h:187
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 ...
Definition: channel.c:539
#define NULL
Definition: resample.c:96
int v6mode
Definition: chan_ooh323.c:354
int onAlerting(ooCallData *call)
Definition: chan_ooh323.c:1682
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
int restart_monitor(void)
Start the channel monitor thread.
Definition: chan_ooh323.c:4082
#define ast_log
Definition: astobj2.c:42
static char gCallerID[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:355
int onCallCleared(ooCallData *call)
Definition: chan_ooh323.c:2236
struct ast_module * self
Definition: module.h:342
ast_mutex_t lock
Definition: chan_ooh323.c:324
static struct io_context * io
Definition: chan_ooh323.c:401
#define ao2_ref(o, delta)
Definition: astobj2.h:464
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
Definition: clicompat.c:13
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
static struct ast_user_list userl
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
ast_mutex_t lock
Definition: chan_ooh323.c:319
int ooh323c_start_stack_thread()
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:236
static struct ast_rtp_glue ooh323_rtp
Definition: chan_ooh323.c:172
int onProgress(ooCallData *call)
Definition: chan_ooh323.c:1738
#define LOG_ERROR
Definition: logger.h:285
int onCallEstablished(ooCallData *call)
Definition: chan_ooh323.c:2181
void onModeChanged(ooCallData *call, int t38mode)
Definition: chan_ooh323.c:5076
static int gMediaWaitForConnect
Definition: chan_ooh323.c:370
static char gRASIP[2+8 *4+7]
Definition: chan_ooh323.c:363
static int gTRCLVL
Definition: chan_ooh323.c:382
struct ast_format_cap * capabilities
Definition: channel.h:633
int ooh323_onReceivedDigit(OOH323CallData *call, const char *digit)
Definition: chan_ooh323.c:1798
static char version[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:391
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static char vendor[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:390
static int gBeMaster
Definition: chan_ooh323.c:369
int reload_config(int reload)
Definition: chan_ooh323.c:2813
static char gInitError[256]
Definition: chan_ooh323.c:350
static struct ast_channel_tech ooh323_tech
Definition: chan_ooh323.c:150
int ooh323c_set_capability(struct ast_format_cap *cap, int dtmf, int dtmfcodec)
static struct ast_format_cap * gCap
Definition: chan_ooh323.c:357
static char gGatekeeper[100]
Definition: chan_ooh323.c:362
static int t35countrycode
Definition: chan_ooh323.c:387
static int t35extensions
Definition: chan_ooh323.c:388
int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
Definition: chan_ooh323.c:1840
static int gIsGateway
Definition: chan_ooh323.c:366
static enum RasGatekeeperMode gRasGkMode
Definition: chan_ooh323.c:364
#define ast_mutex_init(pmutex)
Definition: lock.h:184
char * e164
Definition: chan_ooh323.c:302
static int gDTMFMode
Definition: chan_ooh323.c:358
void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort)
Definition: chan_ooh323.c:4736
char * h323id
Definition: chan_ooh323.c:299
struct ooh323_user * users
Definition: chan_ooh323.c:318
static struct ooh323_config ooconfig
#define ast_mutex_unlock(a)
Definition: lock.h:188
static char gLogFile[PATH_MAX]
Definition: chan_ooh323.c:349
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...
Definition: io.c:81

◆ onAlerting()

int onAlerting ( ooCallData *  call)

Definition at line 1682 of file chan_ooh323.c.

References ast_channel_queue_connected_line_update(), ast_channel_trylock, ast_channel_unlock, AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, AST_CONTROL_RINGING, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_party_connected_line_init(), ast_queue_control(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_verb, c, DEADLOCK_AVOIDANCE, find_call(), gH323Debug, ast_party_connected_line::id, ast_set_party_connected_line::id, ooh323_pvt::lock, LOG_ERROR, ast_party_id::name, ast_set_party_id::name, NULL, ooh323_pvt::owner, ast_party_connected_line::source, ast_party_name::str, and ast_party_name::valid.

Referenced by load_module().

1683 {
1684  struct ooh323_pvt *p = NULL;
1685  struct ast_channel *c = NULL;
1686 
1687  if (gH323Debug)
1688  ast_verb(0, "--- onAlerting %s\n", call->callToken);
1689 
1690  p = find_call(call);
1691 
1692  if(!p) {
1693  ast_log(LOG_ERROR, "No matching call found\n");
1694  return -1;
1695  }
1696  ast_mutex_lock(&p->lock);
1697  if (!p->owner) {
1698  ast_mutex_unlock(&p->lock);
1699  ast_debug(1, "Channel has no owner\n");
1700  return 0;
1701  }
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);
1705  }
1706  if (!p->owner) {
1707  ast_mutex_unlock(&p->lock);
1708  ast_log(LOG_ERROR, "Channel has no owner\n");
1709  return 0;
1710  }
1711  c = p->owner;
1712 
1713  if (call->remoteDisplayName) {
1715  struct ast_set_party_connected_line update_connected;
1716 
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;
1723  ast_channel_queue_connected_line_update(c, &connected, &update_connected);
1724  }
1725  if (ast_channel_state(c) != AST_STATE_UP)
1727 
1729  ast_channel_unlock(c);
1730  ast_mutex_unlock(&p->lock);
1731 
1732  if (gH323Debug)
1733  ast_verb(0, "+++ onAlerting %s\n", call->callToken);
1734 
1735  return OO_OK;
1736 }
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2022
Main Channel structure associated with a channel.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1231
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:374
ast_channel_state
ast_channel states
Definition: channelstate.h:35
#define ast_mutex_lock(a)
Definition: lock.h:187
static struct test_val c
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
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.
Definition: channel.c:9202
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define LOG_ERROR
Definition: logger.h:285
Connected Line/Party information.
Definition: channel.h:457
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:490
struct ast_channel * owner
Definition: chan_ooh323.c:203
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7486
#define ast_channel_trylock(chan)
Definition: channel.h:2947
char connected
Definition: eagi_proxy.c:82
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ onCallCleared()

int onCallCleared ( ooCallData *  call)

Definition at line 2236 of file chan_ooh323.c.

References ast_channel_hangupcause_set(), ast_channel_softhangup_internal_flag_add(), ast_channel_tech_pvt_set(), ast_channel_trylock, ast_channel_unlock, ast_cond_signal, ast_debug, ast_module_unref, ast_mutex_lock, ast_mutex_unlock, ast_queue_hangup_with_cause(), ast_set_flag, AST_SOFTHANGUP_DEV, ast_test_flag, ast_verb, DEADLOCK_AVOIDANCE, find_call(), gH323Debug, H323_ALREADYGONE, H323_NEEDDESTROY, ooh323_pvt::lock, NULL, ooh323c_stop_call_thread(), ooh323_pvt::owner, ooh323_pvt::rtp, ooh323_pvt::rtpcond, usecnt, and usecnt_lock.

Referenced by load_module().

2237 {
2238  struct ooh323_pvt *p = NULL;
2239  int ownerLock = 0;
2240 
2241  if (gH323Debug)
2242  ast_verb(0, "--- onCallCleared %s \n", call->callToken);
2243 
2244 
2245  if ((p = find_call(call))) {
2246  ast_mutex_lock(&p->lock);
2247 
2248  while (p->owner) {
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);
2253  } else {
2254  ownerLock = 1; break;
2255  }
2256  }
2257 
2258  if (ownerLock) {
2259  if (!ast_test_flag(p, H323_ALREADYGONE)) {
2260 
2262  ast_channel_hangupcause_set(p->owner, call->q931cause);
2264  ast_queue_hangup_with_cause(p->owner,call->q931cause);
2265  }
2266  }
2267 
2268  if(p->owner) {
2271  p->owner = NULL;
2273  }
2274 
2275  if (!p->rtp) {
2276  ast_cond_signal(&p->rtpcond);
2277  }
2278 
2280 
2282 
2283  ast_mutex_unlock(&p->lock);
2285  usecnt--;
2287 
2288  }
2289 
2290  if (gH323Debug)
2291  ast_verb(0, "+++ onCallCleared\n");
2292 
2293  return OO_OK;
2294 }
#define H323_ALREADYGONE
Definition: chan_ooh323.c:94
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_module * myself
Definition: chan_ooh323.c:113
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:374
int ooh323c_stop_call_thread(ooCallData *call)
#define ast_mutex_lock(a)
Definition: lock.h:187
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_cond_signal(cond)
Definition: lock.h:201
#define ast_verb(level,...)
Definition: logger.h:463
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1166
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
static int usecnt
Definition: chan_ooh323.c:332
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define H323_NEEDDESTROY
Definition: chan_ooh323.c:95
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static ast_mutex_t usecnt_lock
Definition: chan_ooh323.c:333
struct ast_channel * owner
Definition: chan_ooh323.c:203
ast_cond_t rtpcond
Definition: chan_ooh323.c:186
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct ast_rtp_instance * rtp
Definition: chan_ooh323.c:187
#define ast_channel_trylock(chan)
Definition: channel.h:2947
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ onCallEstablished()

int onCallEstablished ( ooCallData *  call)

Definition at line 2181 of file chan_ooh323.c.

References ast_channel_publish_snapshot(), ast_channel_queue_connected_line_update(), ast_channel_trylock, ast_channel_unlock, AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, AST_CONTROL_ANSWER, ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_party_connected_line_init(), ast_queue_control(), ast_test_flag, ast_verb, c, DEADLOCK_AVOIDANCE, find_call(), gH323Debug, H323_OUTGOING, ast_party_connected_line::id, ast_set_party_connected_line::id, ooh323_pvt::lock, LOG_ERROR, ast_party_id::name, ast_set_party_id::name, NULL, ooh323_pvt::owner, ast_party_connected_line::source, ast_party_name::str, and ast_party_name::valid.

Referenced by load_module().

2182 {
2183  struct ooh323_pvt *p = NULL;
2184 
2185  if (gH323Debug)
2186  ast_verb(0, "--- onCallEstablished %s\n", call->callToken);
2187 
2188 
2189  if (!(p = find_call(call))) {
2190  ast_log(LOG_ERROR, "Failed to find a matching call.\n");
2191  return -1;
2192  }
2193 
2194  if(ast_test_flag(p, H323_OUTGOING)) {
2195  ast_mutex_lock(&p->lock);
2196  if (!p->owner) {
2197  ast_mutex_unlock(&p->lock);
2198  ast_log(LOG_ERROR, "Channel has no owner\n");
2199  return -1;
2200  }
2201 
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);
2205  }
2206  if (p->owner) {
2207  struct ast_channel* c = p->owner;
2208 
2209  if (call->remoteDisplayName) {
2211  struct ast_set_party_connected_line update_connected;
2212 
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;
2219  ast_channel_queue_connected_line_update(c, &connected, &update_connected);
2220  }
2221 
2225  }
2226  ast_mutex_unlock(&p->lock);
2227 
2228  }
2229 
2230  if (gH323Debug)
2231  ast_verb(0, "+++ onCallEstablished %s\n", call->callToken);
2232 
2233  return OO_OK;
2234 }
#define H323_OUTGOING
Definition: chan_ooh323.c:93
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2022
Main Channel structure associated with a channel.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1231
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:374
#define ast_mutex_lock(a)
Definition: lock.h:187
static struct test_val c
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
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.
Definition: channel.c:9202
ast_mutex_t lock
Definition: chan_ooh323.c:185
#define LOG_ERROR
Definition: logger.h:285
Connected Line/Party information.
Definition: channel.h:457
#define ast_channel_unlock(chan)
Definition: channel.h:2946
Indicate what information in ast_party_connected_line should be set.
Definition: channel.h:490
struct ast_channel * owner
Definition: chan_ooh323.c:203
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
#define ast_channel_trylock(chan)
Definition: channel.h:2947
char connected
Definition: eagi_proxy.c:82
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ onModeChanged()

void onModeChanged ( ooCallData *  call,
int  t38mode 
)

Definition at line 5076 of file chan_ooh323.c.

References ast_async_goto(), ast_channel_caller(), ast_channel_context(), ast_channel_exten(), ast_channel_macrocontext(), ast_channel_name(), ast_channel_trylock, ast_channel_unlock, AST_CONTROL_T38_PARAMETERS, ast_debug, ast_exists_extension(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_queue_control_data(), AST_T38_RATE_14400, AST_T38_REQUEST_NEGOTIATE, AST_T38_REQUEST_TERMINATE, ast_udptl_get_far_max_ifp(), ast_udptl_set_far_max_datagram(), ast_verb, ooh323_pvt::chmodepend, DEADLOCK_AVOIDANCE, ooh323_pvt::faxdetect, FAXDETECT_T38, ooh323_pvt::faxdetected, ooh323_pvt::faxmode, find_call(), gH323Debug, ast_party_caller::id, ooh323_pvt::lock, LOG_ERROR, LOG_NOTICE, ast_control_t38_parameters::max_ifp, NULL, ast_party_id::number, ooh323_pvt::owner, pbx_builtin_setvar_helper(), ast_control_t38_parameters::rate, ast_control_t38_parameters::request_response, S_COR, S_OR, ast_party_number::str, T38_ENABLED, ooh323_pvt::t38_init, ooh323_pvt::t38support, ooh323_pvt::udptl, ast_party_number::valid, and ast_control_t38_parameters::version.

Referenced by load_module().

5076  {
5077  struct ooh323_pvt *p;
5078 
5079  p = find_call(call);
5080  if (!p) {
5081  ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken);
5082  return;
5083  }
5084 
5085  ast_mutex_lock(&p->lock);
5086 
5087  if (gH323Debug)
5088  ast_debug(1, "change mode to %d for %s\n", t38mode, call->callToken);
5089 
5090  if (t38mode == p->faxmode) {
5091  if (gH323Debug)
5092  ast_debug(1, "mode for %s is already %d\n", call->callToken,
5093  t38mode);
5094  p->chmodepend = 0;
5095  ast_mutex_unlock(&p->lock);
5096  return;
5097  }
5098 
5099  if (p->owner) {
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);
5103  }
5104  if (!p->owner) {
5105  p->chmodepend = 0;
5106  ast_mutex_unlock(&p->lock);
5107  ast_log(LOG_ERROR, "Channel has no owner\n");
5108  return;
5109  }
5110  } else {
5111  p->chmodepend = 0;
5112  ast_mutex_unlock(&p->lock);
5113  ast_log(LOG_ERROR, "Channel has no owner\n");
5114  return;
5115  }
5116 
5117  if (t38mode) {
5118 
5119 
5120  if (p->t38support == T38_ENABLED) {
5121  struct ast_control_t38_parameters parameters = { .request_response = 0 };
5122 
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 = S_OR(ast_channel_macrocontext(p->owner), ast_channel_context(p->owner));
5127  if ((strcmp(ast_channel_exten(p->owner), "fax")) &&
5128  (ast_exists_extension(p->owner, target_context, "fax", 1,
5130  ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner));
5132  if (ast_async_goto(p->owner, target_context, "fax", 1)) {
5133  ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);
5134  }
5135  }
5136  p->faxdetected = 1;
5137  }
5138 
5139 /* AST_T38_CONTROL mode */
5140 
5142  if (call->T38FarMaxDatagram) {
5143  ast_udptl_set_far_max_datagram(p->udptl, call->T38FarMaxDatagram);
5144  } else {
5146  }
5147  if (call->T38Version) {
5148  parameters.version = call->T38Version;
5149  }
5150  parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl);
5151  parameters.rate = AST_T38_RATE_14400;
5153  &parameters, sizeof(parameters));
5154  p->faxmode = 1;
5155 
5156 
5157  }
5158  } else {
5159  if (p->t38support == T38_ENABLED) {
5160  struct ast_control_t38_parameters parameters = { .request_response = 0 };
5162  parameters.max_ifp = ast_udptl_get_far_max_ifp(p->udptl);
5163  parameters.rate = AST_T38_RATE_14400;
5165  &parameters, sizeof(parameters));
5166  }
5167  p->faxmode = 0;
5168  p->faxdetected = 0;
5169  p->t38_init = 0;
5170  }
5171 
5172  p->chmodepend = 0;
5174  ast_mutex_unlock(&p->lock);
5175 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define T38_ENABLED
Definition: chan_ooh323.c:102
char * str
Subscriber phone number (Malloced)
Definition: channel.h:292
#define DEADLOCK_AVOIDANCE(lock)
Definition: lock.h:374
enum ast_control_t38 request_response
int t38support
Definition: chan_ooh323.c:191
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...
Definition: udptl.c:997
#define ast_mutex_lock(a)
Definition: lock.h:187
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
struct ast_udptl * udptl
Definition: chan_ooh323.c:195
#define ast_verb(level,...)
Definition: logger.h:463
#define FAXDETECT_T38
Definition: chan_ooh323.c:106
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:85
enum ast_control_t38_rate rate
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4179
const char * ast_channel_exten(const struct ast_channel *chan)
ast_mutex_t lock
Definition: chan_ooh323.c:185
unsigned int ast_udptl_get_far_max_ifp(struct ast_udptl *udptl)
retrieves far max ifp
Definition: udptl.c:1016
#define LOG_ERROR
Definition: logger.h:285
int faxdetected
Definition: chan_ooh323.c:193
#define LOG_NOTICE
Definition: logger.h:263
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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...
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel * owner
Definition: chan_ooh323.c:203
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.
Definition: pbx.c:7011
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.
Definition: channel.c:1238
const char * ast_channel_context(const struct ast_channel *chan)
int chmodepend
Definition: chan_ooh323.c:201
#define ast_channel_trylock(chan)
Definition: channel.h:2947
const char * ast_channel_macrocontext(const struct ast_channel *chan)
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:298
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ onNewCallCreated()

int onNewCallCreated ( ooCallData *  call)

Definition at line 2089 of file chan_ooh323.c.

References ast_cond_signal, ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_str_alloca, ast_strlen_zero, ast_verb, ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_h323id, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, ooh323_pvt::cap, configure_local_rtp(), ooh323_pvt::dtmfcodec, ooh323_pvt::dtmfmode, ooh323_pvt::exten, find_call(), ooh323_pvt::g729onlyA, gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, ooh323c_set_capability_for_call(), ooh323c_start_call_thread(), ooh323_pvt::rtpcond, ooh323_pvt::t38support, and ooh323_pvt::username.

Referenced by load_module().

2090 {
2091  struct ooh323_pvt *p = NULL;
2092  int i = 0;
2093 
2094  if (gH323Debug)
2095  ast_verb(0, "--- onNewCallCreated %lx: %s\n", (long unsigned int) call, call->callToken);
2096 
2097  ast_mutex_lock(&call->Lock);
2099  ast_log(LOG_ERROR,"Failed to create call thread.\n");
2100  ast_mutex_unlock(&call->Lock);
2101  return -1;
2102  }
2103 
2104  if (!strcmp(call->callType, "outgoing")) {
2105  p = find_call(call);
2106  if (!p) {
2107  ast_log(LOG_ERROR, "Failed to find a matching call.\n");
2108  ast_mutex_unlock(&call->Lock);
2109  return -1;
2110  }
2111  ast_mutex_lock(&p->lock);
2112 
2113  if (!ast_strlen_zero(p->callerid_name)) {
2114  ooCallSetCallerId(call, p->callerid_name);
2115  }
2116  if (!ast_strlen_zero(p->callerid_num)) {
2117  i = 0;
2118  while (*(p->callerid_num + i) != '\0') {
2119  if(!isdigit(*(p->callerid_num+i))) { break; }
2120  i++;
2121  }
2122  if(*(p->callerid_num+i) == '\0')
2123  ooCallSetCallingPartyNumber(call, p->callerid_num);
2124  else {
2126  ooCallSetCallerId(call, p->callerid_num);
2127  }
2128  }
2129 
2130  if (!ast_strlen_zero(p->caller_h323id))
2131  ooCallAddAliasH323ID(call, p->caller_h323id);
2132 
2134  if (gH323Debug) {
2135  ast_verb(0, "Setting dialed digits %s\n", p->caller_dialedDigits);
2136  }
2137  ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
2138  } else if (!ast_strlen_zero(p->callerid_num)) {
2139  if (ooIsDailedDigit(p->callerid_num)) {
2140  if (gH323Debug) {
2141  ast_verb(0, "setting callid number %s\n", p->callerid_num);
2142  }
2143  ooCallAddAliasDialedDigits(call, p->callerid_num);
2144  } else if (ast_strlen_zero(p->caller_h323id)) {
2145  ooCallAddAliasH323ID(call, p->callerid_num);
2146  }
2147  }
2148 
2149 
2150  if (!ast_strlen_zero(p->exten)) {
2151  if (ooIsDailedDigit(p->exten)) {
2152  ooCallSetCalledPartyNumber(call, p->exten);
2153  ooCallAddRemoteAliasDialedDigits(call, p->exten);
2154  } else {
2155  ooCallAddRemoteAliasH323ID(call, p->exten);
2156  }
2157  }
2158 
2159  if (gH323Debug) {
2160  struct ast_str *codec_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
2161 
2162  ast_verb(0, " Outgoing call %s(%s) - Codec prefs - %s\n",
2163  p->username?p->username:"NULL", call->callToken,
2164  ast_format_cap_get_names(p->cap, &codec_buf));
2165  }
2166 
2168  p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA);
2169 
2171  ast_cond_signal(&p->rtpcond);
2172  ast_mutex_unlock(&p->lock);
2173  }
2174 
2175  ast_mutex_unlock(&call->Lock);
2176  if (gH323Debug)
2177  ast_verb(0, "+++ onNewCallCreated %s\n", call->callToken);
2178  return OO_OK;
2179 }
char caller_h323id[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:217
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
char * username
Definition: chan_ooh323.c:213
int ooh323c_start_call_thread(ooCallData *call)
int t38support
Definition: chan_ooh323.c:191
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_str_alloca(init_len)
Definition: strings.h:800
static int call(void *data)
Definition: chan_pjsip.c:2358
char * callerid_name
Definition: chan_ooh323.c:215
#define NULL
Definition: resample.c:96
#define ast_cond_signal(cond)
Definition: lock.h:201
#define ast_verb(level,...)
Definition: logger.h:463
#define ast_strlen_zero(foo)
Definition: strings.h:52
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
#define ast_log
Definition: astobj2.c:42
struct ast_format_cap * cap
Definition: chan_ooh323.c:229
ast_mutex_t lock
Definition: chan_ooh323.c:185
char exten[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:232
#define LOG_ERROR
Definition: logger.h:285
char * callerid_num
Definition: chan_ooh323.c:216
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call)
Definition: chan_ooh323.c:4599
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:736
char caller_dialedDigits[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:218
ast_cond_t rtpcond
Definition: chan_ooh323.c:186
int ooh323c_set_capability_for_call(ooCallData *call, struct ast_format_cap *cap, int dtmf, int dtmfcodec, int t38support, int g729onlyA)
static struct ooh323_pvt * find_call(ooCallData *call)
Definition: chan_ooh323.c:810
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ onOutgoingCall()

int onOutgoingCall ( ooCallData *  call)

Definition at line 2016 of file chan_ooh323.c.

References ast_copy_string(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero, ast_verb, ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_h323id, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, configure_local_rtp(), find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, NULL, ooh323_pvt::rtp, ooh323_pvt::rtpmask, and ooh323_pvt::rtpmaskstr.

Referenced by load_module().

2017 {
2018  struct ooh323_pvt *p = NULL;
2019  int i = 0;
2020 
2021  if (gH323Debug)
2022  ast_verb(0, "--- onOutgoingCall %lx: %s\n", (long unsigned int) call, call->callToken);
2023 
2024  if (!strcmp(call->callType, "outgoing")) {
2025  p = find_call(call);
2026  if (!p) {
2027  ast_log(LOG_ERROR, "Failed to find a matching call.\n");
2028  return -1;
2029  }
2030  ast_mutex_lock(&p->lock);
2031 
2032  if (!ast_strlen_zero(p->callerid_name)) {
2033  ooCallSetCallerId(call, p->callerid_name);
2034  }
2035  if (!ast_strlen_zero(p->callerid_num)) {
2036  i = 0;
2037  while (*(p->callerid_num + i) != '\0') {
2038  if(!isdigit(*(p->callerid_num+i))) { break; }
2039  i++;
2040  }
2041  if(*(p->callerid_num+i) == '\0')
2042  ooCallSetCallingPartyNumber(call, p->callerid_num);
2043  else {
2044  if(!p->callerid_name)
2045  ooCallSetCallerId(call, p->callerid_num);
2046  }
2047  }
2048 
2049  if (!ast_strlen_zero(p->caller_h323id))
2050  ooCallAddAliasH323ID(call, p->caller_h323id);
2051 
2053  if (gH323Debug) {
2054  ast_verb(0, "Setting dialed digits %s\n", p->caller_dialedDigits);
2055  }
2056  ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
2057  } else if (!ast_strlen_zero(p->