[asterisk-commits] oej: branch oej/deluxepine-1.4 r254271 - in /team/oej/deluxepine-1.4: ./ chan...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 24 04:08:35 CDT 2010
Author: oej
Date: Wed Mar 24 04:08:30 2010
New Revision: 254271
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=254271
Log:
This branch is still alive and kicking. Kicking out people
Modified:
team/oej/deluxepine-1.4/ (props changed)
team/oej/deluxepine-1.4/channels/chan_sip.c
team/oej/deluxepine-1.4/include/asterisk/acl.h
team/oej/deluxepine-1.4/include/asterisk/nacl.h
team/oej/deluxepine-1.4/main/acl.c
team/oej/deluxepine-1.4/main/nacl.c
Propchange: team/oej/deluxepine-1.4/
------------------------------------------------------------------------------
automerge = http://www.codename-pineapple.org/
Modified: team/oej/deluxepine-1.4/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/deluxepine-1.4/channels/chan_sip.c?view=diff&rev=254271&r1=254270&r2=254271
==============================================================================
--- team/oej/deluxepine-1.4/channels/chan_sip.c (original)
+++ team/oej/deluxepine-1.4/channels/chan_sip.c Wed Mar 24 04:08:30 2010
@@ -586,6 +586,7 @@
/*! \brief Global list of addresses dynamic peers are not allowed to use */
static struct ast_ha *global_contact_ha = NULL;
static struct ast_nacl *global_nacl = NULL;
+static struct ast_nacl *global_blacklist = NULL;
static int global_dynamic_exclude_static = 0;
/* Object counters */
@@ -19578,6 +19579,7 @@
sip_poke_all_peers();
sip_send_all_registers();
+ global_blacklist = ast_nacl_add("ast_sip_blacklist", "sip");
/* And start the monitor for the first time */
restart_monitor();
@@ -19668,6 +19670,7 @@
sched_context_destroy(sched);
ast_nacl_detach(global_nacl);
ast_free_ha(global_contact_ha);
+ ao2_ref(global_blacklist,-1);
return 0;
}
Modified: team/oej/deluxepine-1.4/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/deluxepine-1.4/include/asterisk/acl.h?view=diff&rev=254271&r1=254270&r2=254271
==============================================================================
--- team/oej/deluxepine-1.4/include/asterisk/acl.h (original)
+++ team/oej/deluxepine-1.4/include/asterisk/acl.h Wed Mar 24 04:08:30 2010
@@ -39,13 +39,14 @@
/* Host access rule */
struct in_addr netaddr;
struct in_addr netmask;
+ int counter;
int sense;
struct ast_ha *next;
};
void ast_free_ha(struct ast_ha *ha);
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to);
-struct ast_ha *ast_append_ha(char *sense, const char *stuff, struct ast_ha *path);
+struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path);
int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin);
int ast_get_ip(struct sockaddr_in *sin, const char *value);
int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *service);
Modified: team/oej/deluxepine-1.4/include/asterisk/nacl.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/deluxepine-1.4/include/asterisk/nacl.h?view=diff&rev=254271&r1=254270&r2=254271
==============================================================================
--- team/oej/deluxepine-1.4/include/asterisk/nacl.h (original)
+++ team/oej/deluxepine-1.4/include/asterisk/nacl.h Wed Mar 24 04:08:30 2010
@@ -66,6 +66,9 @@
*/
void ast_nacl_detach(struct ast_nacl *nacl);
+/*! \brief Add new IP address to ruleset */
+int ast_nacl_add_ip(struct ast_nacl *nacl, struct sockaddr_in *ip, int permit)
+
/*! \brief Initialize NACL subsystem */
int ast_nacl_load(void);
Modified: team/oej/deluxepine-1.4/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/deluxepine-1.4/main/acl.c?view=diff&rev=254271&r1=254270&r2=254271
==============================================================================
--- team/oej/deluxepine-1.4/main/acl.c (original)
+++ team/oej/deluxepine-1.4/main/acl.c Wed Mar 24 04:08:30 2010
@@ -265,7 +265,7 @@
{
struct ast_ha *new_ha;
- if ((new_ha = ast_malloc(sizeof(*new_ha)))) {
+ if ((new_ha = ast_calloc(sizeof(*new_ha)))) {
/* Copy from original to new object */
ast_copy_ha(original, new_ha);
}
@@ -295,7 +295,7 @@
return ret; /* Return start of list */
}
-struct ast_ha *ast_append_ha(char *sense, const char *stuff, struct ast_ha *path)
+struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path)
{
struct ast_ha *ha;
char *nm = "255.255.255.255";
@@ -310,7 +310,7 @@
prev = path;
path = path->next;
}
- if ((ha = ast_malloc(sizeof(*ha)))) {
+ if ((ha = ast_calloc(sizeof(*ha)))) {
ast_copy_string(tmp, stuff, sizeof(tmp));
nm = strchr(tmp, '/');
if (!nm) {
Modified: team/oej/deluxepine-1.4/main/nacl.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/deluxepine-1.4/main/nacl.c?view=diff&rev=254271&r1=254270&r2=254271
==============================================================================
--- team/oej/deluxepine-1.4/main/nacl.c (original)
+++ team/oej/deluxepine-1.4/main/nacl.c Wed Mar 24 04:08:30 2010
@@ -435,6 +435,23 @@
#undef FORMAT
#undef FORMAT2
+/*! \brief Add new IP address to ruleset */
+int ast_nacl_add_ip(struct ast_nacl *nacl, struct sockaddr_in *ip, int permit)
+{
+ char ipbuf[128];
+
+ if (!nacl || ip->sin_addr.s_addr) {
+ return FALSE;
+ }
+ ao2_ref(nacl,1);
+ ast_copy_string(ipbuf, ast_inet_ntoa(ip->sin_addr.s_addr), 128);
+ /* In trunk, we need to create a function that uses IP directly */
+ nacl->ha = ast_append_ha(permit ? "permit" : "deny", ipbuf, nacl->ha);
+ nacl->rules++;
+ ao2_ref(nacl,-1);
+ return TRUE;
+}
+
/*! \brief Update NACL (or create it if it doesn't exist) */
static int nacl_update(int fd, const char *command, const char *name, int rule, char *operation, const char *target, const char *owner)
{
@@ -450,11 +467,15 @@
}
nacl = ast_nacl_add(name, owner);
/* Add a ref so that both existing and new NACLs has an extra ref after nacl_find or nacl_add */
- ast_cli(fd, "Successfully added new NACL %s\n", name);
+ if (fd) {
+ ast_cli(fd, "Successfully added new NACL %s\n", name);
+ }
ao2_ref(nacl, +1);
}
if (!insert && !nacl->acl) {
- ast_cli(fd, "No rules to delete for NACL: %s\n", name);
+ if (fd) {
+ ast_cli(fd, "No rules to delete for NACL: %s\n", name);
+ }
ao2_ref(nacl, -1);
return RESULT_SUCCESS;
}
@@ -462,7 +483,9 @@
if (insert) {
newha = ast_append_ha(operation, target, NULL);
if (!newha) {
- ast_cli(fd, "Syntax error in new rule forNACL: %s\n", name);
+ if (fd) {
+ ast_cli(fd, "Syntax error in new rule forNACL: %s\n", name);
+ }
ao2_ref(nacl, -1);
ao2_unlock(nacl);
return RESULT_SUCCESS;
More information about the asterisk-commits
mailing list