[asterisk-commits] pcadach: branch pcadach/chan_h323-live r43070 - /team/pcadach/chan_h323-live/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Sep 17 06:47:44 MST 2006


Author: pcadach
Date: Sun Sep 17 08:47:43 2006
New Revision: 43070

URL: http://svn.digium.com/view/asterisk?rev=43070&view=rev
Log:
Allow to reject anonymous calls by configuration

Modified:
    team/pcadach/chan_h323-live/channels/chan_h323.c

Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=43070&r1=43069&r2=43070&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Sun Sep 17 08:47:43 2006
@@ -147,6 +147,7 @@
 static int gkroute = 0;
 /* Find user by alias (h.323 id) is default, alternative is the incomming call's source IP address*/
 static int userbyalias = 1;
+static int acceptAnonymous = 1;
 static int tos = 0;
 static char secret[50];
 static unsigned int unique = 0;
@@ -2104,23 +2105,24 @@
 		   or we are not allowing gk routed calls */
 		user = find_user(cd, 1);
 		if (!user) {
+			if (!acceptAnonymous) {
+				ast_log(LOG_NOTICE, "Anonymous call from '%s@%s' rejected\n", pvt->cd.call_source_aliases, pvt->cd.sourceIp);
+				oh323_destroy(pvt);
+				return NULL;
+			}
+			if (ast_strlen_zero(default_context)) {
+				ast_log(LOG_ERROR, "Call from '%s@%s' rejected due to no default context\n", pvt->cd.call_source_aliases, pvt->cd.sourceIp);
+				oh323_destroy(pvt);
+				return NULL;
+			}
+			strncpy(pvt->context, default_context, sizeof(pvt->context) - 1);
 			if (!ast_strlen_zero(pvt->cd.call_dest_e164)) {
 				strncpy(pvt->exten, cd->call_dest_e164, sizeof(pvt->exten) - 1);
 			} else {
 				strncpy(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten) - 1);
 			}
-			if (ast_strlen_zero(default_context)) {
-				ast_log(LOG_ERROR, "Call from '%s' rejected due to no default context\n", pvt->cd.call_source_aliases);
-				oh323_destroy(pvt);
-				return NULL;
-			}
-			strncpy(pvt->context, default_context, sizeof(pvt->context) - 1);
 			if (h323debug)
-				ast_log(LOG_DEBUG, "Sending %s to context [%s]\n", cd->call_source_aliases, pvt->context);
-			/* XXX: Is it really required??? */
-#if 0
-			memset(&pvt->options, 0, sizeof(pvt->options));
-#endif
+				ast_log(LOG_DEBUG, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
 		} else {
 			if (user->host) {
 				if (strcasecmp(cd->sourceIp, ast_inet_ntoa(user->addr.sin_addr))) {
@@ -2649,6 +2651,7 @@
 	gatekeeper_discover = 0;
 	gkroute = 0;
 	userbyalias = 1;
+	acceptAnonymous = 1;
 	tos = 0;
 
 	/* Copy the default jb config over global_jbconf */
@@ -2726,6 +2729,8 @@
 			ast_verbose(VERBOSE_PREFIX_2 "Setting default context to %s\n", default_context);	
 		} else if (!strcasecmp(v->name, "UserByAlias")) {
 			userbyalias = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "AcceptAnonymous")) {
+			acceptAnonymous = ast_true(v->value);
 		} else if (!update_common_options(v, &global_options)) {
 			/* dummy */
 		}



More information about the asterisk-commits mailing list