[asterisk-commits] jrose: branch jrose/nacl_branch r368454 - in /team/jrose/nacl_branch: channel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 4 15:40:14 CDT 2012


Author: jrose
Date: Mon Jun  4 15:40:12 2012
New Revision: 368454

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368454
Log:
Committing initial working prototype... no new config stuff here.

Modified:
    team/jrose/nacl_branch/channels/chan_h323.c
    team/jrose/nacl_branch/channels/chan_unistim.c
    team/jrose/nacl_branch/include/asterisk/acl.h
    team/jrose/nacl_branch/main/acl.c
    team/jrose/nacl_branch/main/asterisk.c
    team/jrose/nacl_branch/main/manager.c

Modified: team/jrose/nacl_branch/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/nacl_branch/channels/chan_h323.c?view=diff&rev=368454&r1=368453&r2=368454
==============================================================================
--- team/jrose/nacl_branch/channels/chan_h323.c (original)
+++ team/jrose/nacl_branch/channels/chan_h323.c Mon Jun  4 15:40:12 2012
@@ -1488,6 +1488,8 @@
 			user->ha = ast_append_ha(v->name, v->value, user->ha, &ha_error);
 			if (ha_error)
 				ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
+		} else if (!strcasecmp(v->name, "nacl")) {
+			user->ha = ast_append_nacl(user->ha, v->value);
 		}
 	}
 	if (!user->options.dtmfmode)

Modified: team/jrose/nacl_branch/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/nacl_branch/channels/chan_unistim.c?view=diff&rev=368454&r1=368453&r2=368454
==============================================================================
--- team/jrose/nacl_branch/channels/chan_unistim.c (original)
+++ team/jrose/nacl_branch/channels/chan_unistim.c Mon Jun  4 15:40:12 2012
@@ -6306,6 +6306,8 @@
 			ast_copy_string(d->extension_number, v->value, sizeof(d->extension_number));
 		} else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
 			d->ha = ast_append_ha(v->name, v->value, d->ha, NULL);
+		} else if (!strcasecmp(v->name, "nacl")) {
+			d->ha = ast_append_nacl(d->ha, v->value);
 		} else if (!strcasecmp(v->name, "context")) {
 			ast_copy_string(d->context, v->value, sizeof(d->context));
 		} else if (!strcasecmp(v->name, "maintext0")) {

Modified: team/jrose/nacl_branch/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/nacl_branch/include/asterisk/acl.h?view=diff&rev=368454&r1=368453&r2=368454
==============================================================================
--- team/jrose/nacl_branch/include/asterisk/acl.h (original)
+++ team/jrose/nacl_branch/include/asterisk/acl.h Mon Jun  4 15:40:12 2012
@@ -208,6 +208,15 @@
 struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
 
 /*!
+ * \brief append a copy of the contents of one list of host access rules
+ *        to the end of another.
+ *
+ * \param destination The host access rule list that is receiving additional items
+ * \param source The host access rule list being copied from
+ */
+struct ast_ha *ast_duplicate_and_append_ha(struct ast_ha *destination, struct ast_ha *source);
+
+/*!
  * \brief Find our IP address
  *
  * \details
@@ -258,6 +267,29 @@
  */
 const char *ast_tos2str(unsigned int tos);
 
+/*!
+ * \brief Pluggable function to append an nacl to an existing host access list
+ *
+ * \details
+ * This function needs to be installed by some other loaded module. If it is available,
+ * then invoking this function should append the requested ha to the host access
+ * list in a similar fashion to ast_duplicate_and_append_ha
+ *
+ * This function needs to be instaled via the ast_install_nacl_functions function.
+ *
+ * \param ha The host access list being appended
+ * \param name Name of the nacl sought to append with
+ */
+struct ast_ha *ast_append_nacl(struct ast_ha *ha, const char *name);
+
+int init_nacl(void);
+
+/*!
+ * \brief Unset nacl function callbacks
+ */
+void ast_uninstall_nacl_functions(void);
+
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/jrose/nacl_branch/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/nacl_branch/main/acl.c?view=diff&rev=368454&r1=368453&r2=368454
==============================================================================
--- team/jrose/nacl_branch/main/acl.c (original)
+++ team/jrose/nacl_branch/main/acl.c Mon Jun  4 15:40:12 2012
@@ -271,6 +271,26 @@
 	return ret;                             /* Return start of list */
 }
 
+struct ast_ha *ast_duplicate_and_append_ha(struct ast_ha *destination, struct ast_ha *source)
+{
+	struct ast_ha *tail = destination;
+
+	/* If we come into this list with no destination ha, simply return the duplicated source */
+	if (!destination) {
+		return ast_duplicate_ha_list(source);
+	}
+
+	/* Shift the destination to the end of the destination ha. */
+	while (tail->next) {
+		tail = tail->next;
+	}
+
+	/* Clone and attach the source ha */
+	tail->next = ast_duplicate_ha_list(source);
+
+	return destination;
+}
+
 /*!
  * \brief
  * Isolate a 32-bit section of an IPv6 address
@@ -505,7 +525,7 @@
 		const char *addr = ast_strdupa(ast_sockaddr_stringify(&ha->addr));
 		const char *mask = ast_strdupa(ast_sockaddr_stringify(&ha->netmask));
 
-		ast_debug(1, "%s/%s sense %d appended to acl for peer\n", addr, mask, ha->sense);
+		ast_debug(1, "%s/%s sense %d appended to acl\n", addr, mask, ha->sense);
 	}
 
 	return ret;

Modified: team/jrose/nacl_branch/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/nacl_branch/main/asterisk.c?view=diff&rev=368454&r1=368453&r2=368454
==============================================================================
--- team/jrose/nacl_branch/main/asterisk.c (original)
+++ team/jrose/nacl_branch/main/asterisk.c Mon Jun  4 15:40:12 2012
@@ -113,6 +113,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/translate.h"
 #include "asterisk/features.h"
+#include "asterisk/acl.h"
 #include "asterisk/ulaw.h"
 #include "asterisk/alaw.h"
 #include "asterisk/callerid.h"
@@ -4009,6 +4010,11 @@
 
 	ast_http_init();		/* Start the HTTP server, if needed */
 
+	if (init_nacl()) {
+		printf("%s", term_quit());
+		exit(1);
+	}
+
 	if (init_manager()) {
 		printf("%s", term_quit());
 		exit(1);

Modified: team/jrose/nacl_branch/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/nacl_branch/main/manager.c?view=diff&rev=368454&r1=368453&r2=368454
==============================================================================
--- team/jrose/nacl_branch/main/manager.c (original)
+++ team/jrose/nacl_branch/main/manager.c Mon Jun  4 15:40:12 2012
@@ -7188,6 +7188,8 @@
 			} else if (!strcasecmp(var->name, "deny") ||
 				       !strcasecmp(var->name, "permit")) {
 				user->ha = ast_append_ha(var->name, var->value, user->ha, NULL);
+			} else if (!strcasecmp(var->name, "nacl")) {
+				user->ha = ast_append_nacl(user->ha, var->value);
 			}  else if (!strcasecmp(var->name, "read") ) {
 				user->readperm = get_perm(var->value);
 			}  else if (!strcasecmp(var->name, "write") ) {




More information about the asterisk-commits mailing list