Fri Jul 3 20:37:18 2009

Asterisk developer's documentation


chan_ooh323.c File Reference

#include "chan_ooh323.h"

Include dependency graph for chan_ooh323.c:

Go to the source code of this file.

Data Structures

struct  ast_peer_list
 The peer list: Peers and Friends. More...
struct  ast_user_list
 The user list: Users and friends. More...
struct  ooh323_config
struct  ooh323_peer
struct  ooh323_pvt
struct  ooh323_user

Defines

#define DEFAULT_CONTEXT   "default"
#define DEFAULT_H323ACCNT   "ast_h323"
#define DEFAULT_H323ID   "Asterisk PBX"
#define DEFAULT_LOGFILE   "/var/log/asterisk/h323_log"
#define FORMAT   "%-15.15s %-15.15s %-23.23s %-s\n"
#define FORMAT1   "%-15.15s %-15.15s %-15.15s %-s\n"
#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_OUTGOING   (1<<4)
#define H323_SILENCESUPPRESSION   (1<<0)
#define H323_TUNNELING   (1<<2)

Functions

static void __reg_module (void)
static void __unreg_module (void)
static void ast_ooh323c_exit ()
static struct ooh323_peer * build_peer (const char *name, struct ast_variable *v, int friend_type)
static struct ooh323_user * build_user (const char *name, struct ast_variable *v)
void close_rtp_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_pvt * find_call (ooCallData *call)
struct ooh323_peer * find_friend (const char *name, int port)
struct ooh323_peer * find_peer (const char *name, int port)
struct ooh323_user * find_user (const char *name, const char *ip)
static int load_module (void)
int onAlerting (ooCallData *call)
int onCallCleared (ooCallData *call)
int onCallEstablished (ooCallData *call)
int onNewCallCreated (ooCallData *call)
static struct ooh323_pvt * ooh323_alloc (int callref, char *callToken)
static int ooh323_answer (struct ast_channel *ast)
static int ooh323_call (struct ast_channel *ast, char *dest, int timeout)
int ooh323_convert_hangupcause_asteriskToH323 (int cause)
int ooh323_convert_hangupcause_h323ToAsterisk (int cause)
int ooh323_convertAsteriskCapToH323Cap (int cap)
void ooh323_delete_peer (struct ooh323_peer *peer)
static void ooh323_delete_user (struct ooh323_user *user)
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_debug (int fd, int argc, char *argv[])
static int ooh323_do_reload (void)
static int ooh323_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
static enum ast_rtp_get_result ooh323_get_rtp_peer (struct ast_channel *chan, struct ast_rtp **rtp)
static enum ast_rtp_get_result ooh323_get_vrtp_peer (struct ast_channel *chan, struct ast_rtp **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_channel * ooh323_new (struct ooh323_pvt *i, int state, const char *host)
static int ooh323_no_debug (int fd, int argc, char *argv[])
int ooh323_onReceivedDigit (OOH323CallData *call, const char *digit)
int ooh323_onReceivedSetup (ooCallData *call, Q931Message *pmsg)
static struct ast_frame * ooh323_read (struct ast_channel *ast)
static int ooh323_reload (int fd, int argc, char *argv[])
static struct ast_channel * ooh323_request (const char *type, int format, void *data, int *cause)
struct ast_frame * ooh323_rtp_read (struct ast_channel *ast, struct ooh323_pvt *p)
void ooh323_set_read_format (ooCallData *call, int fmt)
static int ooh323_set_rtp_peer (struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
void ooh323_set_write_format (ooCallData *call, int fmt)
static int ooh323_show_channels (int fd, int argc, char *argv[])
static int ooh323_show_config (int fd, int argc, char *argv[])
static int ooh323_show_peer (int fd, int argc, char *argv[])
static int ooh323_show_peers (int fd, int argc, char *argv[])
static int ooh323_show_user (int fd, int argc, char *argv[])
static int ooh323_show_users (int fd, int argc, char *argv[])
int ooh323_update_capPrefsOrderForCall (ooCallData *call, struct ast_codec_pref *prefs)
static int ooh323_write (struct ast_channel *ast, struct ast_frame *f)
static void print_codec_to_cli (int fd, struct ast_codec_pref *pref)
 Print codec list from preference to CLI/manager.
static int reload (void *mod)
int reload_config (void)
int restart_monitor (void)
 Start the channel monitor thread.
void setup_rtp_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_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
static const struct
ast_module_info * 
ast_module_info = &__mod_info
static struct ast_cli_entry cli_debug
static struct ast_cli_entry cli_no_debug
static struct ast_cli_entry cli_show_config
static struct ast_cli_entry cli_show_peer
static struct ast_cli_entry cli_show_peers
static struct ast_cli_entry cli_show_user
static struct ast_cli_entry cli_show_users
static const char config [] = "ooh323.conf"
static char debug_usage []
static char gAccountcode [80] = DEFAULT_H323ACCNT
static struct ooAliases * gAliasList
static int gAMAFLAGS
static char gCallerID [AST_MAX_EXTENSION] = DEFAULT_H323ID
static int gCapability = AST_FORMAT_ULAW
static char gContext [AST_MAX_EXTENSION] = DEFAULT_CONTEXT
static int gDTMFMode = H323_DTMF_RFC2833
static int gFastStart = 1
static char gGatekeeper [100]
OOBOOL gH323Debug = FALSE
static int gIncomingLimit = 4
static char gIP [20]
static int gIsGateway = 0
static char gLogFile [256] = DEFAULT_LOGFILE
static int gMediaWaitForConnect = 0
static int gOutgoingLimit = 4
static int gPort = 1720
static struct ast_codec_pref gPrefs
static enum RasGatekeeperMode gRasGkMode = RasNoGatekeeper
static int gRTPTimeout = 60
static int gTOS = 0
static int gTunneling = 1
static ast_mutex_t h323_reload_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static int h323_reloading = 0
static struct ooh323_pvt * iflist
static ast_mutex_t iflock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static struct io_context * io
static pthread_t monitor_thread = AST_PTHREADT_NULL
static ast_mutex_t monlock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static char no_debug_usage []
static struct ooh323_config ooconfig
static struct ast_rtp_protocol ooh323_rtp
static struct ast_channel_tech ooh323_tech
static ast_mutex_t ooh323c_cmd_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static struct ast_peer_list peerl
static struct sched_context * sched
static char show_config_usage []
static char show_peer_usage []
static char show_peers_usage []
static char show_user_usage []
static char show_users_usage []
static const char tdesc [] = "Objective Systems H323 Channel Driver"
static const char type [] = "OOH323"
static int usecnt = 0
static ast_mutex_t usecnt_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static struct ast_user_list userl


Define Documentation

#define DEFAULT_CONTEXT   "default"

Definition at line 21 of file chan_ooh323.c.

Referenced by reload_config().

#define DEFAULT_H323ACCNT   "ast_h323"

Definition at line 24 of file chan_ooh323.c.

Referenced by reload_config().

#define DEFAULT_H323ID   "Asterisk PBX"

Definition at line 22 of file chan_ooh323.c.

Referenced by reload_config().

#define DEFAULT_LOGFILE   "/var/log/asterisk/h323_log"

Definition at line 23 of file chan_ooh323.c.

Referenced by reload_config().

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

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

Referenced by ooh323_show_users().

#define H323_ALREADYGONE   (1<<5)

Definition at line 32 of file chan_ooh323.c.

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

#define H323_DISABLEGK   (1<<7)

Definition at line 34 of file chan_ooh323.c.

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

#define H323_FASTSTART   (1<<3)

Definition at line 30 of file chan_ooh323.c.

#define H323_GKROUTED   (1<<1)

Definition at line 28 of file chan_ooh323.c.

#define H323_NEEDDESTROY   (1<<6)

Definition at line 33 of file chan_ooh323.c.

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

#define H323_OUTGOING   (1<<4)

#define H323_SILENCESUPPRESSION   (1<<0)

Definition at line 27 of file chan_ooh323.c.

#define H323_TUNNELING   (1<<2)

Definition at line 29 of file chan_ooh323.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 3390 of file chan_ooh323.c.

static void __unreg_module ( void   )  [static]

Definition at line 3390 of file chan_ooh323.c.

static void ast_ooh323c_exit (  )  [static]

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

Definition at line 1710 of file chan_ooh323.c.

References ooh323_peer::accountcode, ooh323_peer::amaflags, ast_cdr_amaflags2int(), ast_log(), ast_mutex_init(), ast_parse_allow_disallow(), ast_verbose(), ooh323_peer::capability, ooh323_peer::dtmfmode, ooh323_peer::e164, ooh323_peer::email, gAccountcode, gAMAFLAGS, gCapability, gDTMFMode, gH323Debug, gPrefs, gRTPTimeout, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_peer::h323id, ooh323_peer::ip, ooh323_peer::lock, LOG_ERROR, malloc, ooh323_peer::mFriend, ast_variable::name, ooh323_peer::name, ast_variable::next, ooh323_delete_peer(), ooh323_peer::outgoinglimit, ooh323_peer::port, ooh323_peer::prefs, ooh323_peer::rtptimeout, ooh323_peer::url, and ast_variable::value.

Referenced by reload_config().

01711 {
01712    struct ooh323_peer *peer=NULL;
01713 
01714    if(gH323Debug)
01715       ast_verbose("---   build_peer\n");
01716 
01717    peer = (struct ooh323_peer *)malloc(sizeof(struct ooh323_peer));
01718    if (peer) {
01719       memset(peer, 0, sizeof(struct ooh323_peer));
01720       ast_mutex_init(&peer->lock);
01721       strncpy(peer->name, name, sizeof(peer->name)-1);
01722       peer->capability = gCapability;
01723       memcpy(&peer->prefs, &gPrefs, sizeof(struct ast_codec_pref));
01724       peer->rtptimeout = gRTPTimeout;
01725       strncpy(peer->accountcode, gAccountcode, sizeof(peer->accountcode)-1);
01726       peer->amaflags = gAMAFLAGS;
01727       peer->dtmfmode = gDTMFMode;
01728       if(0 == friend_type) {
01729          peer->mFriend = 1;
01730       }
01731 
01732       while(v) {
01733          if (!strcasecmp(v->name, "h323id")) {
01734             peer->h323id = (char*)malloc(strlen(v->value)+1);
01735             if(!peer->h323id)
01736             {
01737                ast_log(LOG_ERROR, "Could not allocate memory for h323id of "
01738                                   "peer %s\n", name);
01739                ooh323_delete_peer(peer);
01740                return NULL;
01741             }
01742             strcpy(peer->h323id, v->value);
01743          } 
01744          else if (!strcasecmp(v->name, "e164")) {
01745             peer->e164 = (char*)malloc(strlen(v->value)+1);
01746             if(!peer->e164)
01747             {
01748                ast_log(LOG_ERROR, "Could not allocate memory for e164 of "
01749                                   "peer %s\n", name);
01750                ooh323_delete_peer(peer);
01751                return NULL;
01752             }
01753             strcpy(peer->e164, v->value);
01754          } 
01755          else  if (!strcasecmp(v->name, "email")) {
01756             peer->email = (char*)malloc(strlen(v->value)+1);
01757             if(!peer->email)
01758             {
01759                ast_log(LOG_ERROR, "Could not allocate memory for email of "
01760                                   "peer %s\n", name);
01761                ooh323_delete_peer(peer);
01762                return NULL;
01763             }
01764             strcpy(peer->email, v->value);
01765          } 
01766          else if (!strcasecmp(v->name, "url")) {
01767             peer->url = (char*)malloc(strlen(v->value)+1);
01768             if(!peer->url)
01769             {
01770                ast_log(LOG_ERROR, "Could not allocate memory for h323id of "
01771                                   "peer %s\n", name);
01772                ooh323_delete_peer(peer);
01773                return NULL;
01774             }
01775             strcpy(peer->url, v->value);
01776          }
01777          else if (!strcasecmp(v->name, "port")) {
01778             peer->port = atoi(v->value);
01779          } 
01780          else if (!strcasecmp(v->name, "ip")) {
01781             strncpy(peer->ip, v->value, sizeof(peer->ip)-1);
01782          } 
01783          else if (!strcasecmp(v->name, "outgoinglimit")) {
01784             peer->outgoinglimit = atoi(v->value);
01785             if (peer->outgoinglimit < 0)
01786                peer->outgoinglimit = 0;
01787          }
01788          else if (!strcasecmp(v->name, "accountcode")) {
01789             strncpy(peer->accountcode, v->value, sizeof(peer->accountcode)-1);
01790          }
01791          else if (!strcasecmp(v->name, "rtptimeout")) {
01792             peer->rtptimeout = atoi(v->value);
01793             if(peer->rtptimeout < 0)
01794                peer->rtptimeout = gRTPTimeout;
01795          }
01796          else if (!strcasecmp(v->name, "disallow")) {
01797             ast_parse_allow_disallow(&peer->prefs, &peer->capability, 
01798                                      v->value, 0); 
01799          }
01800          else if (!strcasecmp(v->name, "allow")) {
01801             const char* tcodecs = v->value;
01802             if(!strcasecmp(v->value, "all")) {
01803                tcodecs = "ulaw,alaw,g729,g723,gsm";
01804             }
01805             ast_parse_allow_disallow(&peer->prefs, &peer->capability, 
01806                                      tcodecs, 1);             
01807          }
01808          else if (!strcasecmp(v->name,  "amaflags")) {
01809             peer->amaflags = ast_cdr_amaflags2int(v->value);
01810          }
01811          else if (!strcasecmp(v->name, "dtmfmode")) {
01812             if(!strcasecmp(v->value, "rfc2833"))
01813                peer->dtmfmode = H323_DTMF_RFC2833;
01814             else if(!strcasecmp(v->value, "q931keypad"))
01815                peer->dtmfmode = H323_DTMF_Q931;
01816             else if(!strcasecmp(v->value, "h245alphanumeric"))
01817                peer->dtmfmode = H323_DTMF_H245ALPHANUMERIC;
01818             else if(!strcasecmp(v->value, "h245signal"))
01819                peer->dtmfmode = H323_DTMF_H245SIGNAL;
01820          }
01821          v = v->next;
01822       }
01823    }
01824 
01825    if(gH323Debug)
01826       ast_verbose("+++   build_peer\n");
01827 
01828    return peer;
01829 }

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

Definition at line 1633 of file chan_ooh323.c.

References ooh323_user::accountcode, ooh323_user::amaflags, ast_cdr_amaflags2int(), ast_mutex_init(), ast_parse_allow_disallow(), ast_verbose(), ooh323_user::capability, ooh323_user::context, ooh323_user::dtmfmode, gAccountcode, gAMAFLAGS, gCapability, gContext, gDTMFMode, gH323Debug, gPrefs, gRTPTimeout, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_user::incominglimit, ooh323_user::lock, malloc, ooh323_user::mIP, ooh323_user::mUseIP, ast_variable::name, ooh323_user::name, ast_variable::next, ooh323_user::prefs, ooh323_user::rtptimeout, and ast_variable::value.

Referenced by reload_config().

01634 {
01635    struct ooh323_user *user=NULL;
01636 
01637    if(gH323Debug)
01638       ast_verbose("---   build_user\n");
01639 
01640    user = (struct ooh323_user *)malloc(sizeof(struct ooh323_user));
01641    if (user) {
01642       memset(user, 0, sizeof(struct ooh323_user));
01643       ast_mutex_init(&user->lock);
01644       strncpy(user->name, name, sizeof(user->name)-1);
01645       user->capability = gCapability;
01646       memcpy(&user->prefs, &gPrefs, sizeof(struct ast_codec_pref));
01647       user->rtptimeout = gRTPTimeout;
01648       user->dtmfmode = gDTMFMode;
01649       /* set default context */
01650       strncpy(user->context, gContext, sizeof(user->context)-1);
01651       strncpy(user->accountcode, gAccountcode, sizeof(user->accountcode)-1);
01652       user->amaflags = gAMAFLAGS;
01653 
01654       while(v) {
01655          if (!strcasecmp(v->name, "context")) {
01656             strncpy(user->context, v->value, sizeof(user->context) - 1);
01657          }
01658          else if (!strcasecmp(v->name, "incominglimit")) {
01659             user->incominglimit = atoi(v->value);
01660             if (user->incominglimit < 0)
01661                user->incominglimit = 0;
01662          }
01663          else if (!strcasecmp(v->name, "accountcode")) {
01664             strncpy(user->accountcode, v->value, sizeof(user->accountcode)-1);
01665          }
01666          else if (!strcasecmp(v->name, "rtptimeout")) {
01667             user->rtptimeout = atoi(v->value);
01668             if(user->rtptimeout < 0)
01669                user->rtptimeout = gRTPTimeout;
01670          }
01671          else if (!strcasecmp(v->name, "disallow")) {
01672             ast_parse_allow_disallow(&user->prefs, &user->capability, 
01673                                      v->value, 0);
01674          }
01675          else if (!strcasecmp(v->name, "allow")) {
01676             const char* tcodecs = v->value;
01677             if(!strcasecmp(v->value, "all")) {
01678                tcodecs = "ulaw,alaw,g729,g723,gsm";
01679             }
01680             ast_parse_allow_disallow(&user->prefs, &user->capability, 
01681                                      tcodecs, 1);
01682          }
01683          else if (!strcasecmp(v->name, "amaflags")) {
01684             user->amaflags = ast_cdr_amaflags2int(v->value);
01685          }
01686          else if (!strcasecmp(v->name, "ip")) {
01687             strncpy(user->mIP, v->value, sizeof(user->mIP)-1);
01688             user->mUseIP = 1;
01689          }
01690          else if (!strcasecmp(v->name, "dtmfmode")) {
01691             if(!strcasecmp(v->value, "rfc2833"))
01692                user->dtmfmode = H323_DTMF_RFC2833;
01693             else if(!strcasecmp(v->value, "q931keypad"))
01694                user->dtmfmode = H323_DTMF_Q931;
01695             else if(!strcasecmp(v->value, "h245alphanumeric"))
01696                user->dtmfmode = H323_DTMF_H245ALPHANUMERIC;
01697             else if(!strcasecmp(v->value, "h245signal"))
01698                user->dtmfmode = H323_DTMF_H245SIGNAL;
01699          } 
01700          v = v->next;
01701       }
01702    }
01703 
01704    if(gH323Debug)
01705       ast_verbose("+++   build_user\n");
01706 
01707    return user;
01708 }

void close_rtp_connection ( ooCallData *  call  ) 

Definition at line 3212 of file chan_ooh323.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_stop(), ast_verbose(), find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, and ooh323_pvt::rtp.

Referenced by ooh323c_stop_transmit_channel().

03213 {
03214    struct ooh323_pvt *p = NULL;
03215 
03216    if(gH323Debug)
03217       ast_verbose("---   close_rtp_connection\n");
03218 
03219    p = find_call(call);
03220    if(!p)
03221    {
03222       ast_log(LOG_ERROR, "Couldn't find matching call to close rtp "
03223                          "connection\n");
03224       return;
03225    }
03226    ast_mutex_lock(&p->lock);
03227    if(p->rtp){
03228       ast_rtp_stop(p->rtp);
03229    }
03230    ast_mutex_unlock(&p->lock);
03231 
03232    if(gH323Debug)
03233       ast_verbose("+++   close_rtp_connection\n");
03234 
03235    return;
03236 }

int configure_local_rtp ( struct ooh323_pvt *  p,
ooCallData *  call 
)

Definition at line 3143 of file chan_ooh323.c.

References ast_codec_pref_index(), ast_inet_ntoa(), ast_rtp_codec_setpref(), ast_rtp_get_us(), ast_verbose(), format, gH323Debug, ooh323_convertAsteriskCapToH323Cap(), ooh323_pvt::prefs, and ooh323_pvt::rtp.

Referenced by onNewCallCreated(), and ooh323_onReceivedSetup().

03144 {
03145    struct sockaddr_in us;
03146    ooMediaInfo mediaInfo;
03147    int x, format=0;     
03148 
03149    if(gH323Debug)
03150       ast_verbose("---   configure_local_rtp\n");
03151 
03152    if (p->rtp){
03153    ast_rtp_codec_setpref(p->rtp, &p->prefs);
03154    }
03155 
03156    /* figure out our local RTP port and tell the H.323 stack about it*/
03157    ast_rtp_get_us(p->rtp, &us);
03158 
03159    strncpy(mediaInfo.lMediaIP, ast_inet_ntoa(us.sin_addr), sizeof(mediaInfo.lMediaIP)-1);
03160    mediaInfo.lMediaPort = ntohs(us.sin_port);
03161    mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort +1;
03162    for(x=0; 0 != (format=ast_codec_pref_index(&p->prefs, x)); x++)
03163    {
03164       strcpy(mediaInfo.dir, "transmit");
03165       mediaInfo.cap = ooh323_convertAsteriskCapToH323Cap(format);
03166       ooAddMediaInfo(call, mediaInfo);
03167       strcpy(mediaInfo.dir, "receive");
03168       ooAddMediaInfo(call, mediaInfo);
03169       if(mediaInfo.cap == OO_G729A) {
03170          strcpy(mediaInfo.dir, "transmit");
03171          mediaInfo.cap = OO_G729;
03172          ooAddMediaInfo(call, mediaInfo);
03173          strcpy(mediaInfo.dir, "receive");
03174          ooAddMediaInfo(call, mediaInfo);
03175       }
03176    }
03177 
03178    if(gH323Debug)
03179       ast_verbose("+++   configure_local_rtp\n");
03180 
03181    return 1;
03182 }

int delete_peers ( void   ) 

Definition at line 2862 of file chan_ooh323.c.

References ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), free, ast_peer_list::lock, ooh323_peer::next, peerl, and ast_peer_list::peers.

Referenced by ooh323_do_reload(), and unload_module().

02863 {
02864    struct ooh323_peer *cur=NULL, *prev=NULL;
02865    ast_mutex_lock(&peerl.lock);
02866    cur = peerl.peers;
02867    while(cur)
02868    {
02869       prev = cur;
02870       cur = cur->next;
02871 
02872       ast_mutex_destroy(&prev->lock);
02873       if(prev->h323id)   free(prev->h323id);
02874       if(prev->email)    free(prev->email);
02875       if(prev->url)      free(prev->url);
02876       if(prev->e164)     free(prev->e164);
02877       free(prev);
02878 
02879       if(cur == peerl.peers) { break; }
02880    }
02881    peerl.peers = NULL;
02882    ast_mutex_unlock(&peerl.lock);
02883    return 0;
02884 }

int delete_users ( void   ) 

Definition at line 2886 of file chan_ooh323.c.

References ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), free, ast_user_list::lock, ooh323_user::next, userl, and ast_user_list::users.

02887 {
02888    struct ooh323_user *cur=NULL, *prev=NULL;
02889    ast_mutex_lock(&userl.lock);
02890    cur = userl.users;
02891    while(cur)
02892    {
02893       prev = cur;
02894       cur = cur->next;
02895       ast_mutex_destroy(&prev->lock);
02896       free(prev);
02897       if(cur == userl.users) { break; }
02898    }
02899    userl.users = NULL;
02900    ast_mutex_unlock(&userl.lock);
02901    return 0;
02902 }

static void* do_monitor ( void *  data  )  [static]

Definition at line 2680 of file chan_ooh323.c.

References ast_io_wait(), ast_mutex_lock(), ast_mutex_unlock(), ast_sched_runq(), ast_sched_wait(), ast_test_flag, ast_verbose(), H323_NEEDDESTROY, h323_reload_lock, h323_reloading, iflist, iflock, monlock, ooh323_pvt::next, ooh323_destroy(), ooh323_do_reload(), option_verbose, t, and VERBOSE_PREFIX_1.

Referenced by restart_monitor().

02681 {
02682    int res;
02683    int reloading;
02684    struct ooh323_pvt *h323 = NULL;
02685    time_t t;
02686 
02687    for(;;) {
02688       struct ooh323_pvt *h323_next;
02689       /* Check for a reload request */
02690       ast_mutex_lock(&h323_reload_lock);
02691       reloading = h323_reloading;
02692       h323_reloading = 0;
02693       ast_mutex_unlock(&h323_reload_lock);
02694       if (reloading) {
02695          if (option_verbose > 0) {
02696             ast_verbose(VERBOSE_PREFIX_1 "Reloading H.323\n");
02697          }
02698          ooh323_do_reload();
02699       }
02700 
02701       /* Check for interfaces needing to be killed */
02702       ast_mutex_lock(&iflock);
02703       time(&t);
02704       h323 = iflist;
02705       while(h323) {
02706          h323_next = h323->next;
02707 
02708          /*TODO: Need to add rtptimeout keepalive support */
02709          if(ast_test_flag(h323, H323_NEEDDESTROY)) {
02710             ooh323_destroy (h323);
02711          }
02712          h323 = h323_next;
02713       }
02714       ast_mutex_unlock(&iflock);
02715       pthread_testcancel();
02716 
02717       /* Wait for sched or io */
02718       res = ast_sched_wait(sched);
02719       if ((res < 0) || (res > 1000)) {
02720          res = 1000;
02721       }
02722       res = ast_io_wait(io, res);
02723       pthread_testcancel();
02724       ast_mutex_lock(&monlock);
02725       if (res >= 0) {
02726          ast_sched_runq(sched);
02727       }
02728       ast_mutex_unlock(&monlock);
02729    }
02730    /* Never reached */
02731    return NULL;
02732 }

static struct ooh323_pvt* find_call ( ooCallData *  call  )  [static, read]

Definition at line 589 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), ooh323_pvt::callToken, gH323Debug, iflist, iflock, and ooh323_pvt::next.

Referenced by close_rtp_connection(), onAlerting(), onCallCleared(), onCallEstablished(), onNewCallCreated(), ooh323_onReceivedDigit(), ooh323_set_read_format(), ooh323_set_write_format(), and setup_rtp_connection().

00590 {
00591    struct ooh323_pvt *p=NULL;
00592 
00593    if(gH323Debug)
00594       ast_verbose("---   find_call\n");
00595 
00596    p = iflist;
00597    ast_mutex_lock(&iflock);
00598 
00599    while(p)
00600    {
00601       if(p->callToken && !strcmp(p->callToken, call->callToken))
00602       {
00603          break;
00604       }
00605       p = p->next;
00606       
00607    }
00608    ast_mutex_unlock(&iflock);
00609 
00610    if(gH323Debug)
00611       ast_verbose("+++   find_call\n");
00612 
00613    return p;
00614 }

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

Definition at line 643 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), gH323Debug, ooh323_peer::ip, ast_peer_list::lock, ooh323_peer::next, peerl, ast_peer_list::peers, and ooh323_peer::port.

00644 {
00645    struct ooh323_peer *peer=NULL;  
00646 
00647    if(gH323Debug)
00648       ast_verbose("---   find_friend \"%s\"\n", name);
00649 
00650 
00651    peer = peerl.peers;
00652    ast_mutex_lock(&peerl.lock);
00653    while(peer)
00654    {
00655       if(gH323Debug) {
00656          ast_verbose("      comparing with \"%s\"\n", peer->ip);
00657       }
00658       if(!strcmp(peer->ip, name)) {
00659          if(port > 0 && peer->port == port) { break; }
00660          else if (port <= 0) { break; }
00661       }
00662       peer = peer->next;
00663    }
00664    ast_mutex_unlock(&peerl.lock);
00665 
00666    if(gH323Debug) {
00667       if(peer) {
00668          ast_verbose("      found matching friend\n");
00669       }
00670       ast_verbose("+++   find_friend \"%s\"\n", name);
00671    }
00672 
00673    return peer;      
00674 }

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

Definition at line 677 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), ooh323_peer::e164, gH323Debug, ooh323_peer::h323id, ooh323_peer::ip, ast_peer_list::lock, ooh323_peer::name, ooh323_peer::next, peerl, and ast_peer_list::peers.

00678 {
00679    struct ooh323_peer *peer=NULL;  
00680 
00681    if(gH323Debug)
00682       ast_verbose("---   find_peer \"%s\"\n", name);
00683 
00684 
00685    peer = peerl.peers;
00686    ast_mutex_lock(&peerl.lock);
00687    while(peer)
00688    {
00689       if(gH323Debug) {
00690          ast_verbose("      comparing with \"%s\"\n", peer->ip);
00691       }
00692       if(!strcasecmp(peer->name, name))
00693          break;
00694       if(peer->h323id && !strcasecmp(peer->h323id, name))
00695          break;
00696       if(peer->e164 && !strcasecmp(peer->e164, name))
00697          break;
00698       /*
00699       if(!strcmp(peer->ip, name)) {
00700          if(port > 0 && peer->port == port) { break; }
00701          else if (port <= 0) { break; }
00702       }
00703       */
00704       peer = peer->next;
00705    }
00706    ast_mutex_unlock(&peerl.lock);
00707 
00708    if(gH323Debug) {
00709       if(peer) {
00710          ast_verbose("      found matching peer\n");
00711       }
00712       ast_verbose("+++   find_peer \"%s\"\n", name);
00713    }
00714 
00715    return peer;      
00716 }

struct ooh323_user* find_user ( const char *  name,
const char *  ip 
) [read]

Definition at line 616 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), gH323Debug, ast_user_list::lock, ooh323_user::mIP, ooh323_user::mUseIP, ooh323_user::name, ooh323_user::next, userl, and ast_user_list::users.

00617 {
00618    struct ooh323_user *user=NULL;
00619 
00620    if(gH323Debug)
00621       ast_verbose("---   find_user \n");
00622 
00623    user = userl.users;
00624    ast_mutex_lock(&userl.lock);
00625    while(user)
00626    {
00627       if(ip && user->mUseIP && !strcmp(user->mIP, ip)) {
00628          break;
00629       }
00630       if(name && !strcmp(user->name, name)) {
00631          break;
00632       }
00633       user = user->next;
00634    }
00635    ast_mutex_unlock(&userl.lock);
00636 
00637    if(gH323Debug)
00638       ast_verbose("+++   find_user\n");
00639 
00640    return user;      
00641 }

static int load_module ( void   )  [static]

Definition at line 2514 of file chan_ooh323.c.

References ast_channel_register(), ast_cli_register(), ast_log(), ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_proto_register(), ooh323_peer::e164, ooh323_peer::email, gAliasList, gCallerID, gCapability, gDTMFMode, gFastStart, gGatekeeper, gIP, gIsGateway, gLogFile, gMediaWaitForConnect, gPort, gPrefs, gRasGkMode, gTunneling, ooh323_peer::h323id, io_context_create(), ast_peer_list::lock, ast_user_list::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ooh323_peer::next, onAlerting(), onCallCleared(), onCallEstablished(), onNewCallCreated(), ooh323_onReceivedDigit(), ooh323_onReceivedSetup(), ooh323c_set_capability(), ooh323c_start_stack_thread(), peerl, ast_peer_list::peers, reload_config(), restart_monitor(), sched_context_create(), type, ooh323_peer::url, userl, and ast_user_list::users.

02515 {
02516    int res;
02517    struct ooAliases * pNewAlias=NULL;
02518    struct ooh323_peer *peer=NULL;
02519    OOH225MsgCallbacks h225Callbacks = {0, 0, 0, 0};
02520 
02521    OOH323CALLBACKS h323Callbacks ={
02522      .onNewCallCreated = onNewCallCreated,
02523      .onAlerting = onAlerting,
02524      .onIncomingCall = NULL,
02525      .onOutgoingCall = NULL,
02526      .onCallEstablished = onCallEstablished,
02527      .onCallCleared = onCallCleared,
02528      .openLogicalChannels=NULL,
02529      .onReceivedDTMF = &ooh323_onReceivedDigit
02530    };
02531 
02532    ast_log(LOG_NOTICE, 
02533       "---------------------------------------------------------------------------------\n"
02534       "---  ******* IMPORTANT NOTE ***********\n"
02535       "---\n"
02536       "---  This module is currently unsupported.  Use it at your own risk.\n"
02537       "---\n"
02538       "---------------------------------------------------------------------------------\n");
02539 
02540    h225Callbacks.onReceivedSetup = &ooh323_onReceivedSetup;
02541 
02542    userl.users = NULL;
02543    ast_mutex_init(&userl.lock);
02544    peerl.peers = NULL;
02545    ast_mutex_init(&peerl.lock);
02546          
02547    /* ast_register_atexit(&ast_ooh323c_exit); */
02548 
02549    sched = sched_context_create();
02550    if (!sched) {
02551       ast_log(LOG_WARNING, "Unable to create schedule context\n");
02552    }
02553    io = io_context_create();
02554    if (!io) {
02555       ast_log(LOG_WARNING, "Unable to create I/O context\n");
02556    }
02557 
02558 
02559    res = reload_config();
02560    if (!res) {
02561       /* Make sure we can register our OOH323 channel type */
02562       if (ast_channel_register(&ooh323_tech)) {
02563          ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
02564          return 0;
02565       }
02566       ast_rtp_proto_register(&ooh323_rtp);
02567       ast_cli_register(&cli_show_users);
02568       ast_cli_register(&cli_show_user);
02569       ast_cli_register(&cli_show_peers);
02570       ast_cli_register(&cli_show_peer);
02571       ast_cli_register(&cli_show_config);
02572       ast_cli_register(&cli_debug);
02573       ast_cli_register(&cli_no_debug);
02574 
02575        /* fire up the H.323 Endpoint */       
02576       if(OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile))
02577       {
02578          ast_log(LOG_ERROR, "Failed to initialize OOH323 endpoint-"
02579                             "OOH323 Disabled\n");
02580          return 1;
02581       }
02582 
02583       if(gIsGateway)
02584          ooH323EpSetAsGateway();
02585 
02586       ooH323EpDisableAutoAnswer();
02587       ooH323EpSetH225MsgCallbacks(h225Callbacks);
02588       ooH323EpSetTraceLevel(OOTRCLVLDBGC);
02589       ooH323EpSetLocalAddress(gIP, gPort);
02590       ooH323EpSetCallerID(gCallerID);
02591  
02592       /* Set aliases if any */
02593       pNewAlias = gAliasList;
02594       while(pNewAlias)
02595       {
02596          switch(pNewAlias->type)
02597          {
02598          case T_H225AliasAddress_h323_ID:
02599             ooH323EpAddAliasH323ID(pNewAlias->value);
02600             break;
02601          case T_H225AliasAddress_dialedDigits:   
02602             ooH323EpAddAliasDialedDigits(pNewAlias->value);
02603             break;
02604          case T_H225AliasAddress_email_ID:   
02605             ooH323EpAddAliasEmailID(pNewAlias->value);
02606             break;
02607          default:
02608             ;
02609          }
02610          pNewAlias = pNewAlias->next;
02611       }
02612 
02613       ast_mutex_lock(&peerl.lock);
02614       peer = peerl.peers;
02615       while(peer)
02616       {
02617          if(peer->h323id) ooH323EpAddAliasH323ID(peer->h323id);
02618          if(peer->email)  ooH323EpAddAliasEmailID(peer->email);
02619          if(peer->e164)   ooH323EpAddAliasDialedDigits(peer->e164);
02620          if(peer->url)    ooH323EpAddAliasURLID(peer->url);
02621          peer = peer->next;
02622       }
02623       ast_mutex_unlock(&peerl.lock);
02624    
02625 
02626       if(gMediaWaitForConnect)
02627          ooH323EpEnableMediaWaitForConnect();
02628       else 
02629          ooH323EpDisableMediaWaitForConnect();
02630 
02631       /* Fast start and tunneling options */
02632       if(gFastStart)
02633          ooH323EpEnableFastStart();
02634       else
02635          ooH323EpDisableFastStart();
02636 
02637       if(!gTunneling)
02638          ooH323EpDisableH245Tunneling();
02639 
02640       /* Gatekeeper */
02641       if(gRasGkMode == RasUseSpecificGatekeeper)
02642          ooGkClientInit(gRasGkMode, gGatekeeper, 0);
02643       else if(gRasGkMode == RasDiscoverGatekeeper)
02644          ooGkClientInit(gRasGkMode, 0, 0);
02645 
02646       /* Register callbacks */
02647       ooH323EpSetH323Callbacks(h323Callbacks);
02648 
02649       /* Add endpoint capabilities */
02650       if(ooh323c_set_capability(&gPrefs, gCapability, gDTMFMode)<0) {
02651          ast_log(LOG_ERROR, "Capabilities failure for OOH323. OOH323 Disabled.\n");
02652          return 1;
02653       }
02654 
02655       /* Create H.323 listener */
02656       if(ooCreateH323Listener()!= OO_OK)
02657       {
02658          ast_log(LOG_ERROR, "OOH323 Listener Creation failure. "
02659                             "OOH323 DISABLED\n");
02660       
02661          ooH323EpDestroy();
02662          return 1;
02663       }
02664       
02665       if(ooh323c_start_stack_thread()  <0)
02666       {
02667          ast_log(LOG_ERROR, "Failed to start OOH323 stack thread. "
02668                             "OOH323 DISABLED\n");
02669          ooH323EpDestroy();
02670          return 1;
02671       }
02672       /* And start the monitor for the first time */
02673       restart_monitor();
02674    }
02675 
02676    return 0;
02677 }

int onAlerting ( ooCallData *  call  ) 

Definition at line 1161 of file chan_ooh323.c.

References AST_CONTROL_RINGING, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_queue_control(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, ast_test_flag, ast_verbose(), find_call(), gH323Debug, H323_OUTGOING, ast_channel::lock, ooh323_pvt::lock, LOG_ERROR, ooh323_new(), ooh323_pvt::owner, and ooh323_pvt::username.

Referenced by load_module().

01162 {
01163    struct ooh323_pvt *p=NULL;
01164    struct ast_channel *c = NULL;
01165 
01166    if(gH323Debug)
01167       ast_verbose("--- onAlerting %s\n", call->callToken);
01168 
01169    p = find_call(call);
01170 
01171    if(!p)
01172    {
01173       ast_log(LOG_ERROR, "No matching call found\n");
01174       return -1;
01175    }  
01176    ast_mutex_lock(&p->lock);
01177    if(!ast_test_flag(p, H323_OUTGOING))
01178    {
01179       c = ooh323_new(p, AST_STATE_RING, p->username);
01180       if(!c)
01181       {
01182          ast_mutex_unlock(&p->lock);
01183          ast_log(LOG_ERROR, "Could not create ast_channel\n");
01184          return -1;
01185       }
01186       ast_mutex_unlock(&p->lock);
01187    }
01188    else {
01189       if (!p->owner) {
01190          ast_mutex_unlock(&p->lock);
01191          ast_log(LOG_ERROR, "Channel has no owner\n");
01192          return 0;
01193       }
01194       c = p->owner;
01195       ast_mutex_unlock(&p->lock);
01196       ast_mutex_lock(&c->lock);
01197       ast_setstate(c, AST_STATE_RINGING);
01198       ast_mutex_unlock(&c->lock);
01199       ast_queue_control(c, AST_CONTROL_RINGING);
01200    }
01201    
01202 
01203    if(gH323Debug)
01204       ast_verbose("+++ onAlerting %s\n", call->callToken);
01205 
01206    return OO_OK;
01207 }

int onCallCleared ( ooCallData *  call  ) 

Definition at line 1507 of file chan_ooh323.c.

References ast_channel::_softhangup, ast_log(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_queue_hangup(), ast_set_flag, AST_SOFTHANGUP_DEV, ast_test_flag, ast_verbose(), find_call(), gH323Debug, H323_ALREADYGONE, H323_NEEDDESTROY, ast_channel::hangupcause, ast_channel::lock, ooh323_pvt::lock, LOG_DEBUG, ooh323_convert_hangupcause_h323ToAsterisk(), and ooh323_pvt::owner.

Referenced by load_module().

01508 {
01509    struct ooh323_pvt *p = NULL;
01510    int ownerLock = 0;
01511 
01512    if(gH323Debug)
01513       ast_verbose("---   onCallCleared %s \n", call->callToken);
01514 
01515    p = find_call(call); 
01516    if (!p) { return 0; }
01517    ast_mutex_lock(&p->lock);
01518   
01519    while(p->owner) {
01520       if(ast_mutex_trylock(&p->owner->lock)) {
01521          ooTrace(OOTRCLVLINFO, "Failed to grab lock, trying again\n");
01522          ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
01523          ast_mutex_unlock(&p->lock);
01524          usleep(1);
01525          ast_mutex_lock(&p->lock);
01526       }
01527       else {
01528          ownerLock = 1; break;
01529       }
01530    }
01531 
01532    if(ownerLock) {
01533       if(!ast_test_flag(p, H323_ALREADYGONE)) { 
01534 
01535          /* NOTE: Channel is not detached yet */
01536          ast_set_flag(p, H323_ALREADYGONE);
01537          p->owner->hangupcause = 
01538             ooh323_convert_hangupcause_h323ToAsterisk(call->callEndReason);
01539          p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
01540          ast_mutex_unlock(&p->owner->lock);
01541          ast_queue_hangup(p->owner);
01542          ast_mutex_unlock(&p->lock);
01543          return OO_OK;
01544       }
01545       ast_mutex_unlock(&p->owner->lock);
01546    }
01547    ast_set_flag(p, H323_NEEDDESTROY);
01548    ast_mutex_unlock(&p->lock);
01549 
01550    if(gH323Debug)
01551       ast_verbose("+++   onCallCleared\n");
01552 
01553    return OO_OK;
01554 }

int onCallEstablished ( ooCallData *  call  ) 

Definition at line 1463 of file chan_ooh323.c.

References ast_channel::_state, AST_CONTROL_ANSWER, ast_log(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_queue_control(), ast_setstate(), AST_STATE_UP, ast_test_flag, ast_verbose(), find_call(), gH323Debug, H323_OUTGOING, ast_channel::lock, ooh323_pvt::lock, LOG_DEBUG, LOG_ERROR, and ooh323_pvt::owner.

Referenced by load_module().

01464 {
01465   struct ooh323_pvt *p = NULL;
01466 
01467    if(gH323Debug)
01468       ast_verbose("---   onCallEstablished %s\n", call->callToken);
01469 
01470    p = find_call(call);
01471    if(!p) {
01472       ast_log(LOG_ERROR, "Failed to find a matching call.\n");
01473       return -1;
01474    }
01475    ast_mutex_lock(&p->lock);
01476    if (!p->owner) {
01477       ast_mutex_unlock(&p->lock);
01478       ast_log(LOG_ERROR, "Channel has no owner\n");
01479       return -1;
01480    }
01481    
01482    while(ast_mutex_trylock(&p->owner->lock))
01483    {
01484       ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
01485       ast_mutex_unlock(&p->lock);
01486       usleep(1);
01487       ast_mutex_lock(&p->lock);
01488    }    
01489    if(p->owner->_state != AST_STATE_UP)
01490    {
01491       ast_setstate(p->owner, AST_STATE_UP);
01492    }
01493    ast_mutex_unlock(&p->owner->lock);
01494    if(ast_test_flag(p, H323_OUTGOING)) {
01495       struct ast_channel* c = p->owner;
01496       ast_mutex_unlock(&p->lock);
01497       ast_queue_control(c, AST_CONTROL_ANSWER);
01498    }
01499    else { ast_mutex_unlock(&p->lock); }
01500 
01501    if(gH323Debug)
01502       ast_verbose("+++   onCallEstablished %s\n", call->callToken);
01503 
01504   return OO_OK;
01505 }

int onNewCallCreated ( ooCallData *  call  ) 

Definition at line 1374 of file chan_ooh323.c.

References ast_codec_pref_string(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), ast_verbose(), ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_h323id, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, ooh323_pvt::capability, configure_local_rtp(), ooh323_pvt::dtmfmode, ooh323_pvt::exten, find_call(), gH323Debug, ooh323_pvt::lock, LOG_ERROR, ooh323c_set_capability_for_call(), ooh323_pvt::prefs, and ooh323_pvt::username.

Referenced by load_module().

01375 {
01376    struct ooh323_pvt *p = NULL;
01377    int i=0;
01378 
01379    if(gH323Debug)
01380       ast_verbose("---   onNewCallCreated %s\n", call->callToken);
01381 
01382    if(!strcmp(call->callType, "outgoing"))
01383    {
01384       p = find_call(call);
01385       if(!p)
01386       {
01387          ast_log(LOG_ERROR, "No matching call found for outgoing call\n");
01388          return -1;
01389       }
01390       ast_mutex_lock(&p->lock);
01391       if(p->callerid_name){
01392          ooCallSetCallerId(call, p->callerid_name);
01393       }
01394       if(p->callerid_num)
01395       {
01396          i=0;
01397          while(*(p->callerid_num+i) != '\0')
01398          {
01399             if(!isdigit(*(p->callerid_num+i))) { break; }
01400             i++;
01401          }
01402          if(*(p->callerid_num+i) == '\0')
01403             ooCallSetCallingPartyNumber(call, p->callerid_num);
01404          else{
01405             if(!p->callerid_name)
01406                ooCallSetCallerId(call, p->callerid_num);
01407          }
01408       }
01409       
01410       if(!ast_strlen_zero(p->caller_h323id))
01411          ooCallAddAliasH323ID(call, p->caller_h323id);
01412 
01413       if(!ast_strlen_zero(p->caller_dialedDigits)){
01414          if(gH323Debug) {
01415             ast_verbose("Setting dialed digits %s\n", p->caller_dialedDigits);
01416          }
01417          ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
01418       }
01419       else if(p->callerid_num) {
01420          if(ooIsDailedDigit(p->callerid_num)) {
01421             if(gH323Debug) {
01422                ast_verbose("setting callid number %s\n", p->callerid_num);
01423             }
01424             ooCallAddAliasDialedDigits(call, p->callerid_num);
01425          }
01426          else if(ast_strlen_zero(p->caller_h323id)) {
01427             ooCallAddAliasH323ID(call, p->callerid_num);
01428          }
01429       }
01430   
01431 
01432       if(!ast_strlen_zero(p->exten))  
01433       {
01434          if(ooIsDailedDigit(p->exten)) {
01435             ooCallSetCalledPartyNumber(call, p->exten);
01436             ooCallAddRemoteAliasDialedDigits(call, p->exten);
01437          }
01438          else {
01439            ooCallAddRemoteAliasH323ID(call, p->exten);
01440          }
01441       }
01442 
01443       if(gH323Debug)
01444       {
01445          char prefsBuf[256];
01446          ast_codec_pref_string(&p->prefs, prefsBuf, 256);
01447          ast_verbose(" Outgoing call %s(%s) - Codec prefs - %s\n", 
01448                     p->username?p->username:"NULL", call->callToken, prefsBuf);
01449       }
01450 
01451       ooh323c_set_capability_for_call(call, &p->prefs, p->capability, 
01452                                      p->dtmfmode);
01453    
01454       configure_local_rtp(p, call);
01455       ast_mutex_unlock(&p->lock);
01456    }
01457    if(gH323Debug)
01458       ast_verbose("+++   onNewCallCreated %s\n", call->callToken);
01459 
01460    return OO_OK;
01461 }

static struct ooh323_pvt* ooh323_alloc ( int  callref,
char *  callToken 
) [static, read]

Definition at line 360 of file chan_ooh323.c.

References ooh323_pvt::accountcode, ooh323_pvt::amaflags, ast_log(), ast_mutex_destroy(), ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_new_with_bindaddr(), ast_rtp_settos(), ast_verbose(), ooh323_pvt::call_reference, 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::callerid_name, ooh323_pvt::callerid_num, ooh323_pvt::callToken, ooh323_pvt::capability, ooh323_pvt::context, ooh323_pvt::dtmfmode, errno, ooh323_pvt::exten, ooh323_pvt::flags, free, gAccountcode, gAMAFLAGS, gCapability, gContext, gDTMFMode, gH323Debug, gIP, gPrefs, gRasGkMode, gTOS, H323_DISABLEGK, ooh323_pvt::host, iflist, iflock, ooh323_pvt::lock, LOG_ERROR, LOG_WARNING, malloc, ooh323_pvt::next, ooh323_pvt::owner, ooh323_pvt::port, ooh323_pvt::prefs, ooh323_pvt::rtp, strdup, ooh323_pvt::vad, and ooh323_pvt::vrtp.

Referenced by ooh323_onReceivedSetup(), and ooh323_request().

00361 {
00362    struct ooh323_pvt *pvt = NULL;
00363    struct in_addr ipAddr;
00364    if(gH323Debug)
00365       ast_verbose("---   ooh323_alloc\n");
00366 
00367    pvt = (struct ooh323_pvt*) malloc(sizeof(struct ooh323_pvt));
00368    if(!pvt)
00369    {
00370       ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
00371       return NULL;
00372    }
00373 
00374    memset(pvt, 0, sizeof(struct ooh323_pvt));
00375    ast_mutex_init(&pvt->lock);
00376    ast_mutex_lock(&pvt->lock);
00377 
00378 
00379    pvt->caller_h323id[0]='\0';
00380    pvt->caller_dialedDigits[0]='\0';
00381    pvt->caller_email[0]='\0';
00382    pvt->caller_url[0]='\0';
00383    pvt->vrtp = NULL;   
00384    pvt->callee_h323id[0]='\0';
00385    pvt->callee_dialedDigits[0]='\0';
00386    pvt->callee_email[0] = '\0';
00387    pvt->callee_url[0] = '\0';
00388 
00389    pvt->host = NULL;
00390    pvt->callToken = NULL;
00391    pvt->port = 0;
00392    pvt->vad = NULL;
00393    pvt->next = NULL;
00394    pvt->owner = NULL;
00395    pvt->callerid_name = NULL;
00396    pvt->callerid_num = NULL;
00397    pvt->flags = 0;
00398    if(!inet_aton(gIP, &ipAddr))
00399    {
00400       ast_log(LOG_ERROR, "Invalid OOH323 driver ip address\n");
00401       ast_mutex_unlock(&pvt->lock);
00402       ast_mutex_destroy(&pvt->lock);
00403       free(pvt);
00404       return NULL;
00405    }
00406    
00407 
00408    pvt->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, ipAddr);
00409 
00410    if (!pvt->rtp) 
00411    {
00412       ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", 
00413               strerror(errno));
00414       ast_mutex_unlock(&pvt->lock);
00415       ast_mutex_destroy(&pvt->lock);
00416       free(pvt);
00417       return NULL;
00418    }
00419  
00420    ast_rtp_settos(pvt->rtp, gTOS);
00421 
00422 
00423    pvt->call_reference = callref;
00424    if(callToken)
00425       pvt->callToken = strdup(callToken);
00426 
00427    /* whether to use gk for this call */
00428    if(gRasGkMode == RasNoGatekeeper)
00429       OO_SETFLAG(pvt->flags, H323_DISABLEGK);
00430 
00431    pvt->dtmfmode = gDTMFMode;
00432    strncpy(pvt->context, gContext, sizeof(pvt->context)-1);
00433    pvt->exten[0]='\0';
00434    strncpy(pvt->accountcode, gAccountcode, sizeof(pvt->accountcode)-1);
00435    pvt->amaflags = gAMAFLAGS;
00436    pvt->capability = gCapability;
00437    memcpy(&pvt->prefs, &gPrefs, sizeof(struct ast_codec_pref));
00438 
00439 
00440   ast_mutex_unlock(&pvt->lock); 
00441   /* Add to interface list */
00442   ast_mutex_lock(&iflock);
00443   pvt->next = iflist;
00444   iflist = pvt;
00445   ast_mutex_unlock(&iflock);
00446 
00447   if(gH323Debug)
00448     ast_verbose("+++   ooh323_alloc\n");
00449 
00450   return pvt;
00451 }

static int ooh323_answer ( struct ast_channel *  ast  )  [static]

Definition at line 926 of file chan_ooh323.c.

References ast_channel::_state, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_setstate(), AST_STATE_UP, ast_verbose(), ooh323_pvt::callToken, gH323Debug, ast_channel::lock, ooh323_pvt::lock, LOG_DEBUG, ast_channel::name, ooh323c_cmd_lock, option_debug, and ast_channel::tech_pvt.

00927 {
00928    struct ooh323_pvt *p = ast->tech_pvt;
00929 
00930    if(gH323Debug)
00931       ast_verbose("--- ooh323_answer\n");
00932 
00933    ast_mutex_lock(&p->lock);
00934    if(ast->_state != AST_STATE_UP)
00935    {
00936       ast_mutex_lock(&ast->lock);
00937       ast_setstate(ast, AST_STATE_UP);
00938       if (option_debug)
00939          ast_log(LOG_DEBUG, "ooh323_answer(%s)\n", ast->name);
00940       ast_mutex_unlock(&ast->lock);
00941       ast_mutex_lock(&ooh323c_cmd_lock);
00942       ooAnswerCall(p->callToken);
00943       ast_mutex_unlock(&ooh323c_cmd_lock);
00944    }
00945    ast_mutex_unlock(&p->lock);
00946 
00947    if(gH323Debug)
00948       ast_verbose("+++ ooh323_answer\n");
00949 
00950   return 0;
00951 }

static int ooh323_call ( struct ast_channel *  ast,
char *  dest,
int  timeout 
) [static]

Definition at line 773 of file chan_ooh323.c.

References ast_channel::_state, ast_log(), AST_MAX_EXTENSION, ast_mutex_lock(), ast_mutex_unlock(), ast_set_flag, AST_STATE_DOWN, AST_STATE_RESERVED, ast_verbose(), ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_email, ooh323_pvt::caller_h323id, ooh323_pvt::caller_url, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, ooh323_pvt::callToken, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ooh323_pvt::flags, free, gCallerID, gH323Debug, H323_DISABLEGK, H323_OUTGOING, ooh323_pvt::host, ooh323_pvt::lock, LOG_ERROR, LOG_WARNING, malloc, ast_channel::name, ooh323c_cmd_lock, pbx_builtin_getvar_helper(), ooh323_pvt::port, strdup, ast_channel::tech_pvt, and TRUE.

00774 {
00775    struct ooh323_pvt *p = ast->tech_pvt;
00776    char destination[256];
00777    int res=0;
00778    const char *val=NULL;
00779    ooCallOptions opts = {
00780       .fastStart = TRUE,
00781       .tunneling = TRUE,
00782       .disableGk = TRUE,
00783       .callMode = OO_CALLMODE_AUDIOCALL
00784    };
00785    if(gH323Debug)
00786       ast_verbose("---   ooh323_call- %s\n", dest);
00787 
00788 
00789    if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) 
00790    {
00791       ast_log(LOG_WARNING, "ooh323_call called on %s, neither down nor "
00792                            "reserved\n", ast->name);
00793       return -1;
00794    }
00795    ast_mutex_lock(&p->lock);
00796    ast_set_flag(p, H323_OUTGOING);
00797    if (ast->cid.cid_num) {
00798      if(p->callerid_num)   free(p->callerid_num);
00799       p->callerid_num = strdup(ast->cid.cid_num);
00800    }
00801 
00802    if(ast->cid.cid_name) {
00803       if(p->callerid_name)   free(p->callerid_name);
00804       p->callerid_name = strdup(ast->cid.cid_name);
00805    }
00806    else{
00807       ast->cid.cid_name = strdup(gCallerID);
00808       if(p->callerid_name)   free(p->callerid_name);
00809       p->callerid_name = strdup(ast->cid.cid_name);
00810    }
00811 
00812    /* Retrieve vars */
00813 
00814 
00815    val = pbx_builtin_getvar_helper(ast, "CALLER_H323ID");
00816    if(val){
00817      strncpy(p->caller_h323id, val, sizeof(p->caller_h323id)-1);
00818    }
00819    
00820    val = pbx_builtin_getvar_helper(ast, "CALLER_H323DIALEDDIGITS");
00821    if(val){
00822       strncpy(p->caller_dialedDigits, val, sizeof(p->caller_dialedDigits)-1);
00823       if(!p->callerid_num)   p->callerid_num = strdup(val);
00824      
00825    }
00826 
00827    val = pbx_builtin_getvar_helper(ast, "CALLER_H323EMAIL");
00828    if(val)
00829      strncpy(p->caller_email, val, sizeof(p->caller_email)-1);
00830    
00831    val = pbx_builtin_getvar_helper(ast, "CALLER_H323URL");
00832    if(val)
00833      strncpy(p->caller_url, val, sizeof(p->caller_url)-1);  
00834 
00835 
00836    p->callToken = (char*)malloc(AST_MAX_EXTENSION);
00837    if(!p->callToken)
00838    {
00839       ast_mutex_unlock(&p->lock);
00840       ast_log(LOG_ERROR, "Failed to allocate memory for callToken\n");
00841       return -1; /* TODO: need to clean/hangup?? */
00842    }      
00843 
00844    if(p->host && p->port != 0)
00845       sprintf(destination, "%s:%d", p->host, p->port);
00846    else if(p->host)
00847       sprintf(destination, "%s", p->host);
00848    else
00849      strncpy(destination, dest, sizeof(destination)-1);
00850 
00851    destination[sizeof(destination)-1]='\0';
00852 
00853    ast_mutex_lock(&ooh323c_cmd_lock);
00854    if(OO_TESTFLAG(p->flags, H323_DISABLEGK))
00855       res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, &opts);
00856    else
00857       res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, NULL);
00858    ast_mutex_unlock(&ooh323c_cmd_lock);
00859 
00860    ast_mutex_unlock(&p->lock);
00861    if(res != OO_OK)
00862    {
00863       ast_log(LOG_ERROR,"Failed to make call\n");
00864       return -1; /* ToDO: cleanup */
00865    }
00866    if(gH323Debug)
00867       ast_verbose("+++   ooh323_call\n");
00868 
00869   return 0;
00870 }

int ooh323_convert_hangupcause_asteriskToH323 ( int  cause  ) 

Definition at line 3325 of file chan_ooh323.c.

References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_BUSY, AST_CAUSE_CALL_REJECTED, AST_CAUSE_CONGESTION, AST_CAUSE_FAILURE, AST_CAUSE_NO_ANSWER, AST_CAUSE_NORMAL, and AST_CAUSE_UNALLOCATED.

Referenced by ooh323_hangup().

03326 {
03327    switch(cause)
03328    {
03329       case AST_CAUSE_CALL_REJECTED:
03330          return OO_REASON_REMOTE_REJECTED;
03331       case AST_CAUSE_UNALLOCATED:
03332          return OO_REASON_NOUSER;
03333       case AST_CAUSE_BUSY:
03334          return OO_REASON_REMOTE_BUSY;
03335       case AST_CAUSE_BEARERCAPABILITY_NOTAVAIL:
03336          return OO_REASON_NOCOMMON_CAPABILITIES;
03337       case AST_CAUSE_CONGESTION:
03338          return OO_REASON_REMOTE_BUSY;
03339       case AST_CAUSE_NO_ANSWER:
03340          return OO_REASON_REMOTE_NOANSWER;
03341       case AST_CAUSE_NORMAL:
03342          return OO_REASON_REMOTE_CLEARED;
03343       case AST_CAUSE_FAILURE:
03344       default:
03345          return OO_REASON_UNKNOWN;
03346    }
03347 
03348    return 0;
03349 
03350 
03351 }

int ooh323_convert_hangupcause_h323ToAsterisk ( int  cause  ) 

Definition at line 3353 of file chan_ooh323.c.

References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_BUSY, AST_CAUSE_CALL_REJECTED, AST_CAUSE_CONGESTION, AST_CAUSE_FAILURE, AST_CAUSE_NO_ANSWER, AST_CAUSE_NORMAL, and AST_CAUSE_UNALLOCATED.

Referenced by onCallCleared().

03354 {
03355    switch(cause) {
03356       case OO_REASON_REMOTE_REJECTED:
03357          return AST_CAUSE_CALL_REJECTED;
03358       case OO_REASON_NOUSER: 
03359          return AST_CAUSE_UNALLOCATED;
03360       case OO_REASON_REMOTE_BUSY:
03361       case OO_REASON_LOCAL_BUSY:
03362          return AST_CAUSE_BUSY;
03363       case OO_REASON_NOCOMMON_CAPABILITIES:   /* No codecs approved */
03364          return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
03365       case OO_REASON_REMOTE_CONGESTED:
03366       case OO_REASON_LOCAL_CONGESTED:
03367          return AST_CAUSE_CONGESTION;
03368       case OO_REASON_REMOTE_NOANSWER:
03369          return AST_CAUSE_NO_ANSWER;
03370       case OO_REASON_UNKNOWN: 
03371       case OO_REASON_INVALIDMESSAGE:
03372       case OO_REASON_TRANSPORTFAILURE:
03373          return AST_CAUSE_FAILURE;
03374       case OO_REASON_REMOTE_CLEARED:
03375          return AST_CAUSE_NORMAL;
03376       default:
03377          return AST_CAUSE_NORMAL;
03378    }
03379    /* Never reached */
03380    return 0;
03381 }

int ooh323_convertAsteriskCapToH323Cap ( int  cap  ) 

Definition at line 3089 of file chan_ooh323.c.

References AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H263, AST_FORMAT_ULAW, ast_getformatname_multiple(), ast_log(), and LOG_NOTICE.

Referenced by configure_local_rtp(), ooh323_set_rtp_peer(), and ooh323_update_capPrefsOrderForCall().

03090 {
03091    char formats[512];
03092    switch (cap) {
03093       case AST_FORMAT_ULAW:
03094          return OO_G711ULAW64K;
03095       case AST_FORMAT_ALAW:
03096          return OO_G711ALAW64K;
03097       case AST_FORMAT_GSM:
03098          return OO_GSMFULLRATE;
03099       case AST_FORMAT_G729A:
03100          return OO_G729A;
03101       case AST_FORMAT_G723_1:
03102          return OO_G7231;
03103       case AST_FORMAT_H263:
03104          return OO_H263VIDEO;
03105       default:
03106          ast_log(LOG_NOTICE, "Don't know how to deal with mode %s\n", 
03107                         ast_getformatname_multiple(formats,512,cap));
03108          return -1;
03109    }
03110 }

void ooh323_delete_peer ( struct ooh323_peer *  peer  ) 

Definition at line 1591 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), ooh323_peer::e164, ooh323_peer::email, free, gH323Debug, ooh323_peer::h323id, ast_peer_list::lock, ooh323_peer::next, peerl, ast_peer_list::peers, and ooh323_peer::url.

Referenced by build_peer().

01592 {
01593    struct ooh323_peer *prev=NULL, *cur=NULL;
01594 
01595    if(gH323Debug)
01596       ast_verbose("---   ooh323_delete_peer\n");
01597 
01598    if(peer)
01599    {   
01600       cur = peerl.peers;
01601       ast_mutex_lock(&peerl.lock);
01602       while(cur)
01603       {
01604          if(cur==peer) break;
01605          prev = cur;
01606          cur = cur->next;
01607       }
01608 
01609       if(cur)
01610       {
01611          if(prev)
01612             prev->next = cur->next;
01613          else
01614             peerl.peers = cur->next;
01615       }
01616       ast_mutex_unlock(&peerl.lock);
01617 
01618       if(peer->h323id)   free(peer->h323id);
01619       if(peer->email)    free(peer->email);
01620       if(peer->url)      free(peer->url);
01621       if(peer->e164)     free(peer->e164);
01622 
01623       free(peer);
01624    }  
01625 
01626    if(gH323Debug)
01627       ast_verbose("+++   ooh323_delete_peer\n");
01628 
01629 }

static void ooh323_delete_user ( struct ooh323_user *  user  )  [static]

Definition at line 1556 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), free, gH323Debug, ast_user_list::lock, ooh323_user::next, userl, and ast_user_list::users.

01557 {
01558    struct ooh323_user *prev=NULL, *cur=NULL;
01559 
01560    if(gH323Debug)
01561       ast_verbose("---   ooh323_delete_user\n");
01562 
01563    if(user)
01564    {   
01565       cur = userl.users;
01566       ast_mutex_lock(&userl.lock);
01567       while(cur)
01568       {
01569          if(cur==user) break;
01570          prev = cur;
01571          cur = cur->next;
01572       }
01573 
01574       if(cur)
01575       {
01576          if(prev)
01577             prev->next = cur->next;
01578          else
01579             userl.users = cur->next;
01580       }
01581       ast_mutex_unlock(&userl.lock);
01582 
01583       free(user);
01584    }  
01585 
01586    if(gH323Debug)
01587       ast_verbose("+++   ooh323_delete_user\n");
01588 
01589 }

int ooh323_destroy ( struct ooh323_pvt *  p  ) 

Definition at line 2770 of file chan_ooh323.c.

References ast_dsp_free(), ast_log(), ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_rtp_destroy(), ast_verbose(), free, gH323Debug, iflist, LOG_DEBUG, dahdi_pvt::next, ooh323_pvt::next, and ooh323_pvt::username.

Referenced by do_monitor(), ooh323_request(), and unload_module().

02771 {
02772    /* NOTE: Assumes iflock already acquired */
02773    struct ooh323_pvt *prev=NULL,*cur = NULL;
02774 
02775 
02776    if(gH323Debug)
02777    {
02778       ast_verbose("---   ooh323_destroy \n");
02779 
02780       if(p)
02781          ast_verbose(" Destroying %s\n", p->username);
02782    }
02783 
02784    cur = iflist;
02785    while(cur)
02786    {
02787       if(cur == p) { break; }
02788       prev = cur;
02789       cur = cur->next;
02790    }
02791 
02792    if(cur)
02793    {
02794       ast_mutex_lock(&cur->lock);
02795       if(prev)
02796          prev->next = cur->next;
02797       else
02798          iflist = cur->next;
02799 
02800       if(cur->callToken) {
02801          free(cur->callToken);
02802          cur->callToken = 0;
02803       }
02804 
02805       if(cur->username) {
02806          free(cur->username);
02807          cur->username = 0;
02808       }
02809 
02810       if(cur->host) {
02811          free(cur->host);
02812          cur->host = 0;
02813       }
02814 
02815       if(cur->callerid_name) {
02816          free(cur->callerid_name);
02817          cur->callerid_name = 0;
02818       }
02819       
02820       if(cur->callerid_num) {
02821          free(cur->callerid_num);
02822          cur->callerid_num = 0;
02823       }
02824 
02825 
02826       if (cur->rtp) {
02827          ast_rtp_destroy(cur->rtp);
02828          cur->rtp = 0;
02829       }
02830    
02831       /* Unlink us from the owner if we have one */
02832       if (cur->owner) {
02833          while(ast_mutex_trylock(&cur->owner->lock))
02834          {
02835             ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
02836             ast_mutex_unlock(&cur->lock);
02837             usleep(1);
02838             ast_mutex_lock(&cur->lock);
02839          }           
02840          ast_log(LOG_DEBUG, "Detaching from %s\n", cur->owner->name);
02841          cur->owner->tech_pvt = NULL;
02842          ast_mutex_unlock(&cur->owner->lock);
02843          cur->owner = NULL;
02844       }
02845   
02846       if (cur->vad) {
02847          ast_dsp_free(cur->vad);
02848          cur->vad = NULL;
02849       }
02850       ast_mutex_unlock(&cur->lock);
02851       ast_mutex_destroy(&cur->lock);
02852 
02853       free(cur);
02854    }
02855 
02856    if(gH323Debug)
02857       ast_verbose("+++   ooh323_destroy\n");
02858 
02859    return 0;
02860 }

static int ooh323_digit_begin ( struct ast_channel *  ast,
char  digit 
) [static]

Definition at line 718 of file chan_ooh323.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_senddigit_begin(), ast_verbose(), ooh323_pvt::callToken, ooh323_pvt::dtmfmode, gH323Debug, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_pvt::lock, LOG_ERROR, ooh323c_cmd_lock, ooh323_pvt::rtp, and ast_channel::tech_pvt.

00719 {
00720    char dtmf[2];
00721    struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
00722    
00723    if(gH323Debug)
00724       ast_verbose("---   ooh323_digit_begin\n");
00725 
00726    if(!p){
00727       ast_log(LOG_ERROR, "No private structure for call\n");
00728       return -1;
00729    }
00730    ast_mutex_lock(&p->lock);
00731    if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
00732       ast_rtp_senddigit_begin(p->rtp, digit);
00733    }
00734    else if (((p->dtmfmode & H323_DTMF_Q931) ||
00735                    (p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) ||
00736                    (p->dtmfmode & H323_DTMF_H245SIGNAL))){
00737       dtmf[0]= digit;
00738       dtmf[1]='\0';
00739       ast_mutex_lock(&ooh323c_cmd_lock);
00740       ooSendDTMFDigit(p->callToken, dtmf);
00741       ast_mutex_unlock(&ooh323c_cmd_lock);
00742    }
00743    ast_mutex_unlock(&p->lock);
00744    if(gH323Debug)
00745       ast_verbose("+++   ooh323_digit_begin\n");
00746 
00747    return 0;
00748 }

static int ooh323_digit_end ( struct ast_channel *  ast,
char  digit,
unsigned int  duration 
) [static]

Definition at line 750 of file chan_ooh323.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_senddigit_end(), ast_verbose(), ooh323_pvt::dtmfmode, gH323Debug, H323_DTMF_RFC2833, ooh323_pvt::lock, LOG_ERROR, ooh323_pvt::rtp, and ast_channel::tech_pvt.

00751 {
00752    struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
00753 
00754    if(gH323Debug)
00755       ast_verbose("---   ooh323_digit_end\n");
00756 
00757    if(!p){
00758       ast_log(LOG_ERROR, "No private structure for call\n");
00759       return -1;
00760    }
00761    ast_mutex_lock(&p->lock);
00762    if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) 
00763       ast_rtp_senddigit_end(p->rtp, digit);
00764 
00765    ast_mutex_unlock(&p->lock);
00766    if(gH323Debug)
00767       ast_verbose("+++   ooh323_digit_end\n");
00768 
00769    return 0;
00770 }

static int ooh323_do_debug ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2358 of file chan_ooh323.c.

References ast_cli(), gH323Debug, RESULT_SHOWUSAGE, RESULT_SUCCESS, and TRUE.

02359 {
02360    if (argc != 2)
02361       return RESULT_SHOWUSAGE;
02362 
02363    gH323Debug = TRUE;
02364    ast_cli(fd, "OOH323 Debugging Enabled\n");
02365    return RESULT_SUCCESS;
02366 }

static int ooh323_do_reload ( void   )  [static]

Definition at line 1831 of file chan_ooh323.c.

References ast_verbose(), delete_peers(), delete_users(), gH323Debug, and reload_config().

Referenced by do_monitor().

01832 {
01833    if(gH323Debug) {
01834       ast_verbose("---   ooh323_do_reload\n");
01835    }
01836 
01837    delete_users();
01838    delete_peers();
01839    reload_config();
01840 
01841    if(gH323Debug) {
01842       ast_verbose("+++   ooh323_do_reload\n");
01843    }
01844 
01845    return 0;
01846 }

static int ooh323_fixup ( struct ast_channel *  oldchan,
struct ast_channel *  newchan 
) [static]

Definition at line 1065 of file chan_ooh323.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), gH323Debug, ooh323_pvt::lock, LOG_WARNING, ooh323_pvt::owner, and ast_channel::tech_pvt.

01066 {
01067    struct ooh323_pvt *p = newchan->tech_pvt;
01068 
01069    if(gH323Debug)
01070       ast_verbose("--- ooh323c ooh323_fixup\n");
01071 
01072    ast_mutex_lock(&p->lock);
01073    if (p->owner != oldchan) {
01074       ast_log(LOG_WARNING, "Old channel wasn't %p but was %p\n", oldchan, p->owner);
01075       ast_mutex_unlock(&p->lock);
01076       return -1;
01077    }
01078 
01079    if (p->owner == oldchan) {
01080       p->owner = newchan;
01081    }
01082    else {
01083       p->owner = oldchan;
01084    }
01085 
01086    ast_mutex_unlock(&p->lock);
01087 
01088    if(gH323Debug)
01089       ast_verbose("+++ ooh323c ooh323_fixup \n");
01090 
01091    return 0;
01092 }

static enum ast_rtp_get_result ooh323_get_rtp_peer ( struct ast_channel *  chan,
struct ast_rtp **  rtp 
) [static]

Definition at line 3035 of file chan_ooh323.c.

References AST_RTP_GET_FAILED, AST_RTP_TRY_NATIVE, AST_RTP_TRY_PARTIAL, ooh323_pvt::rtp, and ast_channel::tech_pvt.

03036 {
03037    struct ooh323_pvt *p = NULL;
03038    enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
03039 
03040    if (!(p = (struct ooh323_pvt *) chan->tech_pvt))
03041    return AST_RTP_GET_FAILED;
03042 
03043    *rtp = p->rtp;
03044 
03045    if (!(p->rtp)) {
03046    return AST_RTP_GET_FAILED;
03047    }
03048    res = AST_RTP_TRY_NATIVE;
03049 
03050    return res;
03051 }

static enum ast_rtp_get_result ooh323_get_vrtp_peer ( struct ast_channel *  chan,
struct ast_rtp **  rtp 
) [static]

Definition at line 3053 of file chan_ooh323.c.

References AST_RTP_GET_FAILED, AST_RTP_TRY_NATIVE, AST_RTP_TRY_PARTIAL, ooh323_pvt::rtp, ast_channel::tech_pvt, and ooh323_pvt::vrtp.

03054 {
03055    struct ooh323_pvt *p = NULL;
03056    enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
03057 
03058    if (!(p = (struct ooh323_pvt *) chan->tech_pvt))
03059         return AST_RTP_GET_FAILED;
03060 
03061    *rtp = p->vrtp;
03062 
03063    if (!(p->rtp)) {
03064         return AST_RTP_GET_FAILED;
03065    }
03066    res = AST_RTP_TRY_NATIVE;
03067 
03068    return res;
03069 }

static int ooh323_hangup ( struct ast_channel *  ast  )  [static]

Definition at line 872 of file chan_ooh323.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_set_flag, ast_test_flag, ast_update_use_count(), ast_verbose(), ooh323_pvt::callToken, gH323Debug, H323_ALREADYGONE, H323_NEEDDESTROY, ast_channel::hangupcause, ooh323_pvt::lock, LOG_ERROR, ooh323_convert_hangupcause_asteriskToH323(), ooh323c_cmd_lock, ooh323_pvt::owner, ast_channel::tech_pvt, usecnt, usecnt_lock, and ooh323_pvt::username.

00873 {
00874    struct ooh323_pvt *p = ast->tech_pvt;
00875 
00876    if(gH323Debug)
00877       ast_verbose("---   ooh323_hangup\n");
00878 
00879    if(p)
00880    {
00881       ast_mutex_lock(&p->lock);
00882 
00883       if(gH323Debug)
00884    ast_verbose("    hanging %s\n", p->username);
00885       ast->tech_pvt = NULL; 
00886       if(!ast_test_flag(p, H323_ALREADYGONE)) {
00887          ast_mutex_lock(&ooh323c_cmd_lock);
00888          ooHangCall(p->callToken, 
00889              ooh323_convert_hangupcause_asteriskToH323(p->owner->hangupcause));
00890          ast_mutex_unlock(&ooh323c_cmd_lock);
00891          ast_set_flag(p, H323_ALREADYGONE);
00892          /* ast_mutex_unlock(&p->lock); */
00893       }
00894       else {
00895          ast_set_flag(p, H323_NEEDDESTROY);
00896       }
00897       /* detach channel here */
00898       if(p->owner)
00899       {
00900          p->owner->tech_pvt = NULL;
00901          p->owner = NULL;
00902       }
00903 
00904       ast_mutex_unlock(&p->lock);
00905       ast_mutex_lock(&usecnt_lock);
00906       usecnt--;
00907       ast_mutex_unlock(&usecnt_lock);
00908 
00909       /* Notify the module monitors that use count for resource has changed */
00910       ast_update_use_count();
00911      
00912    }
00913 
00914 
00915    else {
00916       ast_log(LOG_ERROR, "No call to hangup\n" );
00917       return -1;
00918    }
00919    
00920    if(gH323Debug)
00921       ast_verbose("+++   ooh323_hangup\n");
00922 
00923   return 0;
00924 }

static int ooh323_indicate ( struct ast_channel *  ast,
int  condition,
const void *  data,
size_t  datalen 
) [static]

Definition at line 1003 of file chan_ooh323.c.

References AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_log(), ast_moh_start(), ast_moh_stop(), ast_mutex_lock(), ast_mutex_unlock(), ast_set_flag, ast_test_flag, ast_verbose(), ooh323_pvt::callToken, gH323Debug, H323_ALREADYGONE, ooh323_pvt::lock, LOG_WARNING, ooh323c_cmd_lock, strdup, and ast_channel::tech_pvt.

01004 {
01005 
01006    struct ooh323_pvt *p = (struct ooh323_pvt *) ast->tech_pvt;
01007    char *callToken = (char *)NULL;
01008 
01009    ast_mutex_lock(&p->lock);
01010    callToken = (p->callToken ? strdup(p->callToken) : NULL);
01011    ast_mutex_unlock(&p->lock);
01012 
01013    if(!callToken)
01014    {
01015       if(gH323Debug)
01016          ast_verbose("   ooh323_indicate - No callToken\n");
01017       return -1;
01018    }
01019 
01020    if(gH323Debug)
01021       ast_verbose("----- ooh323_indicate %d on call %s\n", condition, callToken);
01022     
01023 
01024    switch(condition) {
01025       case AST_CONTROL_CONGESTION:
01026          if(!ast_test_flag(p, H323_ALREADYGONE)){
01027             ast_mutex_lock(&ooh323c_cmd_lock);
01028             ooHangCall(callToken, OO_REASON_LOCAL_CONGESTED);
01029             ast_mutex_unlock(&ooh323c_cmd_lock);
01030             ast_set_flag(p, H323_ALREADYGONE);
01031          }
01032          break;
01033       case AST_CONTROL_BUSY:
01034          if(!ast_test_flag(p, H323_ALREADYGONE)){
01035             ast_mutex_lock(&ooh323c_cmd_lock);
01036             ooHangCall(callToken, OO_REASON_LOCAL_BUSY);
01037             ast_mutex_unlock(&ooh323c_cmd_lock);
01038             ast_set_flag(p, H323_ALREADYGONE);
01039          }
01040          break;
01041       case AST_CONTROL_HOLD:
01042          ast_moh_start(ast, data, NULL);      
01043          break;
01044       case AST_CONTROL_UNHOLD:
01045         ast_moh_stop(ast);
01046          break;
01047       case AST_CONTROL_PROCEEDING:
01048       case AST_CONTROL_RINGING:
01049       case AST_CONTROL_PROGRESS:
01050       case -1:
01051          break;
01052       default:
01053          ast_log(LOG_WARNING,"Don't know how to indicate condition %d on %s\n",
01054                               condition, callToken);
01055    }
01056 
01057    if(gH323Debug)
01058       ast_verbose("++++  ooh323_indicate %d on %s\n", condition, callToken);
01059 
01060 
01061    return -1;
01062 }

static struct ast_channel* ooh323_new ( struct ooh323_pvt *  i,
int  state,
const char *  host 
) [static, read]

Definition at line 245 of file chan_ooh323.c.

References accountcode, ooh323_pvt::accountcode, ast_channel::adsicpe, ast_channel::amaflags, ooh323_pvt::amaflags, AST_ADSI_UNAVAILABLE, ast_best_codec(), ast_channel_alloc(), ast_dsp_new(), ast_dsp_set_features(), ast_hangup(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pbx_start(), ast_rtcp_fd(), ast_rtp_fd(), ast_setstate(), AST_STATE_DOWN, AST_STATE_RING, ast_string_field_set, ast_strlen_zero(), ast_test_flag, ast_update_use_count(), ast_verbose(), ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_email, ooh323_pvt::caller_h323id, ooh323_pvt::caller_url, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, ooh323_pvt::capability, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, ooh323_pvt::context, DSP_FEATURE_DTMF_DETECT, ooh323_pvt::dtmfmode, ast_channel::exten, ooh323_pvt::exten, ast_channel::fds, gH323Debug, H323_DTMF_INBAND, H323_OUTGOING, ast_channel::lock, ooh323_pvt::lock, LOG_WARNING, ast_channel::name, ast_channel::nativeformats, ooh323_pvt::owner, pbx_builtin_setvar_helper(), ast_channel::priority, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::rings, ooh323_pvt::rtp, strdup, ast_channel::tech, ast_channel::tech_pvt, usecnt, usecnt_lock, ooh323_pvt::vad, and ast_channel::writeformat.

Referenced by onAlerting(), and ooh323_request().

00247 {
00248    struct ast_channel *ch = NULL;
00249    int fmt;
00250    if(gH323Debug)
00251       ast_verbose("---   ooh323_new - %s\n", host);
00252 
00253 
00254    /* Don't hold a h323 pvt lock while we allocate a channel */
00255    ast_mutex_unlock(&i->lock);
00256    ch = ast_channel_alloc(1, state, i->callerid_num, i->callerid_name, i->accountcode, i->exten, i->context, i->amaflags, "OOH323/%s-%04x", host, rand() & 0xffff);
00257    ast_mutex_lock(&i->lock);
00258 
00259    if(ch)
00260    {
00261       ast_mutex_lock(&ch->lock);
00262       ch->tech = &ooh323_tech;
00263 
00264       ch->nativeformats = i->capability;
00265 
00266 
00267       fmt = ast_best_codec(ch->nativeformats);
00268 
00269       ch->fds[0] = ast_rtp_fd(i->rtp);
00270       ch->fds[1] = ast_rtcp_fd(i->rtp);
00271 
00272       if (state == AST_STATE_RING)
00273          ch->rings = 1;
00274 
00275       ch->adsicpe = AST_ADSI_UNAVAILABLE;
00276       ch->writeformat = fmt;
00277       ch->rawwriteformat = fmt;
00278       ch->readformat = fmt;
00279       ch->rawreadformat = fmt;
00280       ch->tech_pvt = i;
00281       i->owner = ch;
00282 
00283       /* Allocate dsp for in-band DTMF support */
00284       if(i->dtmfmode & H323_DTMF_INBAND) {
00285          i->vad = ast_dsp_new();
00286          ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
00287       }
00288 
00289       ast_mutex_lock(&usecnt_lock);
00290       usecnt++;
00291       ast_mutex_unlock(&usecnt_lock);
00292 
00293       /* Notify the module monitors that use count for resource has changed*/
00294       ast_update_use_count();
00295 
00296       strncpy(ch->context, i->context, sizeof(ch->context)-1);
00297       ch->context[sizeof(ch->context)-1] = '\0';
00298       strncpy(ch->exten, i->exten, sizeof(ch->exten)-1);
00299       ch->exten[sizeof(ch->exten)-1] = '\0';
00300 
00301       ch->priority = 1;
00302       if (i->callerid_name)
00303       {
00304          ch->cid.cid_name = strdup(i->callerid_name);
00305       }
00306       if(i->callerid_num){
00307 
00308          ch->cid.cid_num = strdup(i->callerid_num);
00309       }
00310 
00311       if(!ast_test_flag(i, H323_OUTGOING))
00312       {
00313       
00314          if (!ast_strlen_zero(i->caller_h323id)) {
00315             pbx_builtin_setvar_helper(ch, "_CALLER_H323ID", i->caller_h323id);
00316 
00317          }
00318          if (!ast_strlen_zero(i->caller_dialedDigits)) {
00319             pbx_builtin_setvar_helper(ch, "_CALLER_H323DIALEDDIGITS", 
00320                                                        i->caller_dialedDigits);
00321          }
00322          if (!ast_strlen_zero(i->caller_email)) {
00323             pbx_builtin_setvar_helper(ch, "_CALLER_H323EMAIL", 
00324                                                               i->caller_email);
00325          }
00326          if (!ast_strlen_zero(i->caller_url)) {
00327             pbx_builtin_setvar_helper(ch, "_CALLER_H323URL", i->caller_url);
00328          }
00329       }
00330 
00331       if (!ast_strlen_zero(i->accountcode))
00332          ast_string_field_set(ch, accountcode, i->accountcode);
00333       
00334       if (i->amaflags)
00335          ch->amaflags = i->amaflags;
00336 
00337       ast_setstate(ch, state);
00338       if (state != AST_STATE_DOWN) {
00339          if (ast_pbx_start(ch)) {
00340             ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
00341             ast_mutex_unlock(&ch->lock);
00342             ast_hangup(ch);
00343             ch = NULL;
00344          }
00345       }
00346    } else
00347       ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
00348 
00349 
00350    if(ch)   ast_mutex_unlock(&ch->lock);
00351 
00352    if(gH323Debug)
00353       ast_verbose("+++   h323_new\n");
00354 
00355    return ch;
00356 }

static int ooh323_no_debug ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2368 of file chan_ooh323.c.

References ast_cli(), FALSE, gH323Debug, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

02370 {
02371    if (argc != 3)
02372       return RESULT_SHOWUSAGE;
02373    gH323Debug = FALSE;
02374    ast_cli(fd, "OOH323 Debugging Disabled\n");
02375    return RESULT_SUCCESS;
02376 }

int ooh323_onReceivedDigit ( OOH323CallData *  call,
const char *  digit 
)

Callback for sending digits from H.323 up to asterisk

Definition at line 1213 of file chan_ooh323.c.

References AST_FRAME_DTMF, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_queue_frame(), ast_frame::data, ast_frame::datalen, find_call(), ast_frame::frametype, ooh323_pvt::lock, LOG_DEBUG, LOG_ERROR, ast_frame::mallocd, ast_frame::offset, ooh323_pvt::owner, ast_frame::samples, ast_frame::src, and ast_frame::subclass.

Referenced by load_module().

01214 {
01215    struct ooh323_pvt *p=NULL;
01216    struct ast_frame f;
01217    int res;
01218 
01219    ast_log(LOG_DEBUG, "Received Digit: %c\n", digit);
01220    p = find_call(call);
01221    if(!p) {
01222       ast_log(LOG_ERROR, "Failed to find a matching call.\n");
01223       return -1;
01224    }
01225    if(!p->owner) {
01226       ast_log(LOG_ERROR, "Channel has no owner\n");
01227       return -1;
01228    }
01229    ast_mutex_lock(&p->lock);
01230    memset(&f, 0, sizeof(f));
01231    f.frametype = AST_FRAME_DTMF;
01232    f.subclass = digit[0];
01233    f.datalen = 0;
01234    f.samples = 800;
01235    f.offset = 0;
01236    f.data = NULL;
01237    f.mallocd = 0;
01238    f.src = "SEND_DIGIT";
01239    ast_mutex_unlock(&p->lock);
01240    res = ast_queue_frame(p->owner, &f);
01241    return res;
01242 }

int ooh323_onReceivedSetup ( ooCallData *  call,
Q931Message *  pmsg 
)

Definition at line 1244 of file chan_ooh323.c.

References ooh323_user::accountcode, ooh323_pvt::accountcode, ooh323_user::amaflags, ooh323_pvt::amaflags, ast_clear_flag, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), ast_verbose(), ooh323_pvt::callee_dialedDigits, ooh323_pvt::callee_email, ooh323_pvt::callee_h323id, ooh323_pvt::caller_dialedDigits, ooh323_pvt::caller_email, ooh323_pvt::caller_h323id, ooh323_pvt::caller_url, ooh323_pvt::callerid_name, ooh323_pvt::callerid_num, ooh323_user::capability, ooh323_pvt::capability, configure_local_rtp(), ooh323_user::context, ooh323_pvt::context, ooh323_user::dtmfmode, ooh323_pvt::dtmfmode, ooh323_pvt::exten, find_user(), ooh323_pvt::flags, gH323Debug, H323_DISABLEGK, H323_OUTGOING, ooh323_user::lock, ooh323_pvt::lock, LOG_ERROR, ooh323_user::name, ooh323_alloc(), ooh323c_set_capability_for_call(), ooh323_user::prefs, ooh323_pvt::prefs, strdup, update_our_aliases(), and ooh323_pvt::username.

Referenced by load_module().

01245 {
01246    struct ooh323_pvt *p=NULL;
01247    struct ooh323_user *user=NULL;
01248    ooAliases *alias=NULL;
01249    char *at=NULL;
01250    char number [OO_MAX_NUMBER_LENGTH];
01251 
01252    if(gH323Debug)
01253       ast_verbose("---   ooh323_onReceivedSetup %s\n", call->callToken);
01254 
01255 
01256    p = ooh323_alloc(call->callReference, call->callToken);
01257    if(!p)
01258    {
01259       ast_log(LOG_ERROR, "Failed to create a new call.\n");
01260       return -1;
01261    }
01262    ast_mutex_lock(&p->lock);
01263    ast_clear_flag(p, H323_OUTGOING);
01264   
01265 
01266    if(call->remoteDisplayName){
01267       p->callerid_name = strdup(call->remoteDisplayName);
01268    }
01269 
01270    if(ooCallGetCallingPartyNumber(call, number, OO_MAX_NUMBER_LENGTH) == OO_OK)
01271    {
01272       p->callerid_num = strdup(number);
01273    }
01274 
01275    if(call->remoteAliases)
01276    {
01277       alias = call->remoteAliases;         
01278       while(alias)
01279       {
01280          if(alias->type == T_H225AliasAddress_h323_ID)
01281          {
01282             if(!p->callerid_name){
01283                p->callerid_name = strdup(alias->value);
01284             }
01285             strncpy(p->caller_h323id, alias->value, sizeof(p->caller_h323id)-1);
01286          }
01287          else if(alias->type == T_H225AliasAddress_dialedDigits)
01288          {
01289             if(!p->callerid_num)
01290                p->callerid_num = strdup(alias->value);
01291             strncpy(p->caller_dialedDigits, alias->value, 
01292                                              sizeof(p->caller_dialedDigits)-1);
01293          }
01294          else if(alias->type == T_H225AliasAddress_email_ID)
01295          {
01296             strncpy(p->caller_email, alias->value, sizeof(p->caller_email)-1);
01297          }
01298          else if(alias->type == T_H225AliasAddress_url_ID)
01299          {
01300             strncpy(p->caller_url, alias->value, sizeof(p->caller_url)-1);
01301          }
01302          alias = alias->next;
01303       }
01304    }
01305 
01306    number[0]='\0';
01307    if(ooCallGetCalledPartyNumber(call, number, OO_MAX_NUMBER_LENGTH)== OO_OK)
01308    {
01309       strncpy(p->exten, number, sizeof(p->exten)-1);
01310    }
01311    else{
01312       update_our_aliases(call, p);
01313       if(!ast_strlen_zero(p->callee_dialedDigits)){
01314          strncpy(p->exten, p->callee_dialedDigits, sizeof(p->exten)-1);
01315       }
01316       else if(!ast_strlen_zero(p->callee_h323id)){
01317          strncpy(p->exten, p->callee_h323id, sizeof(p->exten)-1);
01318       }
01319       else if(!ast_strlen_zero(p->callee_email)){
01320          strncpy(p->exten, p->callee_email, sizeof(p->exten)-1);
01321          if((at=strchr(p->exten, '@'))) {
01322             *at='\0';
01323          }
01324       }
01325    }
01326 
01327    /* if no extension found, set to default 's' */
01328    if(ast_strlen_zero(p->exten))
01329    {     
01330       p->exten[0]='s';
01331       p->exten[1]='\0';
01332    }
01333 
01334    if(!p->callerid_name)
01335    {
01336       p->callerid_name = strdup(call->remoteIP);
01337    }
01338    
01339    if(p->callerid_name)
01340    {
01341       user = find_user(p->callerid_name, call->remoteIP);
01342       if(user)
01343       {
01344          ast_mutex_lock(&user->lock);
01345          p->username = strdup(user->name);
01346          strncpy(p->context, user->context, sizeof(p->context)-1);
01347          strncpy(p->accountcode, user->accountcode, sizeof(p->accountcode)-1);
01348          p->amaflags = user->amaflags;
01349          p->capability = user->capability;
01350          memcpy(&p->prefs, &user->prefs, sizeof(struct ast_codec_pref));
01351          p->dtmfmode = user->dtmfmode;
01352          /* Since, call is coming from a pbx user, no need to use gk */
01353          OO_SETFLAG(p->flags, H323_DISABLEGK);
01354          OO_SETFLAG(call->flags, OO_M_DISABLEGK);
01355          ast_mutex_unlock(&user->lock);
01356       }
01357    }
01358 
01359 
01360    ooh323c_set_capability_for_call(call, &p->prefs, p->capability,p->dtmfmode);
01361    configure_local_rtp(p, call);
01362 
01363    ast_mutex_unlock(&p->lock);
01364 
01365    if(gH323Debug)
01366       ast_verbose("+++   ooh323_onReceivedSetup - Determined context %s, "
01367                   "extension %s\n", p->context, p->exten);
01368 
01369    return OO_OK;
01370 }

static struct ast_frame * ooh323_read ( struct ast_channel *  ast  )  [static, read]

Definition at line 953 of file chan_ooh323.c.

References AST_FRAME_NULL, ast_mutex_lock(), ast_mutex_unlock(), ooh323_pvt::lock, ooh323_rtp_read(), ooh323_pvt::rtp, and ast_channel::tech_pvt.

00954 {
00955    struct ast_frame *fr;
00956    static struct ast_frame null_frame = { AST_FRAME_NULL, };
00957    struct ooh323_pvt *p = ast->tech_pvt;
00958 
00959    ast_mutex_lock(&p->lock);
00960    if(p->rtp)
00961       fr = ooh323_rtp_read(ast, p);
00962    else
00963       fr = &null_frame;
00964    /* time(&p->lastrtprx); */
00965    ast_mutex_unlock(&p->lock);
00966    return fr;
00967 }

static int ooh323_reload ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1849 of file chan_ooh323.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), gH323Debug, h323_reload_lock, h323_reloading, and restart_monitor().

Referenced by reload().

01850 {
01851 
01852    if(gH323Debug)
01853       ast_verbose("---   ooh323_reload\n");
01854 
01855    ast_mutex_lock(&h323_reload_lock);
01856    if (h323_reloading) {
01857       ast_verbose("Previous OOH323 reload not yet done\n");
01858    } 
01859    else {
01860       h323_reloading = 1;
01861    }
01862    ast_mutex_unlock(&h323_reload_lock);
01863    restart_monitor();
01864 
01865    if(gH323Debug)
01866       ast_verbose("+++   ooh323_reload\n");
01867 
01868    return 0;
01869 }

static struct ast_channel * ooh323_request ( const char *  type,
int  format,
void *  data,
int *  cause 
) [static, read]

Definition at line 457 of file chan_ooh323.c.

References ooh323_peer::accountcode, ooh323_pvt::accountcode, ooh323_peer::amaflags, ooh323_pvt::amaflags, AST_FORMAT_MAX_AUDIO, ast_getformatname_multiple(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_set_flag, AST_STATE_DOWN, ast_verbose(), ooh323_pvt::capability, ooh323_peer::capability, ooh323_peer::dtmfmode, ooh323_pvt::dtmfmode, ext, ooh323_pvt::exten, find_peer(), ooh323_pvt::flags, gCapability, gDTMFMode, gH323Debug, gPrefs, H323_DISABLEGK, H323_OUTGOING, ooh323_pvt::host, iflock, ooh323_peer::ip, ooh323_pvt::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ooh323_peer::name, ooh323_alloc(), ooh323_destroy(), ooh323_new(), ooh323_pvt::port, ooh323_peer::port, ooh323_peer::prefs, ooh323_pvt::prefs, restart_monitor(), strdup, and ooh323_pvt::username.

00460 {
00461    struct ast_channel *chan=NULL;
00462    struct ooh323_pvt *p = NULL;
00463    struct ooh323_peer *peer = NULL;
00464    char *dest = NULL; 
00465    char *ext = NULL;
00466    char tmp[256];
00467    char formats[512];
00468    int oldformat;
00469    char *sport = NULL;
00470    int port = 0;
00471 
00472    if(gH323Debug)
00473       ast_verbose("---   ooh323_request - data %s format %s\n", (char*)data,  
00474                               ast_getformatname_multiple(formats,512,format) );
00475 
00476    oldformat = format;
00477    format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1);
00478    if (!format) {
00479       ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format "
00480                           "'%d'\n", format);
00481       return NULL;
00482    }
00483 
00484    p = ooh323_alloc(0,0); /* Initial callRef is zero */
00485 
00486    if(!p)
00487    {
00488       ast_log(LOG_WARNING, "Unable to build pvt data for '%s'\n", (char*)data);
00489       return NULL;
00490    }
00491    ast_mutex_lock(&p->lock);
00492 
00493    /* This is an outgoing call, since ooh323_request is called */
00494    ast_set_flag(p, H323_OUTGOING);
00495 
00496 
00497    strncpy(tmp, (char*)data, sizeof(tmp)-1);
00498 
00499    dest = strchr(tmp, '/');
00500 
00501    if(dest)
00502    {  
00503       *dest = '\0';
00504       dest++;
00505       ext = tmp;
00506    }
00507    else if((dest = strchr(tmp, '@'))) {
00508       *dest = '\0';
00509       dest++;
00510       ext = tmp;
00511    }
00512    else {
00513       dest = tmp;
00514       ext = NULL;
00515    }
00516    
00517    /*if((sport = strchr(dest, ':'))) {
00518       *sport = '\0';
00519       sport++;
00520       port = atoi(sport);
00521    }*/
00522 
00523    if(dest) {
00524       peer = find_peer(dest, port);
00525    }
00526    else{
00527       ast_log(LOG_ERROR, "Destination format is not supported\n");
00528       return NULL;
00529    }
00530 
00531    if(peer)
00532    {
00533       p->username = strdup(peer->name);
00534       p->host = strdup(peer->ip);
00535       p->port = peer->port;
00536       /* Disable gk as we are going to call a known peer*/
00537       OO_SETFLAG(p->flags, H323_DISABLEGK);
00538 
00539       if(ext)
00540          strncpy(p->exten, ext, sizeof(p->exten)-1);
00541 
00542       if(peer->capability & format)
00543          p->capability = peer->capability & format;
00544       else{
00545          p->capability = peer->capability;
00546       }
00547       memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
00548       p->dtmfmode = peer->dtmfmode;
00549       strncpy(p->accountcode, peer->accountcode, sizeof(p->accountcode)-1);
00550       p->amaflags = peer->amaflags;
00551    }
00552    else {
00553       p->dtmfmode = gDTMFMode;
00554       p->capability = gCapability;
00555 
00556       memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
00557       p->username = strdup(dest);
00558      
00559       p->host = strdup(dest);
00560       if(port > 0) {
00561          p->port = port;
00562       }
00563       if(ext) {
00564          strncpy(p->exten, ext, sizeof(p->exten)-1);
00565       }
00566    }
00567 
00568 
00569    chan = ooh323_new(p, AST_STATE_DOWN, p->username);
00570    
00571    ast_mutex_unlock(&p->lock);
00572 
00573    if (!chan)
00574    {
00575       ast_mutex_lock(&iflock);
00576       ooh323_destroy(p);
00577       ast_mutex_unlock(&iflock);
00578    }
00579 
00580    restart_monitor();
00581    if(gH323Debug)
00582       ast_verbose("+++   ooh323_request\n");
00583 
00584    return chan;
00585 
00586 }

struct ast_frame* ooh323_rtp_read ( struct ast_channel *  ast,
struct ooh323_pvt *  p 
) [read]

Definition at line 3276 of file chan_ooh323.c.

References ast_dsp_process(), AST_FRAME_DTMF, AST_FRAME_NULL, AST_FRAME_VOICE, ast_log(), ast_rtcp_read(), ast_rtp_read(), ast_set_read_format(), ast_set_write_format(), ooh323_pvt::dtmfmode, f, ast_channel::fdno, ast_frame::frametype, H323_DTMF_INBAND, H323_DTMF_RFC2833, LOG_DEBUG, ast_channel::nativeformats, ooh323_pvt::owner, ast_channel::readformat, ooh323_pvt::rtp, ast_frame::subclass, ooh323_pvt::vad, ooh323_pvt::vrtp, and ast_channel::writeformat.

Referenced by ooh323_read().

03277 {
03278    /* Retrieve audio/etc from channel.  Assumes p->lock is already held. */
03279    struct ast_frame *f;
03280    static struct ast_frame null_frame = { AST_FRAME_NULL, };
03281    switch(ast->fdno) {
03282       case 0:
03283          f = ast_rtp_read(p->rtp);   /* RTP Audio */
03284          break;
03285       case 1:
03286          f = ast_rtcp_read(p->rtp);   /* RTCP Control Channel */
03287          break;
03288       case 2:
03289          f = ast_rtp_read(p->vrtp);   /* RTP Video */
03290          break;
03291       case 3:
03292          f = ast_rtcp_read(p->vrtp);   /* RTCP Control Channel for video */
03293          break;
03294       default:
03295          f = &null_frame;
03296    }
03297    /* Don't send RFC2833 if we're not supposed to */
03298    if (f && (f->frametype == AST_FRAME_DTMF) && 
03299        !(p->dtmfmode & H323_DTMF_RFC2833))
03300       return &null_frame;
03301    if (p->owner) 
03302    {
03303       /* We already hold the channel lock */
03304       if (f->frametype == AST_FRAME_VOICE) 
03305       {
03306          if (f->subclass != p->owner->nativeformats) 
03307          {
03308             ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
03309             p->owner->nativeformats = f->subclass;
03310             ast_set_read_format(p->owner, p->owner->readformat);
03311             ast_set_write_format(p->owner, p->owner->writeformat);
03312          }
03313          if ((p->dtmfmode & H323_DTMF_INBAND) && p->vad) 
03314          {
03315             f = ast_dsp_process(p->owner, p->vad, f);
03316             if (f && (f->frametype == AST_FRAME_DTMF)) 
03317                ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n",f->subclass);
03318          }
03319       }
03320    }
03321    return f;
03322 }

void ooh323_set_read_format ( ooCallData *  call,
int  fmt 
)

Definition at line 1133 of file chan_ooh323.c.

References ast_getformatname_multiple(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_set_read_format(), find_call(), ooh323_pvt::lock, LOG_ERROR, ooh323_pvt::owner, and ooh323_pvt::readformat.

Referenced by ooh323c_start_receive_channel().

01134 {
01135 #if 0
01136    struct ooh323_pvt *p = NULL;
01137    char formats[512];
01138 #ifdef print_debug
01139    printf("---   ooh323_update_readformat %s\n", 
01140                                  ast_getformatname_multiple(formats,512, fmt));
01141 #endif
01142 
01143    p = find_call(call);
01144    if(!p)
01145    {
01146       ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken);
01147       return;
01148    }
01149 
01150    ast_mutex_lock(&p->lock);
01151    p->readformat = fmt;
01152    ast_mutex_unlock(&p->lock);
01153    ast_set_read_format(p->owner, fmt);   
01154    
01155 #ifdef print_debug
01156   printf("+++   ooh323_update_readformat\n");
01157 #endif
01158 #endif
01159 }

static int ooh323_set_rtp_peer ( struct ast_channel *  chan,
struct ast_rtp *  rtp,
struct ast_rtp *  vrtp,
int  codecs,
int  nat_active 
) [static]

Definition at line 3113 of file chan_ooh323.c.

References ast_log(), ast_rtp_get_peer(), ast_rtp_get_us(), ast_verbose(), gH323Debug, LOG_ERROR, ast_channel::name, ooh323_convertAsteriskCapToH323Cap(), ast_channel::tech_pvt, and ast_channel::writeformat.

03115 {
03116    /* XXX Deal with Video */
03117    struct ooh323_pvt *p;
03118    struct sockaddr_in them;
03119    struct sockaddr_in us;
03120    int mode;
03121 
03122    if(gH323Debug)
03123       ast_verbose("---   ooh323_set_peer - %s\n", chan->name);
03124 
03125    if (!rtp) {
03126       return 0;
03127    }
03128 
03129    mode = ooh323_convertAsteriskCapToH323Cap(chan->writeformat); 
03130    p = (struct ooh323_pvt *) chan->tech_pvt;
03131    if (!p) {
03132       ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
03133       return -1;
03134    }
03135    ast_rtp_get_peer(rtp, &them);
03136    ast_rtp_get_us(rtp, &us);
03137    return 0;
03138 }

void ooh323_set_write_format ( ooCallData *  call,
int  fmt 
)

Definition at line 1095 of file chan_ooh323.c.

References ast_getformatname_multiple(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_set_write_format(), find_call(), ooh323_pvt::lock, LOG_ERROR, ooh323_pvt::owner, ast_channel::writeformat, and ooh323_pvt::writeformat.

Referenced by ooh323c_start_transmit_channel().

01096 {
01097 #if 0
01098    struct ooh323_pvt *p = NULL;
01099    char formats[512];
01100 #ifdef print_debug
01101    printf("---   ooh323_update_writeformat %s\n", 
01102                               ast_getformatname_multiple(formats,512, fmt));
01103 #endif
01104    
01105    p = find_call(call);
01106    if(!p)
01107    {
01108       ast_log(LOG_ERROR, "No matching call found for %s\n", call->callToken);
01109       return;
01110    }
01111 
01112    ast_mutex_lock(&p->lock);
01113 
01114    p->writeformat = fmt;
01115    ast_mutex_unlock(&p->lock);
01116 
01117    if(p->owner){
01118      printf("Writeformat before update %s\n", 
01119               ast_getformatname_multiple(formats,512, p->owner->writeformat));
01120      ast_set_write_format(p->owner, fmt);
01121    }
01122    else
01123      ast_log(LOG_ERROR, "No owner found\n");
01124 
01125 
01126 #ifdef print_debug
01127   printf("+++   ooh323_update_writeformat\n");
01128 #endif
01129 #endif
01130 }

static int ooh323_show_channels ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2378 of file chan_ooh323.c.

References RESULT_SUCCESS.

02379 {
02380    return RESULT_SUCCESS;
02381 }

static int ooh323_show_config ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2383 of file chan_ooh323.c.

References ast_cdr_flags2str(), ast_cli(), ast_getformatname_multiple(), gAccountcode, gAliasList, gAMAFLAGS, gCallerID, gCapability, gContext, gDTMFMode, gFastStart, gGatekeeper, gIP, gLogFile, gMediaWaitForConnect, gPort, gRasGkMode, gTunneling, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_config::mTCPPortEnd, ooh323_config::mTCPPortStart, ooconfig, and RESULT_SUCCESS.

02384 {
02385    char value[512];
02386    ooAliases *pAlias = NULL, *pAliasNext=NULL;;
02387 
02388    ast_cli(fd, "\nObjective Open H.323 Channel Driver's Config:\n");
02389    sprintf(value, "%s:%d", gIP, gPort);
02390    ast_cli(fd, "%-20s%s\n", "IP:Port: ", value);
02391    ast_cli(fd, "%-20s%d-%d\n", "H.225 port range: ", 
02392       ooconfig.mTCPPortStart, ooconfig.mTCPPortEnd);
02393    ast_cli(fd, "%-20s%s\n", "FastStart", gFastStart?"yes":"no");
02394    ast_cli(fd, "%-20s%s\n", "Tunneling", gTunneling?"yes":"no");
02395    ast_cli(fd, "%-20s%s\n", "CallerId", gCallerID);
02396    ast_cli(fd, "%-20s%s\n", "MediaWaitForConnect", 
02397       gMediaWaitForConnect?"yes":"no");
02398 
02399 #if (0)
02400    extern OOH323EndPoint gH323ep;
02401    ast_cli(fd, "%-20s%s\n", "FASTSTART", 
02402       (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART) != 0) ? "yes" : "no");
02403    ast_cli(fd, "%-20s%s\n", "TUNNELING", 
02404       (OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING) != 0) ? "yes" : "no");
02405    ast_cli(fd, "%-20s%s\n", "MEDIAWAITFORCONN",
02406       (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN) != 0) ? "yes" : "no");
02407 #endif
02408 
02409    if(gRasGkMode == RasNoGatekeeper)
02410       sprintf(value, "%s", "No Gatekeeper");
02411    else if(gRasGkMode == RasDiscoverGatekeeper)
02412       sprintf(value, "%s", "Discover");
02413    else
02414       sprintf(value, "%s", gGatekeeper);
02415 
02416    ast_cli(fd,  "%-20s%s\n", "Gatekeeper:", value);
02417 
02418    ast_cli(fd,  "%-20s%s\n", "H.323 LogFile:", gLogFile);   
02419 
02420    ast_cli(fd,  "%-20s%s\n", "Context:", gContext);
02421    
02422    ast_cli(fd,  "%-20s%s\n", "Capability:", 
02423            ast_getformatname_multiple(value,512,gCapability));
02424 
02425    ast_cli(fd, "%-20s", "DTMF Mode: ");
02426    if(gDTMFMode & H323_DTMF_RFC2833)
02427       ast_cli(fd, "%s\n", "rfc2833");
02428    else if (gDTMFMode & H323_DTMF_Q931)
02429       ast_cli(fd, "%s\n", "q931keypad");
02430    else if(gDTMFMode & H323_DTMF_H245ALPHANUMERIC)
02431       ast_cli(fd, "%s\n", "h245alphanumeric");
02432    else if(gDTMFMode & H323_DTMF_H245SIGNAL)
02433       ast_cli(fd, "%s\n", "h245signal");
02434    else
02435       ast_cli(fd, "%s\n", "unknown");
02436 
02437    ast_cli(fd, "%-20s%s\n", "AccountCode: ", gAccountcode);
02438 
02439    ast_cli(fd, "%-20s%s\n", "AMA flags: ", ast_cdr_flags2str(gAMAFLAGS));
02440 
02441    pAlias = gAliasList;
02442    if(pAlias)
02443    {
02444      ast_cli(fd, "%-20s\n", "Aliases: ");
02445    }
02446    while(pAlias)
02447    {
02448       pAliasNext = pAlias->next;
02449       if(pAliasNext)
02450       {
02451          ast_cli(fd,"\t%-30s\t%-30s\n",pAlias->value, pAliasNext->value);
02452          pAlias = pAliasNext->next;
02453       }
02454       else{
02455          ast_cli(fd,"\t%-30s\n",pAlias->value);
02456          pAlias = pAlias->next;
02457       }
02458    }         
02459    return RESULT_SUCCESS;
02460 }

static int ooh323_show_peer ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2162 of file chan_ooh323.c.

References ast_cdr_flags2str(), ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_peer::lock, ast_peer_list::lock, ooh323_peer::next, peerl, ast_peer_list::peers, print_codec_to_cli(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.

02163 {
02164    struct ooh323_peer *prev=NULL, *peer=NULL;
02165    char formats[512];
02166    char ip_port[30];
02167    if(argc !=  4)
02168       return RESULT_SHOWUSAGE;
02169  
02170  
02171    ast_mutex_lock(&peerl.lock);
02172    peer = peerl.peers;
02173    while(peer)
02174    {
02175       ast_mutex_lock(&peer->lock);
02176       if(!strcmp(peer->name, argv[3]))
02177          break;
02178       else{
02179          prev = peer;
02180          peer = peer->next;
02181          ast_mutex_unlock(&prev->lock);
02182       }
02183    }
02184 
02185    if(peer)
02186    {
02187       sprintf(ip_port, "%s:%d", peer->ip, peer->port);
02188       ast_cli(fd, "%-15.15s%s\n", "Name: ", peer->name);
02189       ast_cli(fd, "%-15.15s%s", "Format Prefs: ", "(");
02190       print_codec_to_cli(fd, &peer->prefs);
02191       ast_cli(fd, ")\n");
02192       ast_cli(fd, "%-15.15s", "DTMF Mode: ");
02193       if(peer->dtmfmode & H323_DTMF_RFC2833)
02194          ast_cli(fd, "%s\n", "rfc2833");
02195       else if(peer->dtmfmode & H323_DTMF_Q931)
02196          ast_cli(fd, "%s\n", "q931keypad");
02197       else if(peer->dtmfmode & H323_DTMF_H245ALPHANUMERIC)
02198          ast_cli(fd, "%s\n", "h245alphanumeric");
02199       else if(peer->dtmfmode & H323_DTMF_H245SIGNAL)
02200          ast_cli(fd, "%s\n", "h245signal");
02201       else
02202          ast_cli(fd, "%s\n", "unknown");
02203       ast_cli(fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode);
02204       ast_cli(fd, "%-15.15s%s\n", "AMA flags: ", 
02205                                             ast_cdr_flags2str(peer->amaflags));
02206       ast_cli(fd, "%-15.15s%s\n", "IP:Port: ", ip_port);
02207       ast_cli(fd, "%-15.15s%d\n", "OutgoingLimit: ", peer->outgoinglimit);
02208       ast_cli(fd, "%-15.15s%d\n", "rtptimeout: ", peer->rtptimeout);
02209       ast_mutex_unlock(&peer->lock);
02210    }
02211    else{
02212      ast_cli(fd, "Peer %s not found\n", argv[3]);
02213      ast_cli(fd, "\n");
02214    }
02215    ast_mutex_unlock(&peerl.lock);
02216 
02217    return RESULT_SUCCESS;
02218 }

static int ooh323_show_peers ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2220 of file chan_ooh323.c.

References ast_cli(), ast_getformatname_multiple(), ast_mutex_lock(), ast_mutex_unlock(), FORMAT, ooh323_peer::lock, ast_peer_list::lock, ooh323_peer::next, peerl, ast_peer_list::peers, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

02221 {
02222    struct ooh323_peer *prev = NULL, *peer=NULL;
02223    char formats[512];
02224    char ip_port[30];
02225 #define FORMAT  "%-15.15s  %-15.15s  %-23.23s  %-s\n"
02226 
02227    if (argc != 3)
02228       return RESULT_SHOWUSAGE;
02229 
02230    ast_cli(fd, FORMAT, "Name", "Accountcode", "ip:port", "Formats");
02231    
02232    ast_mutex_lock(&peerl.lock);
02233    peer = peerl.peers;
02234    while(peer)
02235    {
02236      ast_mutex_lock(&peer->lock);
02237      sprintf(ip_port, "%s:%d", peer->ip, peer->port);
02238      ast_cli(fd, FORMAT, peer->name, 
02239                  peer->accountcode,
02240                  ip_port,
02241                  ast_getformatname_multiple(formats,512,peer->capability));
02242      prev = peer;
02243      peer = peer->next;
02244      ast_mutex_unlock(&prev->lock);
02245 
02246    }
02247    ast_mutex_unlock(&peerl.lock);
02248 #undef FORMAT
02249    return RESULT_SUCCESS;
02250 }

static int ooh323_show_user ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2270 of file chan_ooh323.c.

References ast_cdr_flags2str(), ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_Q931, H323_DTMF_RFC2833, ooh323_user::lock, ast_user_list::lock, ooh323_user::next, print_codec_to_cli(), RESULT_SHOWUSAGE, RESULT_SUCCESS, userl, and ast_user_list::users.

02271 {
02272    struct ooh323_user *prev=NULL, *user=NULL;
02273    char formats[512];
02274 
02275    if(argc !=  4)
02276       return RESULT_SHOWUSAGE;
02277  
02278  
02279    ast_mutex_lock(&userl.lock);
02280    user = userl.users;
02281    while(user)
02282    {
02283       ast_mutex_lock(&user->lock);
02284       if(!strcmp(user->name, argv[3])) {
02285          break;
02286       }
02287       else {
02288          prev = user;
02289          user = user->next;
02290          ast_mutex_unlock(&prev->lock);
02291       }
02292    }
02293 
02294    if(user)
02295    {
02296       ast_cli(fd, "%-15.15s%s\n", "Name: ", user->name);
02297       ast_cli(fd, "%-15.15s%s", "Format Prefs: ", "(");
02298       print_codec_to_cli(fd, &user->prefs);
02299       ast_cli(fd, ")\n");
02300       ast_cli(fd, "%-15.15s", "DTMF Mode: ");
02301       if(user->dtmfmode & H323_DTMF_RFC2833)
02302          ast_cli(fd, "%s\n", "rfc2833");
02303       else if(user->dtmfmode & H323_DTMF_Q931)
02304          ast_cli(fd, "%s\n", "q931keypad");
02305       else if(user->dtmfmode & H323_DTMF_H245ALPHANUMERIC)
02306          ast_cli(fd, "%s\n", "h245alphanumeric");
02307       else if(user->dtmfmode & H323_DTMF_H245SIGNAL)
02308          ast_cli(fd, "%s\n", "h245signal");
02309       else
02310          ast_cli(fd, "%s\n", "unknown");
02311       ast_cli(fd, "%-15.15s%s\n", "AccountCode: ", user->accountcode);
02312       ast_cli(fd, "%-15.15s%s\n", "AMA flags: ", 
02313                                             ast_cdr_flags2str(user->amaflags));
02314       ast_cli(fd, "%-15.15s%s\n", "Context: ", user->context);
02315       ast_cli(fd, "%-15.15s%d\n", "IncomingLimit: ", user->incominglimit);
02316       ast_cli(fd, "%-15.15s%d\n", "rtptimeout: ", user->rtptimeout);
02317       ast_mutex_unlock(&user->lock);
02318    }
02319    else{
02320      ast_cli(fd, "User %s not found\n", argv[3]);
02321      ast_cli(fd, "\n");
02322    }
02323    ast_mutex_unlock(&userl.lock);
02324 
02325    return RESULT_SUCCESS;
02326 }

static int ooh323_show_users ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 2328 of file chan_ooh323.c.

References ast_cli(), ast_getformatname_multiple(), ast_mutex_lock(), ast_mutex_unlock(), FORMAT1, ooh323_user::lock, ast_user_list::lock, ooh323_user::next, RESULT_SHOWUSAGE, RESULT_SUCCESS, userl, and ast_user_list::users.

02329 {
02330    struct ooh323_user *prev = NULL, *user=NULL;
02331    char formats[512];
02332 #define FORMAT1  "%-15.15s  %-15.15s  %-15.15s  %-s\n"
02333 
02334    if (argc != 3)
02335       return RESULT_SHOWUSAGE;
02336 
02337    ast_cli(fd, FORMAT1, "Username", "Accountcode", "Context", "Formats");
02338    
02339    ast_mutex_lock(&userl.lock);
02340    user = userl.users;
02341    while(user)
02342    {
02343      ast_mutex_lock(&user->lock);
02344      ast_cli(fd, FORMAT1, user->name, 
02345                  user->accountcode, user->context,
02346                  ast_getformatname_multiple(formats,512,user->capability));
02347      prev = user;
02348      user = user->next;
02349      ast_mutex_unlock(&prev->lock);
02350 
02351    }
02352    ast_mutex_unlock(&userl.lock);
02353 #undef FORMAT1
02354    return RESULT_SUCCESS;
02355 
02356 }

int ooh323_update_capPrefsOrderForCall ( ooCallData *  call,
struct ast_codec_pref *  prefs 
)

Definition at line 3073 of file chan_ooh323.c.

References ast_codec_pref_index(), and ooh323_convertAsteriskCapToH323Cap().

03074 {
03075    int i=0;
03076    int codec = ast_codec_pref_index(prefs, i);
03077 
03078    ooResetCapPrefs(call);
03079    while(codec)
03080    {
03081       ooAppendCapToCapPrefs(call, ooh323_convertAsteriskCapToH323Cap(codec));
03082       codec = ast_codec_pref_index(prefs, ++i);
03083    }
03084 
03085    return 0;
03086 }

static int ooh323_write ( struct ast_channel *  ast,
struct ast_frame *  f 
) [static]

Definition at line 969 of file chan_ooh323.c.

References AST_FRAME_IMAGE, AST_FRAME_VOICE, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_write(), ast_frame::frametype, ooh323_pvt::lock, LOG_WARNING, ast_channel::nativeformats, ast_channel::readformat, ooh323_pvt::rtp, ast_frame::subclass, ast_channel::tech_pvt, and ast_channel::writeformat.

00970 {
00971    struct ooh323_pvt *p = ast->tech_pvt;
00972    int res = 0;
00973 
00974    if(f->frametype == AST_FRAME_VOICE)
00975    {
00976       if(!(f->subclass & ast->nativeformats))
00977       {
00978          ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native "
00979                              "formats is %d (read/write = %d/%d)\n",
00980                            f->subclass, ast->nativeformats, ast->readformat,
00981                               ast->writeformat);
00982          return 0;
00983       }
00984       if(p){
00985          ast_mutex_lock(&p->lock);
00986          if(p->rtp)
00987             res = ast_rtp_write(p->rtp, f);
00988          ast_mutex_unlock(&p->lock);
00989       }
00990    }
00991    else if (f->frametype == AST_FRAME_IMAGE) {
00992       return 0;
00993    }
00994    else {
00995       ast_log(LOG_WARNING, "Can't send %d type frames with SIP write\n", 
00996                             f->frametype);
00997       return 0;
00998    }
00999 
01000    return res;
01001 }

static void print_codec_to_cli ( int  fd,
struct ast_codec_pref *  pref 
) [static]

Print codec list from preference to CLI/manager.

Definition at line 2253 of file chan_ooh323.c.

References ast_cli(), ast_codec_pref_index(), ast_getformatname(), and ast_codec_pref::framing.

Referenced by ooh323_show_peer(), and ooh323_show_user().

02254 {
02255    int x, codec;
02256 
02257    for(x = 0; x < 32 ; x++) {
02258       codec = ast_codec_pref_index(pref, x);
02259       if (!codec)
02260          break;
02261       ast_cli(fd, "%s", ast_getformatname(codec));
02262       ast_cli(fd, ":%d", pref->framing[x]);
02263       if (x < 31 && ast_codec_pref_index(pref, x + 1))
02264          ast_cli(fd, ",");
02265       }
02266    if (!x)
02267       ast_cli(fd, "none");
02268 }

static int reload ( void *  mod  )  [static]

Definition at line 1871 of file chan_ooh323.c.

References ooh323_reload().

01872 {
01873    return ooh323_reload(0, 0, NULL);
01874 }

int reload_config ( void   ) 

Definition at line 1876 of file chan_ooh323.c.

References ast_category_browse(), ast_cdr_amaflags2int(), ast_config_destroy(), ast_config_load(), AST_FORMAT_ULAW, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_parse_allow_disallow(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose(), build_peer(), build_user(), config, DEFAULT_CONTEXT, DEFAULT_H323ACCNT, DEFAULT_H323ID, DEFAULT_LOGFILE, format, gAccountcode, gAliasList, gAMAFLAGS, gCallerID, gCapability, gContext, gDTMFMode, gFastStart, gGatekeeper, gH323Debug, gIncomingLimit, gIP, gIsGateway, gLogFile, gMediaWaitForConnect, gOutgoingLimit, gPort, gPrefs, gRasGkMode, gRTPTimeout, gTOS, gTunneling, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_INBAND, H323_DTMF_Q931, H323_DTMF_RFC2833, iax2_do_register(), iax_provision_reload(), IPTOS_MINCOST, ast_variable::lineno, ast_peer_list::lock, ast_user_list::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, malloc, ooh323_config::mTCPPortEnd, ooh323_config::mTCPPortStart, ast_variable::name, ooh323_peer::next, ooh323_user::next, ast_variable::next, ooconfig, peerl, ast_peer_list::peers, poke_all_peers(), prune_peers(), prune_users(), reload_firmware(), set_config(), strdup, userl, ast_user_list::users, ast_variable::value, and VERBOSE_PREFIX_3.

01877 {
01878    int format;
01879    struct ooAliases  *pNewAlias = NULL;
01880    struct ast_config *cfg;
01881    struct ast_variable *v;
01882    struct ooh323_user *user = NULL;
01883    struct ooh323_peer *peer = NULL;
01884    char *cat;
01885    const char *utype;
01886 
01887    if(gH323Debug)
01888       ast_verbose("---   reload_config\n");
01889 
01890    cfg = ast_config_load((char*)config);
01891 
01892    /* We *must* have a config file otherwise stop immediately */
01893    if (!cfg) {
01894       ast_log(LOG_NOTICE, "Unable to load config %s, OOH323 disabled\n",config);
01895       return 1;
01896    }
01897 
01898    /* Inintialize everything to default */
01899    strcpy(gLogFile, DEFAULT_LOGFILE);
01900    gPort = 1720;
01901    gIP[0]='\0';
01902    strcpy(gCallerID, DEFAULT_H323ID);
01903    gCapability = AST_FORMAT_ULAW;
01904    memset(&gPrefs, 0, sizeof(struct ast_codec_pref));
01905    gDTMFMode = H323_DTMF_RFC2833;
01906    gRasGkMode = RasNoGatekeeper;
01907    gGatekeeper[0] = '\0';
01908    gRTPTimeout = 60;
01909    strcpy(gAccountcode, DEFAULT_H323ACCNT);
01910    gFastStart = 1;
01911    gTunneling = 1;
01912    gTOS = 0;
01913    strcpy(gContext, DEFAULT_CONTEXT);
01914    gAliasList = NULL;
01915    gMediaWaitForConnect = 0;
01916    ooconfig.mTCPPortStart = 12030;
01917    ooconfig.mTCPPortEnd = 12230;
01918 
01919    v = ast_variable_browse(cfg, "general");
01920    while(v) {
01921    
01922       if (!strcasecmp(v->name, "port")) {
01923          gPort = (int)strtol(v->value, NULL, 10);
01924       } 
01925       else if (!strcasecmp(v->name, "bindaddr")) {
01926          strncpy(gIP, v->value, sizeof(gIP)-1);
01927       } 
01928       else if (!strcasecmp(v->name, "h225portrange")) {
01929          char* endlimit = 0;
01930          char temp[512];
01931          strncpy(temp, v->value, sizeof(temp) - 1);   
01932          /* char *temp = ast_strdupa(v->value); */
01933          endlimit = strchr(temp, ',');
01934          if (endlimit) {
01935             *endlimit = '\0';
01936             endlimit++;
01937             ooconfig.mTCPPortStart = atoi(temp);
01938             ooconfig.mTCPPortEnd = atoi(endlimit);
01939 
01940             if(ooH323EpSetTCPPortRange(ooconfig.mTCPPortStart, 
01941                                        ooconfig.mTCPPortEnd) == OO_FAILED) {
01942                ast_log(LOG_ERROR, "h225portrange: Failed to set range\n");
01943             }
01944          } 
01945          else {
01946             ast_log(LOG_ERROR, "h225portrange: Invalid format, separate port range with \",\"\n");
01947          }
01948       }
01949       else if (!strcasecmp(v->name, "gateway")) {
01950          gIsGateway = ast_true(v->value);
01951       } 
01952       else if (!strcasecmp(v->name, "faststart")) {
01953          gFastStart = ast_true(v->value);
01954          if(gFastStart)
01955             ooH323EpEnableFastStart();
01956          else
01957             ooH323EpDisableFastStart();
01958       } 
01959       else if (!strcasecmp(v->name, "mediawaitforconnect")) {
01960          gMediaWaitForConnect = ast_true(v->value);
01961          if(gMediaWaitForConnect)
01962             ooH323EpEnableMediaWaitForConnect();
01963          else 
01964             ooH323EpDisableMediaWaitForConnect();
01965       } 
01966       else if (!strcasecmp(v->name, "h245tunneling")) {
01967          gTunneling = ast_true(v->value);
01968          if(gTunneling)
01969             ooH323EpEnableH245Tunneling();
01970          else
01971             ooH323EpDisableH245Tunneling();
01972       }
01973       else if (!strcasecmp(v->name, "h323id")) {
01974          pNewAlias = malloc(sizeof(struct ooAliases));
01975          if(!pNewAlias){
01976             ast_log(LOG_ERROR, "Failed to allocate memory for h323id alias\n");
01977             return 1;
01978          }
01979          pNewAlias->type =  T_H225AliasAddress_h323_ID;
01980          pNewAlias->value = strdup(v->value);
01981          pNewAlias->next = gAliasList;
01982          gAliasList = pNewAlias;
01983          pNewAlias = NULL;
01984       }
01985       else if (!strcasecmp(v->name, "e164")) {
01986          pNewAlias = malloc(sizeof(struct ooAliases));
01987          if(!pNewAlias){
01988             ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n");
01989             return 1;
01990          }
01991          pNewAlias->type =  T_H225AliasAddress_dialedDigits;
01992          pNewAlias->value = strdup(v->value);
01993          pNewAlias->next = gAliasList;
01994          gAliasList = pNewAlias;
01995          pNewAlias = NULL;
01996       }
01997       else if (!strcasecmp(v->name, "email")) {
01998          pNewAlias = malloc(sizeof(struct ooAliases));
01999          if(!pNewAlias){
02000             ast_log(LOG_ERROR, "Failed to allocate memory for email alias\n");
02001             return 1;
02002          }
02003          pNewAlias->type =  T_H225AliasAddress_email_ID;
02004          pNewAlias->value = strdup(v->value);
02005          pNewAlias->next = gAliasList;
02006          gAliasList = pNewAlias;
02007          pNewAlias = NULL;
02008       }
02009       else if (!strcasecmp(v->name, "callerid")) {
02010          strncpy(gCallerID, v->value, sizeof(gCallerID)-1);
02011       }
02012       else if (!strcasecmp(v->name, "incominglimit")) {
02013          gIncomingLimit = atoi(v->value);
02014       }
02015       else if (!strcasecmp(v->name, "outgoinglimit")) {
02016          gOutgoingLimit = atoi(v->value);
02017       }
02018       else if (!strcasecmp(v->name, "gatekeeper")) {
02019          if (!strcasecmp(v->value, "DISABLE")) {
02020             gRasGkMode = RasNoGatekeeper;
02021          } 
02022          else if (!strcasecmp(v->value, "DISCOVER")) {
02023             gRasGkMode = RasDiscoverGatekeeper;
02024          } 
02025          else {
02026             gRasGkMode = RasUseSpecificGatekeeper;
02027             strncpy(gGatekeeper, v->value, sizeof(gGatekeeper)-1);
02028          }
02029       }
02030       else if (!strcasecmp(v->name, "logfile")) {
02031          strncpy(gLogFile, v->value, sizeof(gLogFile)-1);
02032       }
02033       else if (!strcasecmp(v->name, "context")) {
02034          strncpy(gContext, v->value, sizeof(gContext)-1);
02035          ast_verbose(VERBOSE_PREFIX_3 "  == Setting default context to %s\n", 
02036                                                       gContext);
02037       }
02038       else if (!strcasecmp(v->name, "rtptimeout")) {
02039          gRTPTimeout = atoi(v->value);
02040          if(gRTPTimeout <= 0)
02041             gRTPTimeout = 60;
02042       }
02043       else if (!strcasecmp(v->name, "tos")) {
02044          if (sscanf(v->value, "%i", &format) == 1)
02045             gTOS = format & 0xff;
02046          else if (!strcasecmp(v->value, "lowdelay"))
02047             gTOS = IPTOS_LOWDELAY;
02048          else if (!strcasecmp(v->value, "throughput"))
02049             gTOS = IPTOS_THROUGHPUT;
02050          else if (!strcasecmp(v->value, "reliability"))
02051             gTOS = IPTOS_RELIABILITY;
02052          else if (!strcasecmp(v->value, "mincost"))
02053             gTOS = IPTOS_MINCOST;
02054          else if (!strcasecmp(v->value, "none"))
02055             gTOS = 0;
02056          else
02057             ast_log(LOG_WARNING, "Invalid tos value at line %d, should be "
02058                                  "'lowdelay', 'throughput', 'reliability', "
02059                                  "'mincost', or 'none'\n", v->lineno);
02060       }
02061       else if(!strcasecmp(v->name, "amaflags")) {
02062          gAMAFLAGS = ast_cdr_amaflags2int(v->value);
02063       }
02064       else if(!strcasecmp(v->name, "accountcode")) {
02065          strncpy(gAccountcode, v->value, sizeof(gAccountcode)-1);
02066       }
02067       else if (!strcasecmp(v->name, "disallow")) {
02068          ast_parse_allow_disallow(&gPrefs, &gCapability, v->value, 0);
02069       }
02070       else if (!strcasecmp(v->name, "allow")) {
02071          const char* tcodecs = v->value;
02072          if(!strcasecmp(v->value, "all")) {
02073             tcodecs = "ulaw,alaw,g729,g723,gsm";
02074          }
02075          ast_parse_allow_disallow(&gPrefs, &gCapability, tcodecs, 1);
02076       }
02077       else if (!strcasecmp(v->name, "dtmfmode")) {
02078          if (!strcasecmp(v->value, "inband"))
02079             gDTMFMode=H323_DTMF_INBAND;
02080          else if (!strcasecmp(v->value, "rfc2833"))
02081             gDTMFMode = H323_DTMF_RFC2833;
02082          else if (!strcasecmp(v->value, "q931keypad"))
02083             gDTMFMode = H323_DTMF_Q931;
02084          else if (!strcasecmp(v->value, "h245alphanumeric"))
02085             gDTMFMode = H323_DTMF_H245ALPHANUMERIC;
02086          else if (!strcasecmp(v->value, "h245signal"))
02087             gDTMFMode = H323_DTMF_H245SIGNAL;
02088          else {
02089             ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n", 
02090                                                                     v->value);
02091             gDTMFMode = H323_DTMF_RFC2833;
02092          }
02093       }  
02094       v = v->next;
02095    }
02096    
02097    cat = ast_category_browse(cfg, NULL);
02098    while(cat) 
02099    {
02100       if(strcasecmp(cat, "general")) 
02101       {
02102          int friend_type = 0;
02103          utype = ast_variable_retrieve(cfg, cat, "type");
02104          if(utype)
02105          {
02106             friend_type = strcasecmp(utype, "friend");
02107             if(!strcmp(utype, "user") || 0 == friend_type)
02108             {
02109                user = build_user(cat, ast_variable_browse(cfg, cat));
02110                if (user) 
02111                {
02112                   ast_mutex_lock(&userl.lock);
02113                   user->next = userl.users;
02114                   userl.users = user;
02115                   ast_mutex_unlock(&userl.lock);
02116                }
02117                else {
02118                   ast_log(LOG_WARNING, "Failed to build user %s\n", cat);
02119                }
02120             }
02121             if(!strcasecmp(utype, "peer") || 0 == friend_type)
02122             {
02123                peer = build_peer(cat, ast_variable_browse(cfg, cat), friend_type);
02124                if(peer)
02125                {
02126                   ast_mutex_lock(&peerl.lock);
02127                   peer->next = peerl.peers;
02128                   peerl.peers = peer;
02129                   ast_mutex_unlock(&peerl.lock);
02130                }
02131                else {
02132                   ast_log(LOG_WARNING, "Failed to build peer %s\n", cat);
02133                }
02134             }
02135          }
02136       }
02137       cat = ast_category_browse(cfg, cat);
02138    }
02139    ast_config_destroy(cfg);
02140 
02141 
02142    /* Determine ip address if neccessary */
02143    if(!strlen(gIP))
02144    {
02145       ooGetLocalIPAddress(gIP);
02146       if(!strcmp(gIP, "127.0.0.1"))
02147       {
02148          ast_log(LOG_NOTICE, "Failed to determine local ip address. Please "
02149                             "specify it in ooh323.conf. OOH323 Disabled\n");
02150          return 1;
02151       }
02152    }
02153 
02154    if(gH323Debug)
02155       ast_verbose("+++   reload_config\n");
02156 
02157    return 0;
02158 
02159 }

static int restart_monitor ( void   ) 

Start the channel monitor thread.

Definition at line 2734 of file chan_ooh323.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pthread_create, ast_pthread_create_background, AST_PTHREADT_NULL, AST_PTHREADT_STOP, do_monitor(), LOG_ERROR, LOG_WARNING, monitor_thread, and monlock.

Referenced by dahdi_hangup(), dahdi_request(), h323_reload(), load_module(), mgcp_reload(), mgcp_request(), oh323_request(), ooh323_reload(), ooh323_request(), phone_hangup(), phone_request(), setup_dahdi(), sip_reload(), sip_request_call(), and skinny_request().

02735 {
02736    pthread_attr_t attr;
02737 
02738    /* If we're supposed to be stopped -- stay stopped */
02739    if (monitor_thread == AST_PTHREADT_STOP)
02740       return 0;
02741    if (ast_mutex_lock(&monlock)) {
02742       ast_log(LOG_WARNING, "Unable to lock monitor\n");
02743       return -1;
02744    }
02745    if (monitor_thread == pthread_self()) {
02746       ast_mutex_unlock(&monlock);
02747       ast_log(LOG_WARNING, "Cannot kill myself\n");
02748       return -1;
02749    }
02750    if (monitor_thread != AST_PTHREADT_NULL) {
02751       /* Wake up the thread */
02752       pthread_kill(monitor_thread, SIGURG);
02753    } 
02754    else {
02755       pthread_attr_init(&attr);
02756       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
02757       /* Start a new monitor */
02758       if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
02759          ast_mutex_unlock(&monlock);
02760          ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
02761          return -1;
02762       }
02763    }
02764    ast_mutex_unlock(&monlock);
02765    return 0;
02766 }

void setup_rtp_connection ( ooCallData *  call,
const char *  remoteIp,
int  remotePort 
)

Definition at line 3184 of file chan_ooh323.c.

References ast_log(), ast_rtp_set_peer(), ast_verbose(), find_call(), gH323Debug, LOG_ERROR, and ooh323_pvt::rtp.

03186 {
03187    struct ooh323_pvt *p = NULL;
03188    struct sockaddr_in them;
03189 
03190    if(gH323Debug)
03191       ast_verbose("---   setup_rtp_connection\n");
03192 
03193    /* Find the call or allocate a private structure if call not found */
03194    p = find_call(call); 
03195 
03196    if (!p) {
03197       ast_log(LOG_ERROR, "Something is wrong: rtp\n");
03198       return;
03199    }
03200 
03201    them.sin_family = AF_INET;
03202    them.sin_addr.s_addr = inet_addr(remoteIp); /* only works for IPv4 */
03203    them.sin_port = htons(remotePort);
03204    ast_rtp_set_peer(p->rtp, &them);
03205 
03206    if(gH323Debug)
03207       ast_verbose("+++   setup_rtp_connection\n");
03208 
03209    return;
03210 }

static int unload_module ( void   )  [static]

Definition at line 2904 of file chan_ooh323.c.

References ast_channel_unregister(), ast_cli_unregister(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_rtp_proto_unregister(), ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_verbose(), delete_peers(), delete_users(), free, gAliasList, gH323Debug, iflist, iflock, LOG_WARNING, monitor_thread, monlock, ooh323_pvt::next, ooh323_destroy(), ooh323c_stop_stack_thread(), and ooh323_pvt::owner.

02905 {
02906    struct ooh323_pvt *p;
02907    struct ooAliases *cur=NULL, *prev=NULL;
02908 
02909    if(gH323Debug) {
02910       ast_verbose("--- ooh323  unload_module \n");
02911    }
02912    /* First, take us out of the channel loop */
02913    ast_cli_unregister(&cli_show_users);
02914    ast_cli_unregister(&cli_show_user);
02915    ast_cli_unregister(&cli_show_peers);
02916    ast_cli_unregister(&cli_show_peer);
02917    ast_cli_unregister(&cli_show_config);
02918    ast_cli_unregister(&cli_debug);
02919    ast_cli_unregister(&cli_no_debug);
02920    ast_rtp_proto_unregister(&ooh323_rtp);
02921    ast_channel_unregister(&ooh323_tech);
02922    /* ast_unregister_atexit(&ast_ooh323c_exit); */
02923 
02924    if(gH323Debug) {
02925       ast_verbose("  unload_module - hanging up all interfaces\n");
02926    }
02927    if (!ast_mutex_lock(&iflock)) {
02928       /* Hangup all interfaces if they have an owner */
02929       p = iflist;
02930       while(p) {
02931          if (p->owner) {
02932             ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
02933          }
02934          p = p->next;
02935       }
02936       iflist = NULL;
02937       ast_mutex_unlock(&iflock);
02938    } 
02939    else {
02940       ast_log(LOG_WARNING, "Unable to lock the interface list\n");
02941       return -1;
02942    }
02943 
02944 
02945    if(gH323Debug) {
02946       ast_verbose("  unload_module - stopping monitor thread\n");
02947    }  
02948    if (monitor_thread != AST_PTHREADT_NULL)
02949    {
02950      if(!ast_mutex_lock(&monlock)) {
02951         if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
02952             pthread_cancel(monitor_thread);
02953             pthread_kill(monitor_thread, SIGURG);
02954             pthread_join(monitor_thread, NULL);
02955          }
02956          monitor_thread = AST_PTHREADT_STOP;
02957          ast_mutex_unlock(&monlock);
02958       } 
02959       else {
02960          ast_log(LOG_WARNING, "Unable to lock the monitor\n");
02961          return -1;
02962       }
02963    }
02964 
02965 
02966    if(gH323Debug) {
02967      ast_verbose("   unload_module - stopping stack thread\n");
02968    }
02969    ooh323c_stop_stack_thread();
02970 
02971 
02972    if(gH323Debug) {
02973       ast_verbose("  unload_module - freeing up memory used by interfaces\n");
02974    }
02975    if (!ast_mutex_lock(&iflock)) {
02976       struct ooh323_pvt *pl;
02977 
02978       /* Destroy all the interfaces and free their memory */
02979       p = iflist;
02980       while(p) {
02981          pl = p;
02982          p = p->next;
02983          /* Free associated memory */
02984          ooh323_destroy(pl);
02985       }
02986       iflist = NULL;
02987       ast_mutex_unlock(&iflock);
02988    } 
02989    else {
02990       ast_log(LOG_WARNING, "Unable to lock the interface list\n");
02991       return -1;
02992    }
02993  
02994 
02995    if(gH323Debug) {
02996       ast_verbose("  unload_module - deleting users\n");
02997    }
02998    delete_users();
02999 
03000 
03001    if(gH323Debug) {
03002       ast_verbose("  unload_module - deleting peers\n");
03003    }
03004    delete_peers();
03005 
03006 
03007    if(gH323Debug) {
03008       ast_verbose("  unload_module - Freeing up alias list\n");
03009    }
03010    cur = gAliasList;
03011    while(cur)
03012    {
03013      prev = cur;
03014      cur = cur->next;
03015      free(prev->value);
03016      free(prev);
03017    }
03018    gAliasList = NULL;
03019 
03020 
03021    if(gH323Debug) {
03022       ast_verbose("   unload_module- destroying OOH323 endpoint \n");
03023    }
03024    ooH323EpDestroy();
03025 
03026    if(gH323Debug) {
03027       ast_verbose("+++ ooh323  unload_module \n");   
03028    }
03029 
03030    return 0;
03031 }

int update_our_aliases ( ooCallData *  call,
struct ooh323_pvt *  p 
)

Definition at line 3239 of file chan_ooh323.c.

References ooh323_pvt::callee_dialedDigits, ooh323_pvt::callee_email, ooh323_pvt::callee_h323id, and ooh323_pvt::callee_url.

Referenced by ooh323_onReceivedSetup().

03240 {
03241    int updated = -1;
03242    ooAliases *psAlias=NULL;
03243    
03244    if(!call->ourAliases)
03245       return updated;
03246    psAlias = call->ourAliases;
03247    while(psAlias)
03248    {
03249       if(psAlias->type == T_H225AliasAddress_h323_ID)
03250       {
03251          strncpy(p->callee_h323id, psAlias->value, sizeof(p->callee_h323id)-1);
03252          updated = 1;
03253       }
03254       if(psAlias->type == T_H225AliasAddress_dialedDigits)
03255       {
03256          strncpy(p->callee_dialedDigits, psAlias->value, 
03257                                         sizeof(p->callee_dialedDigits)-1);
03258          updated = 1;
03259       }
03260       if(psAlias->type == T_H225AliasAddress_url_ID)
03261       {
03262          strncpy(p->callee_url, psAlias->value, sizeof(p->callee_url)-1);
03263          updated = 1;
03264       }
03265       if(psAlias->type == T_H225AliasAddress_email_ID)
03266       {
03267          strncpy(p->callee_email, psAlias->value, sizeof(p->callee_email)-1);
03268          updated = 1;
03269       }
03270       psAlias = psAlias->next;
03271    }
03272    return updated;
03273 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 3390 of file chan_ooh323.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 3390 of file chan_ooh323.c.

struct ast_cli_entry cli_debug [static]

Initial value:

   { { "ooh323", "debug", NULL }, ooh323_do_debug, "Enable OOH323 debugging", debug_usage }

Definition at line 2470 of file chan_ooh323.c.

struct ast_cli_entry cli_no_debug [static]

Initial value:

   { { "ooh323", "no", "debug", NULL }, ooh323_no_debug, "Disable OOH323 debugging", no_debug_usage }

Definition at line 2477 of file chan_ooh323.c.

struct ast_cli_entry cli_show_config [static]

Initial value:

   { { "ooh323", "show", "config", NULL }, ooh323_show_config, "Show details on global configuration of H.323 channel driver", show_config_usage }

Definition at line 2508 of file chan_ooh323.c.

struct ast_cli_entry cli_show_peer [static]

Initial value:

   { { "ooh323", "show", "peer", NULL }, ooh323_show_peer, "Show details on specific OOH323 peer", show_peer_usage }

Definition at line 2505 of file chan_ooh323.c.

struct ast_cli_entry cli_show_peers [static]

Initial value:

 
   { { "ooh323", "show", "peers", NULL }, ooh323_show_peers, "Show defined OOH323 peers", show_peers_usage }

Definition at line 2498 of file chan_ooh323.c.

struct ast_cli_entry cli_show_user [static]

Initial value:

   { { "ooh323", "show", "user", NULL }, ooh323_show_user, "Show details on specific OOH323 user", show_user_usage }

Definition at line 2491 of file chan_ooh323.c.

struct ast_cli_entry cli_show_users [static]

Initial value:

 
   { { "ooh323", "show", "users", NULL }, ooh323_show_users, "Show defined OOH323 users", show_users_usage }

Definition at line 2484 of file chan_ooh323.c.

const char config[] = "ooh323.conf" [static]

Definition at line 39 of file chan_ooh323.c.

Referenced by reload_config().

char debug_usage[] [static]

Initial value:

 
"Usage: ooh323 debug\n"
"       Enables debugging of OOH323 channel driver\n"

Definition at line 2466 of file chan_ooh323.c.

char gAccountcode[80] = DEFAULT_H323ACCNT [static]

struct ooAliases* gAliasList [static]

Definition at line 205 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), reload_config(), and unload_module().

int gAMAFLAGS [static]

char gCallerID[AST_MAX_EXTENSION] = DEFAULT_H323ID [static]

Definition at line 204 of file chan_ooh323.c.

Referenced by load_module(), ooh323_call(), ooh323_show_config(), and reload_config().

int gCapability = AST_FORMAT_ULAW [static]

char gContext[AST_MAX_EXTENSION] = DEFAULT_CONTEXT [static]

Definition at line 220 of file chan_ooh323.c.

Referenced by build_user(), ooh323_alloc(), ooh323_show_config(), and reload_config().

int gDTMFMode = H323_DTMF_RFC2833 [static]

int gFastStart = 1 [static]

Definition at line 213 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), and reload_config().

char gGatekeeper[100] [static]

Definition at line 209 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), and reload_config().

OOBOOL gH323Debug = FALSE

int gIncomingLimit = 4 [static]

Definition at line 221 of file chan_ooh323.c.

Referenced by reload_config().

char gIP[20] [static]

Definition at line 203 of file chan_ooh323.c.

Referenced by load_module(), ooh323_alloc(), ooh323_show_config(), and reload_config().

int gIsGateway = 0 [static]

Definition at line 212 of file chan_ooh323.c.

Referenced by load_module(), and reload_config().

char gLogFile[256] = DEFAULT_LOGFILE [static]

Definition at line 201 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), and reload_config().

int gMediaWaitForConnect = 0 [static]

Definition at line 215 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), and reload_config().

int gOutgoingLimit = 4 [static]

Definition at line 222 of file chan_ooh323.c.

Referenced by reload_config().

int gPort = 1720 [static]

Definition at line 202 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), and reload_config().

struct ast_codec_pref gPrefs [static]

enum RasGatekeeperMode gRasGkMode = RasNoGatekeeper [static]

Definition at line 210 of file chan_ooh323.c.

Referenced by load_module(), ooh323_alloc(), ooh323_show_config(), and reload_config().

int gRTPTimeout = 60 [static]

Definition at line 217 of file chan_ooh323.c.

Referenced by build_peer(), build_user(), and reload_config().

int gTOS = 0 [static]

Definition at line 216 of file chan_ooh323.c.

Referenced by ooh323_alloc(), and reload_config().

int gTunneling = 1 [static]

Definition at line 214 of file chan_ooh323.c.

Referenced by load_module(), ooh323_show_config(), and reload_config().

ast_mutex_t h323_reload_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]

Definition at line 187 of file chan_ooh323.c.

Referenced by do_monitor(), and ooh323_reload().

int h323_reloading = 0 [static]

Definition at line 186 of file chan_ooh323.c.

Referenced by do_monitor(), and ooh323_reload().

struct ooh323_pvt * iflist [static]

ast_mutex_t iflock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]

Definition at line 131 of file chan_ooh323.c.

Referenced by do_monitor(), find_call(), ooh323_alloc(), ooh323_request(), and unload_module().

struct io_context* io [static]

Definition at line 233 of file chan_ooh323.c.

pthread_t monitor_thread = AST_PTHREADT_NULL [static]

Definition at line 242 of file chan_ooh323.c.

Referenced by restart_monitor(), and unload_module().

ast_mutex_t monlock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]

Definition at line 237 of file chan_ooh323.c.

Referenced by do_monitor(), restart_monitor(), and unload_module().

char no_debug_usage[] [static]

Initial value:

 
"Usage: ooh323 no debug\n"
"       Disables debugging of OOH323 channel driver\n"

Definition at line 2473 of file chan_ooh323.c.

struct ooh323_config ooconfig [static]

struct ast_rtp_protocol ooh323_rtp [static]

Definition at line 84 of file chan_ooh323.c.

struct ast_channel_tech ooh323_tech [static]

Definition at line 65 of file chan_ooh323.c.

ast_mutex_t ooh323c_cmd_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]

struct ast_peer_list peerl [static]

struct sched_context* sched [static]

Asterisk RTP stuff

Definition at line 232 of file chan_ooh323.c.

char show_config_usage[] [static]

Initial value:

"Usage: ooh323 show config\n"
"       Shows global configuration of H.323 channel driver\n"

Definition at line 2462 of file chan_ooh323.c.

char show_peer_usage[] [static]

Initial value:

 
"Usage: ooh323 show peer <name> \n"
"       List details of specific OOH323 peer.\n"

Definition at line 2501 of file chan_ooh323.c.

char show_peers_usage[] [static]

Initial value:

 
"Usage: ooh323 show peers \n"
"       Lists all known OOH323 peers.\n"

Definition at line 2494 of file chan_ooh323.c.

char show_user_usage[] [static]

Initial value:

 
"Usage: ooh323 show user <name> \n"
"       List details of specific OOH323 user.\n"

Definition at line 2487 of file chan_ooh323.c.

char show_users_usage[] [static]

Initial value:

 
"Usage: ooh323 show users \n"
"       Lists all known OOH323 users.\n"

Definition at line 2480 of file chan_ooh323.c.

const char tdesc[] = "Objective Systems H323 Channel Driver" [static]

Definition at line 38 of file chan_ooh323.c.

const char type[] = "OOH323" [static]

Definition at line 37 of file chan_ooh323.c.

int usecnt = 0 [static]

Definition at line 190 of file chan_ooh323.c.

Referenced by ooh323_hangup(), and ooh323_new().

ast_mutex_t usecnt_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static]

Definition at line 191 of file chan_ooh323.c.

Referenced by ooh323_hangup(), and ooh323_new().

struct ast_user_list userl [static]


Generated on Fri Jul 3 20:37:19 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.9