[asterisk-commits] oej: branch oej/pgtips-srv-and-outbound-stuff-1.8 r386450 - in /team/oej/pgti...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 24 15:05:59 CDT 2013


Author: oej
Date: Wed Apr 24 15:05:55 2013
New Revision: 386450

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386450
Log:
Start working on the acl that we're going to use quite a lot


Also notice that the DNS functions doesn't help since they only return the first entry,
even for dual stack queries. We need both in that case.


Modified:
    team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c
    team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/acl.h
    team/oej/pgtips-srv-and-outbound-stuff-1.8/main/acl.c

Modified: team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c?view=diff&rev=386450&r1=386449&r2=386450
==============================================================================
--- team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c (original)
+++ team/oej/pgtips-srv-and-outbound-stuff-1.8/channels/chan_sip.c Wed Apr 24 15:05:55 2013
@@ -28638,18 +28638,19 @@
 					struct ast_sockaddr ip;
 					/* Get host name */
 					res = ast_srv_get_nth_record(peer->srvcontext, rec, &hostname, &tportno, &prio, &weight);
-					if (res) {
+					if (!res) {
 						res = ast_sockaddr_resolve_first_transport(&ip, hostname, 0, peer->socket.type);
+						if (ast_sockaddr_isnull(&ip) || res ) {
+							ast_debug(3, " ==> Bad IP, could not resolve hostname %s to proper family. \n", hostname);
+						} else {
+							peer->srventries = ast_append_ha("p", ast_sockaddr_stringify_addr(&ip), peer->srventries, &res);
+							ast_debug(3, " ==> Adding IP to peer %s srv list: %s \n", name, ast_sockaddr_stringify_addr(&ip));
+						}
 					}
-					if (res) {
-						int ha_error;
-						peer->srventries = ast_append_ha("p", ast_sockaddr_stringify_addr(&ip), peer->srventries, &res);
-					}
-					if (res) {
-						ast_log(LOG_ERROR, "Bad or unresolved host/IP entry in configuration for peer %s, cannot add to contact ACL\n", peer->name);
-					} else {
-						ast_debug(3, " ==> Adding IP to peer %s srv list: %s \n", name, ast_sockaddr_stringify_addr(&ip));
-					}
+				}
+				if (option_debug > 3) {
+					ast_debug(3, "======> List of IP matching entries for %s <============\n", name);
+					ha_list_debug(peer->srventries);
 				}
 
 		} else {
@@ -30705,6 +30706,7 @@
 {
 	struct ast_sockaddr *addrs;
 	int addrs_cnt;
+	int i;
 
 	addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
 	if (addrs_cnt <= 0) {
@@ -30713,6 +30715,12 @@
 	if (addrs_cnt > 1) {
 		ast_debug(1, "Multiple addresses, using the first one only\n");
 	}
+	if (option_debug > 3) {
+		for (i = 0; i < addrs_cnt; i++) {
+			ast_debug(0, "           => %d: %s resolves into  %s\n", i, name, ast_sockaddr_stringify(&addrs[i]));
+		}
+	}
+	
 
 	ast_sockaddr_copy(addr, &addrs[0]);
 

Modified: team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/acl.h?view=diff&rev=386450&r1=386449&r2=386450
==============================================================================
--- team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/acl.h (original)
+++ team/oej/pgtips-srv-and-outbound-stuff-1.8/include/asterisk/acl.h Wed Apr 24 15:05:55 2013
@@ -258,6 +258,11 @@
  */
 const char *ast_tos2str(unsigned int tos);
 
+/*!
+ * \brief Print a list of the ha contents in the debug channel 
+ */
+void ha_list_debug(struct ast_ha *ha);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/oej/pgtips-srv-and-outbound-stuff-1.8/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pgtips-srv-and-outbound-stuff-1.8/main/acl.c?view=diff&rev=386450&r1=386449&r2=386450
==============================================================================
--- team/oej/pgtips-srv-and-outbound-stuff-1.8/main/acl.c (original)
+++ team/oej/pgtips-srv-and-outbound-stuff-1.8/main/acl.c Wed Apr 24 15:05:55 2013
@@ -585,6 +585,12 @@
 			ast_debug(1, "Multiple addresses. Using the first only\n");
 		}
 		ast_sockaddr_copy(addr, &addrs[0]);
+		if (option_debug > 3) {
+			int i;
+			for (i = 0; i < addrs_cnt; i++) {
+				ast_debug(0, "           => %d: %s resolves into  %s\n", i, name, ast_sockaddr_stringify(&addrs[i]));
+			}
+		}
 		ast_free(addrs);
 	} else {
 		ast_log(LOG_WARNING, "Unable to lookup '%s'\n", name);
@@ -778,3 +784,15 @@
 	return res;
 }
 
+
+/*! \brief Print ha list to CLI on the debug channel */
+void ha_list_debug(struct ast_ha *ha)
+{
+	int rulesfound = 0;
+	while (ha) {
+		rulesfound++;
+		ast_debug(0,"     %-3.3d: %s: %s mask %s\n", rulesfound, (ha->sense == AST_SENSE_ALLOW) ? "permit" : "deny  ", 
+			ast_sockaddr_stringify(&ha->addr), ast_sockaddr_stringify(&ha->netmask));
+		ha = ha->next;
+	}
+}




More information about the asterisk-commits mailing list