[asterisk-commits] jdixon: branch jdixon/chan_usbradio-1.4 r155797 - /team/jdixon/chan_usbradio-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 10 14:15:11 CST 2008


Author: jdixon
Date: Mon Nov 10 14:15:11 2008
New Revision: 155797

URL: http://svn.digium.com/view/asterisk?view=rev&rev=155797
Log:
Added "deny" and "permit" to allow inbound connection control

Modified:
    team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c

Modified: team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c?view=diff&rev=155797&r1=155796&r2=155797
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c Mon Nov 10 14:15:11 2008
@@ -107,6 +107,7 @@
 #include <zlib.h>
 #include <pthread.h>
 #include <signal.h>
+#include <fnmatch.h>
 
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
@@ -144,6 +145,7 @@
 #define EL_MAX_SERVERS 3
 #define EL_SERVERNAME_SIZE 63
 #define	EL_MAX_INSTANCES 100
+#define	EL_MAX_CALL_LIST 30
 
 #define	DELIMCHR ','
 #define	QUOTECHR 34
@@ -221,6 +223,10 @@
 	char astnode[EL_NAME_SIZE + 1];
 	char context[EL_NAME_SIZE + 1];
 	int maxstns;
+	char *denylist[EL_MAX_CALL_LIST];
+	int ndenylist;
+	char *permitlist[EL_MAX_CALL_LIST];
+	int npermitlist;
 	/* missed 10 heartbeats, you're out */
 	short rtcptimeout;
 	unsigned int mynode;
@@ -2348,13 +2354,44 @@
 						}
 						else /* otherwise its a new request */
 						{
-							i = do_new_call(instp,NULL,call,name);
-							if (i < 0)
+							i = 0;  /* default authorized */
+							if (instp->ndenylist)
 							{
-								ast_mutex_unlock(&instp->lock);
-								mythread_exit(NULL);
+								for (x = 0; x < instp->ndenylist; x++)
+								{
+									if (!fnmatch(instp->denylist[x],call,FNM_CASEFOLD)) 
+									{
+										i = 1;
+										break;
+									}
+								}
 							}
-							if (i)
+							else
+							{
+								/* if permit list specified, default is not to authorize */
+								if (instp->npermitlist) i = 1;
+							}
+							if (instp->npermitlist)
+							{
+								for (x = 0; x < instp->npermitlist; x++)
+								{
+									if (!fnmatch(instp->permitlist[x],call,FNM_CASEFOLD)) 
+									{
+										i = 0;
+										break;
+									}
+								}
+							}
+							if (!i) /* if authorized */
+							{
+								i = do_new_call(instp,NULL,call,name);
+								if (i < 0)
+								{
+									ast_mutex_unlock(&instp->lock);
+									mythread_exit(NULL);
+								}
+							}
+							if (i) /* if not authorized */
 							{
 								if (debug) ast_log(LOG_DEBUG,"Sent bye to IP address %s\n",
 									instp->el_node_test.ip);
@@ -2622,6 +2659,12 @@
 	   instp->irlpnode = atoi(val);
 	}
 
+        val = (char *) ast_variable_retrieve(cfg,ctg,"deny"); 
+	if (val) instp->ndenylist = finddelim(strdup(val),instp->denylist,EL_MAX_CALL_LIST);
+
+        val = (char *) ast_variable_retrieve(cfg,ctg,"permit"); 
+	if (val) instp->npermitlist = finddelim(strdup(val),instp->permitlist,EL_MAX_CALL_LIST);
+
 	instp->audio_sock = -1;
 	instp->ctrl_sock = -1;
 




More information about the asterisk-commits mailing list