[asterisk-commits] irroot: branch irroot/h323_h323plus-trunk r318978 - in /team/irroot/h323_h323...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat May 14 08:42:40 CDT 2011


Author: irroot
Date: Sat May 14 08:42:35 2011
New Revision: 318978

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=318978
Log:

r1117 (#16619 #18670)

Changes to h323 to allow use with h323plus > 1.20.
Allow setting the gwid on registration.

This is no longer maintained


Modified:
    team/irroot/h323_h323plus-trunk/   (props changed)
    team/irroot/h323_h323plus-trunk/channels/chan_h323.c
    team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.cxx
    team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.h
    team/irroot/h323_h323plus-trunk/channels/h323/chan_h323.h
    team/irroot/h323_h323plus-trunk/configs/h323.conf.sample
    team/irroot/h323_h323plus-trunk/configure.ac

Propchange: team/irroot/h323_h323plus-trunk/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/irroot/h323_h323plus-trunk/
------------------------------------------------------------------------------
    automerge-email = gregory at distrotech.co.za

Modified: team/irroot/h323_h323plus-trunk/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/h323_h323plus-trunk/channels/chan_h323.c?view=diff&rev=318978&r1=318977&r2=318978
==============================================================================
--- team/irroot/h323_h323plus-trunk/channels/chan_h323.c (original)
+++ team/irroot/h323_h323plus-trunk/channels/chan_h323.c Sat May 14 08:42:35 2011
@@ -143,6 +143,7 @@
 /** H.323 configuration values */
 static int h323_signalling_port = 1720;
 static char gatekeeper[100];
+static char gatewayid[100];
 static int gatekeeper_disable = 1;
 static int gatekeeper_discover = 0;
 static int gkroute = 0;
@@ -982,6 +983,7 @@
 			return -1;
 		}
 	}
+	our_addr.ss.ss_family = AF_INET;
 	pvt->rtp = ast_rtp_instance_new("asterisk", sched, &our_addr, NULL);
 	if (!pvt->rtp) {
 		ast_mutex_unlock(&pvt->lock);
@@ -1815,7 +1817,7 @@
 		host = tmp;
 	}
 	strtok_r(host, "/", &(h323id));
-	if (!ast_strlen_zero(h323id)) {
+	if (!ast_strlen_zero(h323id) && gatekeeper_disable) {
 		h323_set_id(h323id);
 	}
 	if (ext) {
@@ -2769,8 +2771,45 @@
 
 	/* Possibly register with a GK */
 	if (!gatekeeper_disable) {
-		if (h323_set_gk(gatekeeper_discover, gatekeeper, secret)) {
+		if (h323_set_gk(gatekeeper_discover, gatekeeper, secret, gatewayid)) {
 			ast_log(LOG_ERROR, "Gatekeeper registration failed.\n");
+		}
+	}
+	return CLI_SUCCESS;
+}
+
+static char *handle_cli_h323_register_gk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "h323 register gk";
+		e->usage =
+			"Usage: h323 register gk\n"
+			"       Check gatekeeper registration and reregister\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (a->argc != 3) {
+		return CLI_SHOWUSAGE;
+	}
+
+	if (!gatekeeper_disable) {
+		switch (h323_check_gk()) {
+			case H323GK_FAILED:
+				ast_verb(3, "Endpoint not available\n");
+				break;
+			case H323GK_NOTREGISTERED:
+			case H323GK_NOTUSED:
+				ast_verb(3, "Gatekeeper not registered\n");
+				if (h323_set_gk(gatekeeper_discover, gatekeeper, secret, gatewayid)) {
+					ast_log(LOG_ERROR, "Gatekeeper registration failed.\n");
+				}
+				break;
+			case H323GK_OK:
+				ast_verb(3, "Gatekeeper registered\n");
+				break;
 		}
 	}
 	return CLI_SUCCESS;
@@ -2845,6 +2884,7 @@
 	AST_CLI_DEFINE(handle_cli_h323_set_trace,    "Enable/Disable H.323 Stack Tracing"),
 	AST_CLI_DEFINE(handle_cli_h323_set_debug,    "Enable/Disable H.323 Debugging"),
 	AST_CLI_DEFINE(handle_cli_h323_cycle_gk,     "Manually re-register with the Gatekeper"),
+	AST_CLI_DEFINE(handle_cli_h323_register_gk,  "Check and re-register with Gatekeeper if needed"),
 	AST_CLI_DEFINE(handle_cli_h323_hangup,       "Manually try to hang up a call"),
 	AST_CLI_DEFINE(handle_cli_h323_show_tokens,  "Show all active call tokens"),
 	AST_CLI_DEFINE(handle_cli_h323_show_version, "Show the version of the H.323 library in use"),
@@ -3063,6 +3103,8 @@
 			userbyalias = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "AcceptAnonymous")) {
 			acceptAnonymous = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "gatewayid")) {
+			ast_copy_string(gatewayid, v->value, sizeof(gatewayid));
 		} else if (!update_common_options(v, &global_options)) {
 			/* dummy */
 		}
@@ -3123,7 +3165,7 @@
 	ASTOBJ_CONTAINER_WRLOCK(&aliasl);
 	ASTOBJ_CONTAINER_TRAVERSE(&aliasl, 1, do {
 		ASTOBJ_RDLOCK(iterator);
-		if (h323_set_alias(iterator)) {
+		if (h323_set_alias(iterator, gatewayid)) {
 			ast_log(LOG_ERROR, "Alias %s rejected by endpoint\n", alias->name);
 			ASTOBJ_UNLOCK(iterator);
 			continue;
@@ -3144,7 +3186,7 @@
 		if(!gk_disable)
 			h323_gk_urq();
 		if (!gatekeeper_disable) {
-			if (h323_set_gk(gatekeeper_discover, gatekeeper, secret)) {
+			if (h323_set_gk(gatekeeper_discover, gatekeeper, secret, gatewayid)) {
 				ast_log(LOG_ERROR, "Gatekeeper registration failed.\n");
 				gatekeeper_disable = 1;
 			}
@@ -3386,9 +3428,8 @@
 		}
 		/* Possibly register with a GK */
 		if (!gatekeeper_disable) {
-			if (h323_set_gk(gatekeeper_discover, gatekeeper, secret)) {
+			if (h323_set_gk(gatekeeper_discover, gatekeeper, secret, gatewayid)) {
 				ast_log(LOG_ERROR, "Gatekeeper registration failed.\n");
-				gatekeeper_disable = 1;
 				res = AST_MODULE_LOAD_SUCCESS;
 			}
 		}

Modified: team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.cxx
URL: http://svnview.digium.com/svn/asterisk/team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.cxx?view=diff&rev=318978&r1=318977&r2=318978
==============================================================================
--- team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.cxx (original)
+++ team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.cxx Sat May 14 08:42:35 2011
@@ -118,15 +118,9 @@
  
 const char *h323manufact = "The NuFone Networks";
 const char *h323product  = "H.323 Channel Driver for Asterisk";
- 
+
 PDECLARE_PROCESS(MyProcess,PProcess,h323manufact,h323product,MAJOR_VERSION,MINOR_VERSION,BUILD_TYPE,BUILD_NUMBER)
-static MyProcess localProcess;  // active for the life of the DLL
-/* void MyProcess::Main()
-{
-}
-*/
-////////////////////////////////////////////////
-
+static MyProcess *localProcess = NULL;
 
 /** Counter for the number of connections */
 static int channelsOpen;
@@ -228,19 +222,6 @@
 
 void MyProcess::Main()
 {
-	PTrace::Initialise(PTrace::GetLevel(), NULL, traceOptions);
-	PTrace::SetStream(logstream);
-
-	cout << "  == Creating H.323 Endpoint" << endl;
-	if (endPoint) {
-		cout << "  == ENDPOINT ALREADY CREATED" << endl;
-		return;
-	}
-	endPoint = new MyH323EndPoint();
-	/* Due to a bug in the H.323 recomendation/stack we should request a sane
-	   amount of bandwidth from the GK - this function is ignored if not using a GK
-	   We are requesting 128 (64k in each direction), which is the worst case codec. */
-	endPoint->SetInitialBandwidth(1280);
 }
 
 void PAssertFunc(const char *msg)
@@ -2251,9 +2232,23 @@
 void h323_end_point_create(void)
 {
 	channelsOpen = 0;
-	logstream = new PAsteriskLog();
-	PTrace::SetStream(logstream); 
+
+	if (!localProcess) {
+		localProcess = new MyProcess();
+	}
+
+	if (!logstream) {
+		logstream = new PAsteriskLog();
+		PTrace::Initialise(PTrace::GetLevel(), NULL, traceOptions);
+		PTrace::SetStream(logstream);
+	}
+
+	cout << "  == Creating H.323 Endpoint" << endl;
 	endPoint = new MyH323EndPoint();
+	/* Due to a bug in the H.323 recomendation/stack we should request a sane
+	 amount of bandwidth from the GK - this function is ignored if not using a GK
+	  We are requesting 128 (64k in each direction), which is the worst case codec. */
+	endPoint->SetInitialBandwidth(1280);
 }
 
 void h323_gk_urq(void)
@@ -2262,7 +2257,9 @@
 		cout << " ERROR: [h323_gk_urq] No Endpoint, this is bad" << endl;
 		return;
 	}
-	endPoint->RemoveGatekeeper();
+	if (endPoint->IsRegisteredWithGatekeeper() == TRUE) {
+		endPoint->RemoveGatekeeper(0);
+	}
 }
 
 void h323_debug(int flag, unsigned level)
@@ -2388,11 +2385,12 @@
 #endif
 
 
-int h323_set_alias(struct oh323_alias *alias)
+int h323_set_alias(struct oh323_alias *alias, const char *gwid)
 {
 	char *p;
 	char *num;
 	PString h323id(alias->name);
+	PString h323gwid(gwid);
 	PString e164(alias->e164);
 	char *prefix;
 
@@ -2402,6 +2400,9 @@
 	}
 
 	cout << "== Adding alias \"" << h323id << "\" to endpoint" << endl;
+	if (!h323gwid.IsEmpty()) {
+		endPoint->SetLocalUserName(h323gwid);
+	}
 	endPoint->AddAliasName(h323id);
 	endPoint->RemoveAliasName(PProcess::Current().GetName());
 
@@ -2446,10 +2447,11 @@
 /** Establish Gatekeeper communiations, if so configured,
   *	register aliases for the H.323 endpoint to respond to.
   */
-int h323_set_gk(int gatekeeper_discover, char *gatekeeper, char *secret)
+int h323_set_gk(int gatekeeper_discover, char *gatekeeper, char *secret, char *gatewayid)
 {
 	PString gkName = PString(gatekeeper);
 	PString pass = PString(secret);
+	PString h323gwid(gatewayid);
 	H323TransportUDP *rasChannel;
 
 	if (!h323_end_point_exist()) {
@@ -2460,6 +2462,10 @@
 	if (!gatekeeper) {
 		cout << "Error: Gatekeeper cannot be NULL" << endl;
 		return 1;
+	}
+	if (!h323gwid.IsEmpty()) {
+		cout << "=== Setting Local Name To " << h323gwid << endl;
+		endPoint->SetLocalUserName(h323gwid);
 	}
 	if (strlen(secret)) {
 		endPoint->SetGatekeeperPassword(pass);
@@ -2480,6 +2486,7 @@
 			return 1;
 		}
 		if (endPoint->SetGatekeeper(gkName, rasChannel)) {
+			endPoint->GetGatekeeper()->RegistrationRequest(true);
 			cout << "== Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl;
 		} else {
 			cout << "Error registering with gatekeeper \"" << gkName << "\". " << endl;
@@ -2490,6 +2497,26 @@
 	return 0;
 }
 
+enum gk_status h323_check_gk()
+{
+	H323Gatekeeper *GK;
+
+	if (!h323_end_point_exist()) {
+		return H323GK_FAILED;
+	}
+
+	GK = endPoint->GetGatekeeper();
+	if (GK != NULL) {
+		PString gkname = GK->GetName();
+		if (endPoint->IsRegisteredWithGatekeeper() == FALSE) {
+			return H323GK_NOTREGISTERED;
+		}
+	} else {
+		return H323GK_NOTUSED;
+	}
+	return H323GK_OK;
+}
+
 /** Send a DTMF tone over the H323Connection with the
   * specified token.
   */
@@ -2668,10 +2695,13 @@
 	close(_timerChangePipe[1]);
 #endif
 	if (logstream) {
-		PTrace::SetStream(NULL);
 		delete logstream;
 		logstream = NULL;
 	}
+	if (localProcess) {
+		delete localProcess;
+		localProcess = NULL;
+	}
 }
 
 } /* extern "C" */

Modified: team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.h
URL: http://svnview.digium.com/svn/asterisk/team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.h?view=diff&rev=318978&r1=318977&r2=318978
==============================================================================
--- team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.h (original)
+++ team/irroot/h323_h323plus-trunk/channels/h323/ast_h323.h Sat May 14 08:42:35 2011
@@ -32,6 +32,10 @@
 #include "ast_ptlib.h"
 
 #define VERSION(a,b,c) ((a)*10000+(b)*100+(c))
+
+#if VERSION(OPENH323_MAJOR, OPENH323_MINOR, OPENH323_BUILD) > VERSION(1,21,0)
+typedef PBoolean BOOL;
+#endif
 
 class MyH323EndPoint : public H323EndPoint
 {

Modified: team/irroot/h323_h323plus-trunk/channels/h323/chan_h323.h
URL: http://svnview.digium.com/svn/asterisk/team/irroot/h323_h323plus-trunk/channels/h323/chan_h323.h?view=diff&rev=318978&r1=318977&r2=318978
==============================================================================
--- team/irroot/h323_h323plus-trunk/channels/h323/chan_h323.h (original)
+++ team/irroot/h323_h323plus-trunk/channels/h323/chan_h323.h Sat May 14 08:42:35 2011
@@ -135,6 +135,13 @@
 	unsigned int port;
 } rtp_info_t;
 
+enum gk_status {
+	H323GK_OK,
+	H323GK_FAILED,
+	H323GK_NOTUSED,
+	H323GK_NOTREGISTERED
+};
+
 /* This is a callback prototype function, called pass
    DTMF down the RTP. */
 typedef int (*receive_digit_cb)(unsigned, char, const char *, int);
@@ -222,7 +229,7 @@
 	void h323_end_point_create(void);
 	void h323_end_process(void);
 	int  h323_end_point_exist(void);
-
+	enum gk_status h323_check_gk(void);
 	void h323_debug(int, unsigned);
 
 	/* callback function handler*/
@@ -242,8 +249,8 @@
 					setpeercapabilities_cb,
 					onhold_cb);
 	int h323_set_capabilities(const char *, int, int, struct ast_codec_pref *, int);
-	int h323_set_alias(struct oh323_alias *);
-	int h323_set_gk(int, char *, char *);
+	int h323_set_alias(struct oh323_alias *, const char *gwid);
+	int h323_set_gk(int, char *, char *, char *);
 	void h323_set_id(char *);
 	void h323_show_tokens(void);
 	void h323_show_version(void);

Modified: team/irroot/h323_h323plus-trunk/configs/h323.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/irroot/h323_h323plus-trunk/configs/h323.conf.sample?view=diff&rev=318978&r1=318977&r2=318978
==============================================================================
--- team/irroot/h323_h323plus-trunk/configs/h323.conf.sample (original)
+++ team/irroot/h323_h323plus-trunk/configs/h323.conf.sample Sat May 14 08:42:35 2011
@@ -44,6 +44,10 @@
 ;dtmfmode=rfc2833:101
 ; or
 ;dtmfmode=cisco:121
+;
+; Set the gateway id this is the ID used to register as to the gatekeeper
+; Default is the user of the running process.
+;gatewayid = mygwid
 ;
 ; Set the gatekeeper
 ; DISCOVER			- Find the Gk address using multicast

Modified: team/irroot/h323_h323plus-trunk/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/irroot/h323_h323plus-trunk/configure.ac?view=diff&rev=318978&r1=318977&r2=318978
==============================================================================
--- team/irroot/h323_h323plus-trunk/configure.ac (original)
+++ team/irroot/h323_h323plus-trunk/configure.ac Sat May 14 08:42:35 2011
@@ -1895,7 +1895,7 @@
 		OPENH323DIR="${OPENH323_DIR}"
 	fi
 	AST_CHECK_OPENH323()
-	AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3], [], [1], [19], [0])
+	AST_CHECK_PWLIB_VERSION([OpenH323], [OPENH323], [openh323buildopts.h], [1], [17], [3], [], [1], [22], [0])
 	AST_CHECK_OPENH323_BUILD()
 	PLATFORM_OPENH323="h323_${PWLIB_PLATFORM}_${OPENH323_SUFFIX}"
 	AST_CHECK_PWLIB_BUILD([OpenH323], [OPENH323],




More information about the asterisk-commits mailing list