[asterisk-commits] irroot: branch irroot/patches r336374 - /team/irroot/patches/h323-trunk.patch

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 17 12:50:14 CDT 2011


Author: irroot
Date: Sat Sep 17 12:50:13 2011
New Revision: 336374

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=336374
Log:
Add patch for h323_h323plus-trunk

Added:
    team/irroot/patches/h323-trunk.patch   (with props)

Added: team/irroot/patches/h323-trunk.patch
URL: http://svnview.digium.com/svn/asterisk/team/irroot/patches/h323-trunk.patch?view=auto&rev=336374
==============================================================================
--- team/irroot/patches/h323-trunk.patch (added)
+++ team/irroot/patches/h323-trunk.patch Sat Sep 17 12:50:13 2011
@@ -1,0 +1,396 @@
+Index: channels/h323/ast_h323.cxx
+===================================================================
+--- channels/h323/ast_h323.cxx	(.../trunk)	(revision 336373)
++++ channels/h323/ast_h323.cxx	(.../team/irroot/h323_h323plus-trunk)	(revision 336373)
+@@ -118,16 +118,10 @@
+  
+ 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()) {
+@@ -2461,6 +2463,10 @@
+ 		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" */
+Index: channels/h323/chan_h323.h
+===================================================================
+--- channels/h323/chan_h323.h	(.../trunk)	(revision 336373)
++++ channels/h323/chan_h323.h	(.../team/irroot/h323_h323plus-trunk)	(revision 336373)
+@@ -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);
+Index: channels/h323/ast_h323.h
+===================================================================
+--- channels/h323/ast_h323.h	(.../trunk)	(revision 336373)
++++ channels/h323/ast_h323.h	(.../team/irroot/h323_h323plus-trunk)	(revision 336373)
+@@ -33,6 +33,10 @@
+ 
+ #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
+ {
+ 	PCLASSINFO(MyH323EndPoint, H323EndPoint);
+Index: channels/chan_h323.c
+===================================================================
+--- channels/chan_h323.c	(.../trunk)	(revision 336373)
++++ channels/chan_h323.c	(.../team/irroot/h323_h323plus-trunk)	(revision 336373)
+@@ -145,6 +145,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;
+@@ -988,6 +989,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);
+@@ -1821,7 +1823,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) {
+@@ -2775,13 +2777,50 @@
+ 
+ 	/* 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;
++}
++
+ static char *handle_cli_h323_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+ 	switch (cmd) {
+@@ -2851,6 +2890,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"),
+@@ -3069,6 +3109,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 */
+ 		}
+@@ -3129,7 +3171,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;
+@@ -3150,7 +3192,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;
+ 			}
+@@ -3392,9 +3434,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;
+ 			}
+ 		}
+Index: configure.ac
+===================================================================
+--- configure.ac	(.../trunk)	(revision 336373)
++++ configure.ac	(.../team/irroot/h323_h323plus-trunk)	(revision 336373)
+@@ -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],
+Index: configs/h323.conf.sample
+===================================================================
+--- configs/h323.conf.sample	(.../trunk)	(revision 336373)
++++ configs/h323.conf.sample	(.../team/irroot/h323_h323plus-trunk)	(revision 336373)
+@@ -45,6 +45,10 @@
+ ; 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
+ ; DISABLE			- Disable the use of a GK
+
+Property changes on: .
+___________________________________________________________________
+Added: automerge
+   + *
+Added: svnmerge-integrated
+   + /trunk:1-336331
+Added: automerge-email
+   + gregory at distrotech.co.za
+

Propchange: team/irroot/patches/h323-trunk.patch
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/irroot/patches/h323-trunk.patch
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/irroot/patches/h323-trunk.patch
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list