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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Feb 8 17:46:45 CST 2009


Author: jdixon
Date: Sun Feb  8 17:46:45 2009
New Revision: 174217

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174217
Log:
Make initial changes allowing for 'EXP' node types

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

Modified: team/jdixon/chan_usbradio-1.4/channels/chan_irlp.c
URL: http://svn.digium.com/svn-view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_irlp.c?view=diff&rev=174217&r1=174216&r2=174217
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_irlp.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_irlp.c Sun Feb  8 17:46:45 2009
@@ -34,7 +34,7 @@
 #define	rpt_free(p) __ast_free(p,__FILE__,__LINE__,__PRETTY_FUNCTION__)
 
 
-/* Version 0.18, 12/1/2008
+/* Version 0.19, 2/8/2009
 irlp channel driver for Asterisk/app_rpt.
 
 I wish to thank the following people for the immeasurable amount of
@@ -326,6 +326,9 @@
 int  len;
 struct stat mystat;
 
+#ifndef	STNTYPE
+	return(NULL);
+#endif
 	snprintf(s,sizeof(s) - 1,"%s/%s",basename,fname);
 	fp = fopen(s,"r");
 	if (!fp) return(NULL);
@@ -351,6 +354,34 @@
 	str[len] = 0;
 	return(str);
 }
+
+#ifndef	STNTYPE
+
+static char *irlp_get_node(char *ip)
+{
+	FILE *fp = NULL;
+	char myip[100],mystn[100];
+
+	fp = fopen("/home/irlp/local/hosts","r");
+	if (!fp)
+	{
+		ast_log(LOG_ERROR,"Cannot open hosts file\n");
+		reset_stuff();
+		if ((!radmode) && curcall) ast_softhangup(curcall,AST_SOFTHANGUP_DEV);
+		return(NULL);
+	}
+	while(fscanf(fp,"%s %s",mystn,myip) == 2)
+	{
+		if (strcasecmp(myip,ip)) continue;
+		fclose(fp);
+		return(strdup(mystn));
+	}
+	fclose(fp);
+	return(NULL);
+}
+
+#endif
+
 
 static int is_rtcp_bye(unsigned char *p, int len)
 {
@@ -529,6 +560,24 @@
 	{
 		strncpy(ipbuf,remote_irlp_node_ip,sizeof(buf) - 1);
 	}
+        sin.sin_family = AF_INET;
+        sin.sin_addr.s_addr = inet_addr(ipbuf);
+        sin.sin_port = htons(tx_audio_port + 1);
+	len = rtcp_make_bye((unsigned char *)buf,reason);
+	for(x = 0; x < 1; x++)
+	{	
+	        sendto((alt_ctrl_sock != -1) ? alt_ctrl_sock : ctrl_sock,buf,len,
+        	        0,(struct sockaddr *)&sin,sizeof(struct sockaddr));
+	}
+	return;
+}
+
+static void send_bye_ip(char *reason, char *ipbuf)
+{
+char	buf[200];
+int	len,x;
+struct sockaddr_in sin;
+
         sin.sin_family = AF_INET;
         sin.sin_addr.s_addr = inet_addr(ipbuf);
         sin.sin_port = htons(tx_audio_port + 1);
@@ -722,10 +771,13 @@
 		time(&now);
 		if (keepalive && ((keepalive + KEEPALIVE_TIME) < now))
 		{
+#ifdef	STNTYPE
 			cp = irlp_read_file(IRLP_ROOT,"codec");
 			i = ((cp && *cp));
 			if (cp) ast_free(cp);
-			if (i) send_keepalive();
+			if (i)
+#endif
+				 send_keepalive();
 			keepalive = now;
 		}
 		FD_ZERO(fds);
@@ -768,10 +820,22 @@
 			 {
 	                    if (strncmp(ip, "127.0.0.1",IRLP_IP_SIZE) != 0)
 			    {
+
+				if (remote_irlp_node_ip[0] && strcasecmp(remote_irlp_node_ip,ip))
+				{
+					ast_log(LOG_NOTICE,"irlp node attempted connect from %s while busy\n", ip);
+					send_bye_ip("busy",ip);
+				} else
 	                       if (strncmp(remote_irlp_node_ip, ip, IRLP_IP_SIZE) != 0) 
 			       {
 	                          strncpy(remote_irlp_node_ip, ip, IRLP_IP_SIZE);
+#ifdef	STNTYPE
+
 				  cp = irlp_read_file(IRLP_ROOT,"active");
+#else
+				  cp = irlp_get_node(ip);
+#endif
+
 				  if ((cp && (strlen(cp) > 3)) && 
 				    (time(NULL) >= (lingertime + DISC_LINGER_TIME)))
 				  {
@@ -800,7 +864,12 @@
 					}
 					ready = 1;
 					if (curcall && (proto == IRLP_NOPROTO)) process_codec_file(curcall);
-				  } else ast_log(LOG_NOTICE,"irlp node attempted connect from %s with no node info\n", ip);
+				  }
+				   else 
+				  {
+					ast_log(LOG_NOTICE,"irlp node attempted connect from %s with no node info\n", ip);
+					send_bye("un-authorized");
+				  }
 				  if (cp) ast_free(cp);
 	                       }
 	                    }




More information about the asterisk-commits mailing list