[asterisk-addons-commits] tilghman: trunk r610 - in /trunk: cdr/cdr_addon_mysql.c channels/chan_ooh323.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Wed May 28 19:13:13 CDT 2008


Author: tilghman
Date: Wed May 28 19:13:13 2008
New Revision: 610

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=610
Log:
Whitespace changes only

Modified:
    trunk/cdr/cdr_addon_mysql.c
    trunk/channels/chan_ooh323.c

Modified: trunk/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/cdr/cdr_addon_mysql.c?view=diff&rev=610&r1=609&r2=610
==============================================================================
--- trunk/cdr/cdr_addon_mysql.c (original)
+++ trunk/cdr/cdr_addon_mysql.c Wed May 28 19:13:13 2008
@@ -457,7 +457,7 @@
 
 	res = 0;
 
-	res |= my_load_config_string(cfg, "global", "hostname",  &hostname, "localhost");
+	res |= my_load_config_string(cfg, "global", "hostname", &hostname, "localhost");
 	res |= my_load_config_string(cfg, "global", "dbname", &dbname, "astriskcdrdb");
 	res |= my_load_config_string(cfg, "global", "user", &dbuser, "root");
 	res |= my_load_config_string(cfg, "global", "sock", &dbsock, "");
@@ -561,7 +561,7 @@
 {
 	int ret;
 
-	ast_mutex_lock(&mysql_lock);    
+	ast_mutex_lock(&mysql_lock);
 	ret = my_load_module(1);
 	ast_mutex_unlock(&mysql_lock);
 

Modified: trunk/channels/chan_ooh323.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/channels/chan_ooh323.c?view=diff&rev=610&r1=609&r2=610
==============================================================================
--- trunk/channels/chan_ooh323.c (original)
+++ trunk/channels/chan_ooh323.c Wed May 28 19:13:13 2008
@@ -50,8 +50,7 @@
 static struct ast_frame *ooh323_read(struct ast_channel *ast);
 static int ooh323_write(struct ast_channel *ast, struct ast_frame *f);
 static int ooh323_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
-static int ooh323_fixup
-   (struct ast_channel *oldchan, struct ast_channel *newchan);
+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);
@@ -65,68 +64,68 @@
 #endif
 
 static const struct ast_channel_tech ooh323_tech = {
-   .type = type,
-   .description = tdesc,
-   .capabilities = -1,
-   .requester = ooh323_request,
-   .send_digit_begin = ooh323_digit_begin,
-   .send_digit_end = ooh323_digit_end,
-   .call = ooh323_call,
-   .hangup = ooh323_hangup,
-   .answer = ooh323_answer,
-   .read = ooh323_read,
-   .write = ooh323_write,
-   .exception = ooh323_read,
-   .indicate = ooh323_indicate,
-   .fixup = ooh323_fixup,
-   .send_html = 0,
-   .bridge = ast_rtp_bridge,
+	.type = type,
+	.description = tdesc,
+	.capabilities = -1,
+	.requester = ooh323_request,
+	.send_digit_begin = ooh323_digit_begin,
+	.send_digit_end = ooh323_digit_end,
+	.call = ooh323_call,
+	.hangup = ooh323_hangup,
+	.answer = ooh323_answer,
+	.read = ooh323_read,
+	.write = ooh323_write,
+	.exception = ooh323_read,
+	.indicate = ooh323_indicate,
+	.fixup = ooh323_fixup,
+	.send_html = 0,
+	.bridge = ast_rtp_bridge,
 };
 
 static struct ast_rtp_protocol ooh323_rtp = {
-   .type = type,
-   .get_rtp_info = ooh323_get_rtp_peer,
-   .get_vrtp_info = ooh323_get_vrtp_peer,
-   .set_rtp_peer = ooh323_set_rtp_peer
+	.type = type,
+	.get_rtp_info = ooh323_get_rtp_peer,
+	.get_vrtp_info = ooh323_get_vrtp_peer,
+	.set_rtp_peer = ooh323_set_rtp_peer
 };
 
 /* H.323 channel private structure */
 static struct ooh323_pvt {
-   ast_mutex_t lock;		/* Channel private lock */
-   struct ast_rtp *rtp;
-   struct ast_rtp *vrtp; /* Placeholder for now */
-   struct ast_channel *owner;	/* Master Channel */
-   time_t lastrtptx;
-   time_t lastrtprx;
-   unsigned int flags;
-   unsigned int call_reference;
-   char *callToken;
-   char *username;
-   char *host;
-   char *callerid_name;
-   char *callerid_num;
-   char caller_h323id[AST_MAX_EXTENSION];
-   char caller_dialedDigits[AST_MAX_EXTENSION];
-   char caller_email[AST_MAX_EXTENSION];
-   char caller_url[256];
-   char callee_h323id[AST_MAX_EXTENSION];
-   char callee_dialedDigits[AST_MAX_EXTENSION];
-   char callee_email[AST_MAX_EXTENSION];
-   char callee_url[AST_MAX_EXTENSION];
+	ast_mutex_t lock;		/* Channel private lock */
+	struct ast_rtp *rtp;
+	struct ast_rtp *vrtp; /* Placeholder for now */
+	struct ast_channel *owner;	/* Master Channel */
+	time_t lastrtptx;
+	time_t lastrtprx;
+	unsigned int flags;
+	unsigned int call_reference;
+	char *callToken;
+	char *username;
+	char *host;
+	char *callerid_name;
+	char *callerid_num;
+	char caller_h323id[AST_MAX_EXTENSION];
+	char caller_dialedDigits[AST_MAX_EXTENSION];
+	char caller_email[AST_MAX_EXTENSION];
+	char caller_url[256];
+	char callee_h323id[AST_MAX_EXTENSION];
+	char callee_dialedDigits[AST_MAX_EXTENSION];
+	char callee_email[AST_MAX_EXTENSION];
+	char callee_url[AST_MAX_EXTENSION];
  
-   int port;
-   int readformat;    /* negotiated read format */
-   int writeformat;  /* negotiated write format */
-   int capability;
-   struct ast_codec_pref prefs;
-   int dtmfmode;
-   char exten[AST_MAX_EXTENSION];	/* Requested extension */
-   char context[AST_MAX_EXTENSION];	/* Context where to start */
-   char accountcode[256];	/* Account code */
-   int nat;
-   int amaflags;
-   struct ast_dsp *vad;
-   struct ooh323_pvt *next;	/* Next entity */
+	int port;
+	int readformat;   /* negotiated read format */
+	int writeformat;  /* negotiated write format */
+	int capability;
+	struct ast_codec_pref prefs;
+	int dtmfmode;
+	char exten[AST_MAX_EXTENSION];	/* Requested extension */
+	char context[AST_MAX_EXTENSION];	/* Context where to start */
+	char accountcode[256];	/* Account code */
+	int nat;
+	int amaflags;
+	struct ast_dsp *vad;
+	struct ooh323_pvt *next;	/* Next entity */
 } *iflist = NULL;
 
 /* Protect the channel/interface list (ooh323_pvt) */
@@ -134,62 +133,62 @@
 
 /* Profile of H.323 user registered with PBX*/
 struct ooh323_user{
-   ast_mutex_t lock;
-   char        name[256];
-   char        context[AST_MAX_EXTENSION];
-   int         incominglimit;
-   unsigned    inUse;
-   char        accountcode[20];
-   int         amaflags;
-   int         capability;
-   struct ast_codec_pref prefs;
-   int         dtmfmode;
-   int         rtptimeout;
-   int         mUseIP;        /* Use IP address or H323-ID to search user */
-   char        mIP[20];
-   struct ooh323_user *next;
+	ast_mutex_t lock;
+	char        name[256];
+	char        context[AST_MAX_EXTENSION];
+	int         incominglimit;
+	unsigned    inUse;
+	char        accountcode[20];
+	int         amaflags;
+	int         capability;
+	struct ast_codec_pref prefs;
+	int         dtmfmode;
+	int         rtptimeout;
+	int         mUseIP;        /* Use IP address or H323-ID to search user */
+	char        mIP[20];
+	struct ooh323_user *next;
 };
 
 /* Profile of valid asterisk peers */
 struct ooh323_peer{
-   ast_mutex_t lock;
-   char        name[256];
-   unsigned    outgoinglimit;
-   unsigned    outUse;
-   int         capability;
-   struct ast_codec_pref prefs;
-   char        accountcode[20];
-   int         amaflags;
-   int         dtmfmode;
-   int         mFriend;    /* indicates defined as friend */
-   char        ip[20];
-   int         port;
-   char        *h323id;    /* H323-ID alias, which asterisk will register with gk to reach this peer*/
-   char        *email;     /* Email alias, which asterisk will register with gk to reach this peer*/
-   char        *url;       /* url alias, which asterisk will register with gk to reach this peer*/
-   char        *e164;      /* e164 alias, which asterisk will register with gk to reach this peer*/
-   int         rtptimeout;
-   struct ooh323_peer *next;
+	ast_mutex_t lock;
+	char        name[256];
+	unsigned    outgoinglimit;
+	unsigned    outUse;
+	int         capability;
+	struct ast_codec_pref prefs;
+	char        accountcode[20];
+	int         amaflags;
+	int         dtmfmode;
+	int         mFriend;    /* indicates defined as friend */
+	char        ip[20];
+	int         port;
+	char        *h323id;    /* H323-ID alias, which asterisk will register with gk to reach this peer*/
+	char        *email;     /* Email alias, which asterisk will register with gk to reach this peer*/
+	char        *url;       /* url alias, which asterisk will register with gk to reach this peer*/
+	char        *e164;      /* e164 alias, which asterisk will register with gk to reach this peer*/
+	int         rtptimeout;
+	struct ooh323_peer *next;
 };
 
 
 /* List of H.323 users known to PBX */
 static struct ast_user_list {
-   struct ooh323_user *users;
-   ast_mutex_t lock;
+	struct ooh323_user *users;
+	ast_mutex_t lock;
 } userl;
 
 static struct ast_peer_list {
-   struct ooh323_peer *peers;
-  ast_mutex_t lock;
-}peerl;
+	struct ooh323_peer *peers;
+	ast_mutex_t lock;
+} peerl;
 
 /* Mutex to protect H.323 reload process */
 static int h323_reloading = 0;
 AST_MUTEX_DEFINE_STATIC(h323_reload_lock);
 
 /* Mutex to protect usage counter */
-static int usecnt =0;
+static int usecnt = 0;
 AST_MUTEX_DEFINE_STATIC(usecnt_lock);
 
 AST_MUTEX_DEFINE_STATIC(ooh323c_cmd_lock);
@@ -228,7 +227,7 @@
 {
    int  mTCPPortStart;
    int  mTCPPortEnd;
-}ooconfig;
+} ooconfig;
 
 /** Asterisk RTP stuff*/
 static struct sched_context *sched;
@@ -247,882 +246,805 @@
 static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
                                              const char *host) 
 {
-   struct ast_channel *ch = NULL;
-   int fmt;
-   if(gH323Debug)
-      ast_verbose("---   ooh323_new - %s\n", host);
-
-
-   /* Don't hold a h323 pvt lock while we allocate a channel */
-   ast_mutex_unlock(&i->lock);
-   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);
-   ast_mutex_lock(&i->lock);
-
-   if(ch)
-   {
-      ast_channel_lock(ch);
-      ch->tech = &ooh323_tech;
-
-      ch->nativeformats = i->capability;
-
-
-      fmt = ast_best_codec(ch->nativeformats);
-
-      ch->fds[0] = ast_rtp_fd(i->rtp);
-      ch->fds[1] = ast_rtcp_fd(i->rtp);
-
-      if (state == AST_STATE_RING)
-         ch->rings = 1;
-
-      ch->adsicpe = AST_ADSI_UNAVAILABLE;
-      ch->writeformat = fmt;
-      ch->rawwriteformat = fmt;
-      ch->readformat = fmt;
-      ch->rawreadformat = fmt;
-      ch->tech_pvt = i;
-      i->owner = ch;
-
-      /* Allocate dsp for in-band DTMF support */
-      if(i->dtmfmode & H323_DTMF_INBAND) {
-         i->vad = ast_dsp_new();
-         ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
-      }
-
-      ast_mutex_lock(&usecnt_lock);
-      usecnt++;
-      ast_mutex_unlock(&usecnt_lock);
-
-      /* Notify the module monitors that use count for resource has changed*/
-      ast_update_use_count();
-
-      strncpy(ch->context, i->context, sizeof(ch->context)-1);
-      ch->context[sizeof(ch->context)-1] = '\0';
-      strncpy(ch->exten, i->exten, sizeof(ch->exten)-1);
-      ch->exten[sizeof(ch->exten)-1] = '\0';
-
-      ch->priority = 1;
-      if (i->callerid_name)
-      {
-         ch->cid.cid_name = strdup(i->callerid_name);
-      }
-      if(i->callerid_num){
-
-         ch->cid.cid_num = strdup(i->callerid_num);
-      }
-
-      if(!ast_test_flag(i, H323_OUTGOING))
-      {
-      
-         if (!ast_strlen_zero(i->caller_h323id)) {
-            pbx_builtin_setvar_helper(ch, "_CALLER_H323ID", i->caller_h323id);
-
-         }
-         if (!ast_strlen_zero(i->caller_dialedDigits)) {
-            pbx_builtin_setvar_helper(ch, "_CALLER_H323DIALEDDIGITS", 
-                                                       i->caller_dialedDigits);
-         }
-         if (!ast_strlen_zero(i->caller_email)) {
-            pbx_builtin_setvar_helper(ch, "_CALLER_H323EMAIL", 
-                                                              i->caller_email);
-         }
-         if (!ast_strlen_zero(i->caller_url)) {
-            pbx_builtin_setvar_helper(ch, "_CALLER_H323URL", i->caller_url);
-         }
-      }
-
-      if (!ast_strlen_zero(i->accountcode))
-         ast_string_field_set(ch, accountcode, i->accountcode);
-      
-      if (i->amaflags)
-         ch->amaflags = i->amaflags;
-
-      ast_setstate(ch, state);
-      if (state != AST_STATE_DOWN) {
-         if (ast_pbx_start(ch)) {
-            ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
-            ast_channel_unlock(ch);
-            ast_hangup(ch);
-            ch = NULL;
-         }
-      }
-   } else
-      ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
-
-
-   if(ch)   ast_channel_unlock(ch);
-
-   if(gH323Debug)
-      ast_verbose("+++   h323_new\n");
-
-   return ch;
+	struct ast_channel *ch = NULL;
+	int fmt;
+	if (gH323Debug)
+		ast_verbose("---   ooh323_new - %s\n", host);
+
+
+	/* Don't hold a h323 pvt lock while we allocate a channel */
+	ast_mutex_unlock(&i->lock);
+	ch = ast_channel_alloc(1, state, i->callerid_num, i->callerid_name, i->accountcode, i->exten, i->context, i->amaflags, "OOH323/%s-%08x", host, i & 0xffffffff);
+	ast_mutex_lock(&i->lock);
+
+	if (ch) {
+		ast_channel_lock(ch);
+		ch->tech = &ooh323_tech;
+
+		ch->nativeformats = i->capability;
+
+		fmt = ast_best_codec(ch->nativeformats);
+
+		ch->fds[0] = ast_rtp_fd(i->rtp);
+		ch->fds[1] = ast_rtcp_fd(i->rtp);
+
+		if (state == AST_STATE_RING)
+			ch->rings = 1;
+
+		ch->adsicpe = AST_ADSI_UNAVAILABLE;
+		ch->writeformat = fmt;
+		ch->rawwriteformat = fmt;
+		ch->readformat = fmt;
+		ch->rawreadformat = fmt;
+		ch->tech_pvt = i;
+		i->owner = ch;
+
+		/* Allocate dsp for in-band DTMF support */
+		if (i->dtmfmode & H323_DTMF_INBAND) {
+			i->vad = ast_dsp_new();
+			ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
+		}
+
+		ast_mutex_lock(&usecnt_lock);
+		usecnt++;
+		ast_mutex_unlock(&usecnt_lock);
+
+		/* Notify the module monitors that use count for resource has changed*/
+		ast_update_use_count();
+
+		ast_copy_string(ch->context, i->context, sizeof(ch->context));
+		ast_copy_string(ch->exten, i->exten, sizeof(ch->exten));
+
+		ch->priority = 1;
+		if (i->callerid_name) {
+			ch->cid.cid_name = strdup(i->callerid_name);
+		}
+		if (i->callerid_num) {
+
+			ch->cid.cid_num = strdup(i->callerid_num);
+		}
+
+		if (!ast_test_flag(i, H323_OUTGOING)) {
+		
+			if (!ast_strlen_zero(i->caller_h323id)) {
+				pbx_builtin_setvar_helper(ch, "_CALLER_H323ID", i->caller_h323id);
+
+			}
+			if (!ast_strlen_zero(i->caller_dialedDigits)) {
+				pbx_builtin_setvar_helper(ch, "_CALLER_H323DIALEDDIGITS", 
+				i->caller_dialedDigits);
+			}
+			if (!ast_strlen_zero(i->caller_email)) {
+				pbx_builtin_setvar_helper(ch, "_CALLER_H323EMAIL", 
+				i->caller_email);
+			}
+			if (!ast_strlen_zero(i->caller_url)) {
+				pbx_builtin_setvar_helper(ch, "_CALLER_H323URL", i->caller_url);
+			}
+		}
+
+		if (!ast_strlen_zero(i->accountcode))
+			ast_string_field_set(ch, accountcode, i->accountcode);
+		
+		if (i->amaflags)
+			ch->amaflags = i->amaflags;
+
+		ast_setstate(ch, state);
+		if (state != AST_STATE_DOWN) {
+			if (ast_pbx_start(ch)) {
+				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
+				ast_channel_unlock(ch);
+				ast_hangup(ch);
+				ch = NULL;
+			}
+		}
+	} else
+		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
+
+
+	if (ch)
+		ast_channel_unlock(ch);
+
+	if (gH323Debug)
+		ast_verbose("+++   h323_new\n");
+
+	return ch;
 }
 
 
 
 static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken) 
 {
-   struct ooh323_pvt *pvt = NULL;
-   struct in_addr ipAddr;
-   if(gH323Debug)
-      ast_verbose("---   ooh323_alloc\n");
-
-   pvt = (struct ooh323_pvt*) malloc(sizeof(struct ooh323_pvt));
-   if(!pvt)
-   {
-      ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
-      return NULL;
-   }
-
-   memset(pvt, 0, sizeof(struct ooh323_pvt));
-   ast_mutex_init(&pvt->lock);
-   ast_mutex_lock(&pvt->lock);
-
-
-   pvt->caller_h323id[0]='\0';
-   pvt->caller_dialedDigits[0]='\0';
-   pvt->caller_email[0]='\0';
-   pvt->caller_url[0]='\0';
-   pvt->vrtp = NULL;   
-   pvt->callee_h323id[0]='\0';
-   pvt->callee_dialedDigits[0]='\0';
-   pvt->callee_email[0] = '\0';
-   pvt->callee_url[0] = '\0';
-
-   pvt->host = NULL;
-   pvt->callToken = NULL;
-   pvt->port = 0;
-   pvt->vad = NULL;
-   pvt->next = NULL;
-   pvt->owner = NULL;
-   pvt->callerid_name = NULL;
-   pvt->callerid_num = NULL;
-   pvt->flags = 0;
-   if(!inet_aton(gIP, &ipAddr))
-   {
-      ast_log(LOG_ERROR, "Invalid OOH323 driver ip address\n");
-      ast_mutex_unlock(&pvt->lock);
-      ast_mutex_destroy(&pvt->lock);
-      free(pvt);
-      return NULL;
-   }
-   
-
-   pvt->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, ipAddr);
-
-   if (!pvt->rtp) 
-   {
-      ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", 
-              strerror(errno));
-      ast_mutex_unlock(&pvt->lock);
-      ast_mutex_destroy(&pvt->lock);
-      free(pvt);
-      return NULL;
-   }
+	struct ooh323_pvt *pvt = NULL;
+	struct in_addr ipAddr;
+	if (gH323Debug)
+		ast_verbose("---   ooh323_alloc\n");
+
+	if (!(pvt = ast_calloc(1, sizeof(*pvt)))) {
+		ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
+		return NULL;
+	}
+
+	ast_mutex_init(&pvt->lock);
+	ast_mutex_lock(&pvt->lock);
+
+	if (!inet_aton(gIP, &ipAddr)) {
+		ast_log(LOG_ERROR, "Invalid OOH323 driver ip address\n");
+		ast_mutex_unlock(&pvt->lock);
+		ast_mutex_destroy(&pvt->lock);
+		free(pvt);
+		return NULL;
+	}
+
+	if (!(pvt->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, ipAddr))) {
+		ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", 
+				  strerror(errno));
+		ast_mutex_unlock(&pvt->lock);
+		ast_mutex_destroy(&pvt->lock);
+		free(pvt);
+		return NULL;
+	}
  
-   ast_rtp_setqos(pvt->rtp, gTOS, 0, "ooh323");
-
-
-   pvt->call_reference = callref;
-   if(callToken)
-      pvt->callToken = strdup(callToken);
-
-   /* whether to use gk for this call */
-   if(gRasGkMode == RasNoGatekeeper)
-      OO_SETFLAG(pvt->flags, H323_DISABLEGK);
-
-   pvt->dtmfmode = gDTMFMode;
-   strncpy(pvt->context, gContext, sizeof(pvt->context)-1);
-   pvt->exten[0]='\0';
-   strncpy(pvt->accountcode, gAccountcode, sizeof(pvt->accountcode)-1);
-   pvt->amaflags = gAMAFLAGS;
-   pvt->capability = gCapability;
-   memcpy(&pvt->prefs, &gPrefs, sizeof(struct ast_codec_pref));
-
-
-  ast_mutex_unlock(&pvt->lock); 
-  /* Add to interface list */
-  ast_mutex_lock(&iflock);
-  pvt->next = iflist;
-  iflist = pvt;
-  ast_mutex_unlock(&iflock);
-
-  if(gH323Debug)
-    ast_verbose("+++   ooh323_alloc\n");
-
-  return pvt;
+	ast_rtp_setqos(pvt->rtp, gTOS, 0, "ooh323");
+
+	pvt->call_reference = callref;
+	if (callToken)
+		pvt->callToken = strdup(callToken);
+
+	/* whether to use gk for this call */
+	if (gRasGkMode == RasNoGatekeeper)
+		OO_SETFLAG(pvt->flags, H323_DISABLEGK);
+
+	pvt->dtmfmode = gDTMFMode;
+	ast_copy_string(pvt->context, gContext, sizeof(pvt->context));
+	ast_copy_string(pvt->accountcode, gAccountcode, sizeof(pvt->accountcode));
+	pvt->amaflags = gAMAFLAGS;
+	pvt->capability = gCapability;
+	memcpy(&pvt->prefs, &gPrefs, sizeof(pvt->prefs));
+
+	ast_mutex_unlock(&pvt->lock); 
+	/* Add to interface list */
+	ast_mutex_lock(&iflock);
+	pvt->next = iflist;
+	iflist = pvt;
+	ast_mutex_unlock(&iflock);
+
+	if (gH323Debug)
+		ast_verbose("+++   ooh323_alloc\n");
+
+	return pvt;
 }
 
 
 /*
-   Possible data values - peername, exten/peername, exten at ip
+	Possible data values - peername, exten/peername, exten at ip
  */
 static struct ast_channel *ooh323_request(const char *type, int format, 
-                                        void *data, int *cause)
-
-{
-   struct ast_channel *chan=NULL;
-   struct ooh323_pvt *p = NULL;
-   struct ooh323_peer *peer = NULL;
-   char *dest = NULL; 
-   char *ext = NULL;
-   char tmp[256];
-   char formats[512];
-   int oldformat;
-   char *sport = NULL;
-   int port = 0;
-
-   if(gH323Debug)
-      ast_verbose("---   ooh323_request - data %s format %s\n", (char*)data,  
-                              ast_getformatname_multiple(formats,512,format) );
-
-   oldformat = format;
-   format &= AST_FORMAT_AUDIO_MASK;
-   if (!format) {
-      ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format "
-                          "'%d'\n", format);
-      return NULL;
-   }
-
-   p = ooh323_alloc(0,0); /* Initial callRef is zero */
-
-   if(!p)
-   {
-      ast_log(LOG_WARNING, "Unable to build pvt data for '%s'\n", (char*)data);
-      return NULL;
-   }
-   ast_mutex_lock(&p->lock);
-
-   /* This is an outgoing call, since ooh323_request is called */
-   ast_set_flag(p, H323_OUTGOING);
-
-
-   strncpy(tmp, (char*)data, sizeof(tmp)-1);
-
-   dest = strchr(tmp, '/');
-
-   if(dest)
-   {  
-      *dest = '\0';
-      dest++;
-      ext = tmp;
-   }
-   else if((dest = strchr(tmp, '@'))) {
-      *dest = '\0';
-      dest++;
-      ext = tmp;
-   }
-   else {
-      dest = tmp;
-      ext = NULL;
-   }
-   
-   /*if((sport = strchr(dest, ':'))) {
-      *sport = '\0';
-      sport++;
-      port = atoi(sport);
-   }*/
-
-   if(dest) {
-      peer = find_peer(dest, port);
-   }
-   else{
-      ast_log(LOG_ERROR, "Destination format is not supported\n");
-      return NULL;
-   }
-
-   if(peer)
-   {
-      p->username = strdup(peer->name);
-      p->host = strdup(peer->ip);
-      p->port = peer->port;
-      /* Disable gk as we are going to call a known peer*/
-      OO_SETFLAG(p->flags, H323_DISABLEGK);
-
-      if(ext)
-         strncpy(p->exten, ext, sizeof(p->exten)-1);
-
-      if(peer->capability & format)
-         p->capability = peer->capability & format;
-      else{
-        p->capability = peer->capability;
-      }
-      memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
-      p->dtmfmode = peer->dtmfmode;
-      strncpy(p->accountcode, peer->accountcode, sizeof(p->accountcode)-1);
-      p->amaflags = peer->amaflags;
-   }
-   else {
-      p->dtmfmode = gDTMFMode;
-      p->capability = gCapability;
-
-      memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
-      p->username = strdup(dest);
-
-     
-      p->host = strdup(dest);
-      if(port > 0) {
-         p->port = port;
-      }
-      if(ext) {
-         strncpy(p->exten, ext, sizeof(p->exten)-1);
-      }
-   }
-
-
-   chan = ooh323_new(p, AST_STATE_DOWN, p->username);
-   
-   ast_mutex_unlock(&p->lock);
-
-   if (!chan)
-   {
-      ast_mutex_lock(&iflock);
-      ooh323_destroy(p);
-      ast_mutex_unlock(&iflock);
-   }
-
-   restart_monitor();
-   if(gH323Debug)
-      ast_verbose("+++   ooh323_request\n");
-
-   return chan;
+													 void *data, int *cause)
+{
+	struct ast_channel *chan = NULL;
+	struct ooh323_pvt *p = NULL;
+	struct ooh323_peer *peer = NULL;
+	char *dest = NULL; 
+	char *ext = NULL;
+	char tmp[256];
+	char formats[512];
+	int oldformat;
+	char *sport = NULL;
+	int port = 0;
+
+	if (gH323Debug)
+		ast_verbose("---   ooh323_request - data %s format %s\n", (char*)data,  
+										ast_getformatname_multiple(formats,512,format));
+
+	oldformat = format;
+	format &= AST_FORMAT_AUDIO_MASK;
+	if (!format) {
+		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format "
+								  "'%d'\n", format);
+		return NULL;
+	}
+
+	p = ooh323_alloc(0,0); /* Initial callRef is zero */
+
+	if (!p) {
+		ast_log(LOG_WARNING, "Unable to build pvt data for '%s'\n", (char*)data);
+		return NULL;
+	}
+	ast_mutex_lock(&p->lock);
+
+	/* This is an outgoing call, since ooh323_request is called */
+	ast_set_flag(p, H323_OUTGOING);
+
+	ast_copy_string(tmp, data, sizeof(data));
+
+	dest = strchr(tmp, '/');
+
+	if (dest) {  
+		*dest = '\0';
+		dest++;
+		ext = tmp;
+	} else if ((dest = strchr(tmp, '@'))) {
+		*dest = '\0';
+		dest++;
+		ext = tmp;
+	} else {
+		dest = tmp;
+		ext = NULL;
+	}
+
+#if 0
+	if ((sport = strchr(dest, ':'))) {
+		*sport = '\0';
+		sport++;
+		port = atoi(sport);
+	}
+#endif
+
+	if (dest) {
+		peer = find_peer(dest, port);
+	} else{
+		ast_log(LOG_ERROR, "Destination format is not supported\n");
+		return NULL;
+	}
+
+	if (peer) {
+		p->username = strdup(peer->name);
+		p->host = strdup(peer->ip);
+		p->port = peer->port;
+		/* Disable gk as we are going to call a known peer*/
+		OO_SETFLAG(p->flags, H323_DISABLEGK);
+
+		if (ext)
+			ast_copy_string(p->exten, ext, sizeof(p->exten));
+
+		if (peer->capability & format) {
+			p->capability = peer->capability & format;
+		} else {
+		  p->capability = peer->capability;
+		}
+		memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
+		p->dtmfmode = peer->dtmfmode;
+		ast_copy_string(p->accountcode, peer->accountcode, sizeof(p->accountcode));
+		p->amaflags = peer->amaflags;
+	} else {
+		p->dtmfmode = gDTMFMode;
+		p->capability = gCapability;
+
+		memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
+		p->username = strdup(dest);
+
+		p->host = strdup(dest);
+		if (port > 0) {
+			p->port = port;
+		}
+		if (ext) {
+			ast_copy_string(p->exten, ext, sizeof(p->exten));
+		}
+	}
+
+
+	chan = ooh323_new(p, AST_STATE_DOWN, p->username);
+	
+	ast_mutex_unlock(&p->lock);
+
+	if (!chan) {
+		ast_mutex_lock(&iflock);
+		ooh323_destroy(p);
+		ast_mutex_unlock(&iflock);
+	}
+
+	restart_monitor();
+	if (gH323Debug)
+		ast_verbose("+++   ooh323_request\n");
+
+	return chan;
 
 }
 
 
 static struct ooh323_pvt* find_call(ooCallData *call)
 {
-   struct ooh323_pvt *p=NULL;
-
-   if(gH323Debug)
-      ast_verbose("---   find_call\n");
-
-   p = iflist;
-   ast_mutex_lock(&iflock);
-
-   while(p)
-   {
-      if(p->callToken && !strcmp(p->callToken, call->callToken))
-      {
-         break;
-      }
-      p = p->next;
-      
-   }
-   ast_mutex_unlock(&iflock);
-
-   if(gH323Debug)
-      ast_verbose("+++   find_call\n");
-
-   return p;
+	struct ooh323_pvt *p;
+
+	if (gH323Debug)
+		ast_verbose("---   find_call\n");
+
+	ast_mutex_lock(&iflock);
+
+	for (p = iflist; p; p = p->next) {
+		if (p->callToken && !strcmp(p->callToken, call->callToken)) {
+			break;
+		}
+	}
+	ast_mutex_unlock(&iflock);
+
+	if (gH323Debug)
+		ast_verbose("+++   find_call\n");
+
+	return p;
 }
 
 struct ooh323_user *find_user(const char * name, const char* ip)
 {
-   struct ooh323_user *user=NULL;
-
-   if(gH323Debug)
-      ast_verbose("---   find_user\n");
-
-   user = userl.users;
-   ast_mutex_lock(&userl.lock);
-   while(user)
-   {
-      if(ip && user->mUseIP && !strcmp(user->mIP, ip)) {
-         break;
-      }
-      if(name && !strcmp(user->name, name)) {
-         break;
-      }
-      user = user->next;
-   }
-   ast_mutex_unlock(&userl.lock);
-
-   if(gH323Debug)
-      ast_verbose("+++   find_user\n");
-
-   return user;      
+	struct ooh323_user *user;
+
+	if (gH323Debug)
+		ast_verbose("---   find_user\n");
+
+	ast_mutex_lock(&userl.lock);
+	for (user = userl.users; user; user = user->next) {
+		if (ip && user->mUseIP && !strcmp(user->mIP, ip)) {
+			break;
+		}
+		if (name && !strcmp(user->name, name)) {
+			break;
+		}
+	}
+	ast_mutex_unlock(&userl.lock);
+
+	if (gH323Debug)
+		ast_verbose("+++   find_user\n");
+
+	return user;
 }
 
 struct ooh323_peer *find_friend(const char *name, int port)
 {
-   struct ooh323_peer *peer=NULL;  
-
-   if(gH323Debug)
-      ast_verbose("---   find_friend \"%s\"\n", name);
-
-
-   peer = peerl.peers;
-   ast_mutex_lock(&peerl.lock);
-   while(peer)
-   {
-      if(gH323Debug) {
-         ast_verbose("      comparing with \"%s\"\n", peer->ip);
-      }
-      if(!strcmp(peer->ip, name)) {
-         if(port > 0 && peer->port == port) { break; }
-         else if (port <= 0) { break; }
-      }
-      peer = peer->next;
-   }
-   ast_mutex_unlock(&peerl.lock);
-
-   if(gH323Debug) {
-      if(peer) {
-         ast_verbose("      found matching friend\n");
-      }
-      ast_verbose("+++   find_friend \"%s\"\n", name);
-   }
-
-   return peer;      
+	struct ooh323_peer *peer;  
+
+	if (gH323Debug)
+		ast_verbose("---   find_friend \"%s\"\n", name);
+
+
+	ast_mutex_lock(&peerl.lock);
+	for (peer = peerl.peers; peer; peer = peer->next) {
+		if (gH323Debug) {
+			ast_verbose("		comparing with \"%s\"\n", peer->ip);
+		}
+		if (!strcmp(peer->ip, name)) {
+			if (port <= 0 || (port > 0 && peer->port == port)) {
+				break;
+			}
+		}
+	}
+	ast_mutex_unlock(&peerl.lock);
+
+	if (gH323Debug) {
+		if (peer) {
+			ast_verbose("		found matching friend\n");
+		}
+		ast_verbose("+++   find_friend \"%s\"\n", name);
+	}
+
+	return peer;		
 }
 
 
 struct ooh323_peer *find_peer(const char * name, int port)
 {
-   struct ooh323_peer *peer=NULL;
-
-   if(gH323Debug)
-      ast_verbose("---   find_peer \"%s\"\n", name);
-
-
-   peer = peerl.peers;
-   ast_mutex_lock(&peerl.lock);
-   while(peer)
-   {
-      if(gH323Debug) {
-         ast_verbose("      comparing with \"%s\"\n", peer->ip);
-      }
-      if(!strcasecmp(peer->name, name))
-         break;
-      if(peer->h323id && !strcasecmp(peer->h323id, name))
-         break;
-      if(peer->e164 && !strcasecmp(peer->e164, name))
-         break;
-      /*
-      if(!strcmp(peer->ip, name)) {
-         if(port > 0 && peer->port == port) { break; }
-         else if (port <= 0) { break; }
-      }
-      */
-      peer = peer->next;
-   }
-   ast_mutex_unlock(&peerl.lock);
-
-   if(gH323Debug) {
-      if(peer) {
-         ast_verbose("      found matching peer\n");
-      }
-      ast_verbose("+++   find_peer \"%s\"\n", name);
-   }
-
-   return peer;      
+	struct ooh323_peer *peer;
+
+	if (gH323Debug)
+		ast_verbose("---   find_peer \"%s\"\n", name);
+
+	ast_mutex_lock(&peerl.lock);
+	for (peer = peerl.peers; peer; peer = peer->next) {
+		if (gH323Debug) {
+			ast_verbose("		comparing with \"%s\"\n", peer->ip);
+		}
+		if (!strcasecmp(peer->name, name))
+			break;
+		if (peer->h323id && !strcasecmp(peer->h323id, name))
+			break;
+		if (peer->e164 && !strcasecmp(peer->e164, name))
+			break;
+		/*
+		if (!strcmp(peer->ip, name)) {
+			if (port > 0 && peer->port == port) { break; }
+			else if (port <= 0) { break; }
+		}
+		*/
+	}
+	ast_mutex_unlock(&peerl.lock);
+
+	if (gH323Debug) {
+		if (peer) {
+			ast_verbose("		found matching peer\n");
+		}
+		ast_verbose("+++   find_peer \"%s\"\n", name);
+	}
+
+	return peer;		
 }
 
 static int ooh323_digit_begin(struct ast_channel *chan, char digit)
 {
-   char dtmf[2];
-   struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
-   
-   if(gH323Debug)
-      ast_verbose("---   ooh323_digit_begin\n");
-
-   if(!p){
-      ast_log(LOG_ERROR, "No private structure for call\n");
-      return -1;
-   }
-   ast_mutex_lock(&p->lock);
-   if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
-      ast_rtp_senddigit_begin(p->rtp, digit);
-   }
-   else if (((p->dtmfmode & H323_DTMF_Q931) ||
-                   (p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) ||
-                   (p->dtmfmode & H323_DTMF_H245SIGNAL))){
-      dtmf[0]= digit;
-      dtmf[1]='\0';
-      ast_mutex_lock(&ooh323c_cmd_lock);
-      ooSendDTMFDigit(p->callToken, dtmf);
-      ast_mutex_unlock(&ooh323c_cmd_lock);
-   }
-   ast_mutex_unlock(&p->lock);
-   if(gH323Debug)
-      ast_verbose("+++   ooh323_digit_begin\n");
-
-   return 0;
+	char dtmf[2];
+	struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
+	
+	if (gH323Debug)
+		ast_verbose("---   ooh323_digit_begin\n");
+
+	if (!p) {
+		ast_log(LOG_ERROR, "No private structure for call\n");
+		return -1;
+	}
+	ast_mutex_lock(&p->lock);
+	if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
+		ast_rtp_senddigit_begin(p->rtp, digit);
+	} else if (((p->dtmfmode & H323_DTMF_Q931) ||
+						 (p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) ||
+						 (p->dtmfmode & H323_DTMF_H245SIGNAL))) {
+		dtmf[0] = digit;
+		dtmf[1] = '\0';
+		ast_mutex_lock(&ooh323c_cmd_lock);
+		ooSendDTMFDigit(p->callToken, dtmf);
+		ast_mutex_unlock(&ooh323c_cmd_lock);
+	}
+	ast_mutex_unlock(&p->lock);
+	if (gH323Debug)
+		ast_verbose("+++   ooh323_digit_begin\n");
+
+	return 0;
 }
 
 static int ooh323_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
 {
-   struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
-
-   if(gH323Debug)
-      ast_verbose("---   ooh323_digit_end\n");
-
-   if(!p){
-      ast_log(LOG_ERROR, "No private structure for call\n");
-      return -1;
-   }
-   ast_mutex_lock(&p->lock);
-   if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) 
-      ast_rtp_senddigit_end(p->rtp, digit);
-
-   ast_mutex_unlock(&p->lock);
-   if(gH323Debug)
-      ast_verbose("+++   ooh323_digit_end\n");
-
-   return 0;
+	struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
+
+	if (gH323Debug)
+		ast_verbose("---   ooh323_digit_end\n");
+
+	if (!p) {
+		ast_log(LOG_ERROR, "No private structure for call\n");
+		return -1;
+	}
+	ast_mutex_lock(&p->lock);
+	if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) 
+		ast_rtp_senddigit_end(p->rtp, digit);
+
+	ast_mutex_unlock(&p->lock);
+	if (gH323Debug)
+		ast_verbose("+++   ooh323_digit_end\n");
+
+	return 0;
 }
 
 
 static int ooh323_call(struct ast_channel *ast, char *dest, int timeout)
 {
-   struct ooh323_pvt *p = ast->tech_pvt;
-   char destination[256];
-   int res=0;
-   const char *val=NULL;
-   ooCallOptions opts = {
-      .fastStart = TRUE,
-      .tunneling = TRUE,
-      .disableGk = TRUE,
-      .callMode = OO_CALLMODE_AUDIOCALL
-   };
-   if(gH323Debug)
-      ast_verbose("---   ooh323_call- %s\n", dest);
-
-
-   if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) 
-   {
-      ast_log(LOG_WARNING, "ooh323_call called on %s, neither down nor "
-                           "reserved\n", ast->name);
-      return -1;
-   }
-   ast_mutex_lock(&p->lock);
-   ast_set_flag(p, H323_OUTGOING);
-   if (ast->cid.cid_num) {
-     if(p->callerid_num)   free(p->callerid_num);
-      p->callerid_num = strdup(ast->cid.cid_num);
-   }
-
-   if(ast->cid.cid_name) {
-      if(p->callerid_name)   free(p->callerid_name);
-      p->callerid_name = strdup(ast->cid.cid_name);
-   }
-   else{
-      ast->cid.cid_name = strdup(gCallerID);
-      if(p->callerid_name)   free(p->callerid_name);
-      p->callerid_name = strdup(ast->cid.cid_name);
-   }
-
-   /* Retrieve vars */
-
-
-   val = pbx_builtin_getvar_helper(ast, "CALLER_H323ID");
-   if(val){
-     strncpy(p->caller_h323id, val, sizeof(p->caller_h323id)-1);
-   }
-   
-   val = pbx_builtin_getvar_helper(ast, "CALLER_H323DIALEDDIGITS");
-   if(val){
-      strncpy(p->caller_dialedDigits, val, sizeof(p->caller_dialedDigits)-1);
-      if(!p->callerid_num)   p->callerid_num = strdup(val);
-     
-   }
-
-   val = pbx_builtin_getvar_helper(ast, "CALLER_H323EMAIL");
-   if(val)
-     strncpy(p->caller_email, val, sizeof(p->caller_email)-1);
-   
-   val = pbx_builtin_getvar_helper(ast, "CALLER_H323URL");
-   if(val)
-     strncpy(p->caller_url, val, sizeof(p->caller_url)-1);  
-
-
-   p->callToken = (char*)malloc(AST_MAX_EXTENSION);
-   if(!p->callToken)
-   {
-      ast_mutex_unlock(&p->lock);
-      ast_log(LOG_ERROR, "Failed to allocate memory for callToken\n");
-      return -1; /* TODO: need to clean/hangup?? */
-   }      
-
-   if(p->host && p->port != 0)
-      sprintf(destination, "%s:%d", p->host, p->port);
-   else if(p->host)
-      sprintf(destination, "%s", p->host);
-   else
-     strncpy(destination, dest, sizeof(destination)-1);
-
-   destination[sizeof(destination)-1]='\0';
-
-   ast_mutex_lock(&ooh323c_cmd_lock);
-   if(OO_TESTFLAG(p->flags, H323_DISABLEGK))
-      res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, &opts);
-   else
-      res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, NULL);
-   ast_mutex_unlock(&ooh323c_cmd_lock);
-
-   ast_mutex_unlock(&p->lock);
-   if(res != OO_OK)
-   {
-      ast_log(LOG_ERROR,"Failed to make call\n");
-      return -1; /* ToDO: cleanup */
-   }
-   if(gH323Debug)
-      ast_verbose("+++   ooh323_call\n");
+	struct ooh323_pvt *p = ast->tech_pvt;
+	char destination[256];
+	int res = 0;
+	const char *val = NULL;
+	ooCallOptions opts = {
+		.fastStart = TRUE,
+		.tunneling = TRUE,
+		.disableGk = TRUE,
+		.callMode = OO_CALLMODE_AUDIOCALL
+	};
+	if (gH323Debug)
+		ast_verbose("---   ooh323_call- %s\n", dest);
+
+	if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
+		ast_log(LOG_WARNING, "ooh323_call called on %s, neither down nor "
+									"reserved\n", ast->name);
+		return -1;
+	}
+	ast_mutex_lock(&p->lock);
+	ast_set_flag(p, H323_OUTGOING);
+	if (ast->cid.cid_num) {
+		if (p->callerid_num) {
+			free(p->callerid_num);
+		}
+		p->callerid_num = strdup(ast->cid.cid_num);
+	}
+
+	if (ast->cid.cid_name) {
+		if (p->callerid_name) {
+			free(p->callerid_name);
+		}
+		p->callerid_name = strdup(ast->cid.cid_name);
+	}
+	else{
+		ast->cid.cid_name = strdup(gCallerID);
+		if (p->callerid_name) {
+			free(p->callerid_name);
+		}
+		p->callerid_name = strdup(ast->cid.cid_name);
+	}
+
+	/* Retrieve vars */
+
+
+	if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323ID"))) {
+		ast_copy_string(p->caller_h323id, val, sizeof(p->caller_h323id));
+	}
+	
+	if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323DIALEDDIGITS"))) {
+		ast_copy_string(p->caller_dialedDigits, val, sizeof(p->caller_dialedDigits));
+		if (!p->callerid_num) {
+			p->callerid_num = strdup(val);
+		}
+	}
+
+	if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323EMAIL"))) {
+		ast_copy_string(p->caller_email, val, sizeof(p->caller_email));
+	}
+
+	if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323URL"))) {
+		ast_copy_string(p->caller_url, val, sizeof(p->caller_url));
+	}
+
+
+	if (!(p->callToken = (char*)malloc(AST_MAX_EXTENSION))) {
+		ast_mutex_unlock(&p->lock);
+		ast_log(LOG_ERROR, "Failed to allocate memory for callToken\n");
+		return -1; /* TODO: need to clean/hangup?? */
+	}		
+
+	if (p->host && p->port != 0)
+		snprintf(destination, sizeof(destination), "%s:%d", p->host, p->port);
+	else if (p->host)
+		snprintf(destination, sizeof(destination), "%s", p->host);
+	else
+		ast_copy_string(destination, dest, sizeof(destination));
+
+	ast_mutex_lock(&ooh323c_cmd_lock);
+	if (OO_TESTFLAG(p->flags, H323_DISABLEGK))
+		res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, &opts);
+	else
+		res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, NULL);
+	ast_mutex_unlock(&ooh323c_cmd_lock);
+
+	ast_mutex_unlock(&p->lock);
+	if (res != OO_OK) {
+		ast_log(LOG_ERROR, "Failed to make call\n");
+		return -1; /* TODO: cleanup */
+	}
+	if (gH323Debug)
+		ast_verbose("+++   ooh323_call\n");
 
   return 0;
 }
 
 static int ooh323_hangup(struct ast_channel *ast)
 {
-   struct ooh323_pvt *p = ast->tech_pvt;
-
-   if(gH323Debug)
-      ast_verbose("---   ooh323_hangup\n");
-
-   if(p)
-   {
-      ast_mutex_lock(&p->lock);
-
-      if(gH323Debug)
-	ast_verbose("    hanging %s\n", p->username);
-      ast->tech_pvt = NULL; 
-      if(!ast_test_flag(p, H323_ALREADYGONE)) {
-         ast_mutex_lock(&ooh323c_cmd_lock);
-         ooHangCall(p->callToken, 
-             ooh323_convert_hangupcause_asteriskToH323(p->owner->hangupcause));
-         ast_mutex_unlock(&ooh323c_cmd_lock);
-         ast_set_flag(p, H323_ALREADYGONE);
-         /* ast_mutex_unlock(&p->lock); */
-      }
-      else {
-         ast_set_flag(p, H323_NEEDDESTROY);
-      }
-      /* detach channel here */
-      if(p->owner)
-      {
-         p->owner->tech_pvt = NULL;
-         p->owner = NULL;
-      }
-
-      ast_mutex_unlock(&p->lock);
-      ast_mutex_lock(&usecnt_lock);
-      usecnt--;
-      ast_mutex_unlock(&usecnt_lock);
-
-      /* Notify the module monitors that use count for resource has changed */
-      ast_update_use_count();
-     
-   }
-
-
-   else {
-      ast_log(LOG_ERROR, "No call to hangup\n" );
-      return -1;
-   }
-   
-   if(gH323Debug)
-      ast_verbose("+++   ooh323_hangup\n");
+	struct ooh323_pvt *p = ast->tech_pvt;
+
+	if (gH323Debug)
+		ast_verbose("---   ooh323_hangup\n");
+
+	if (p) {

[... 4046 lines stripped ...]



More information about the asterisk-addons-commits mailing list