[sr-dev] git:rbetancor/drouting: drouting: blacklist functions remove

Raul Alexis Betancor Santana rabs at dimension-virtual.com
Tue Jul 7 20:40:27 CEST 2009


Module: sip-router
Branch: rbetancor/drouting
Commit: 4df07e0bc7f8ac71dd788bf4d4b79072e7ea7d42
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4df07e0bc7f8ac71dd788bf4d4b79072e7ea7d42

Author: Raul Alexis Betancor Santana <rabs at dimension-virtual.com>
Committer: Raul Alexis Betancor Santana <rabs at dimension-virtual.com>
Date:   Tue Jul  7 17:48:39 2009 +0100

drouting: blacklist functions remove

- All blacklist management functions removed, core take cares of BL when
  sending out request as we only rewrite uri's

---

 modules_k/drouting/dr_bl.c    |  203 -----------------------------------------
 modules_k/drouting/dr_bl.h    |   52 -----------
 modules_k/drouting/drouting.c |   13 ---
 3 files changed, 0 insertions(+), 268 deletions(-)

diff --git a/modules_k/drouting/dr_bl.c b/modules_k/drouting/dr_bl.c
deleted file mode 100644
index 3e38585..0000000
--- a/modules_k/drouting/dr_bl.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2005-2009 Voice Sistem SRL
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * History:
- * ---------
- *  2009-01-19  first version (bogdan)
- */
-
-
-
-#include <string.h>
-
-#include "../../mem/mem.h"
-#include "../../mem/shm_mem.h"
-#include "../../dprint.h"
-#include "../../ut.h"
-#include "../../trim.h"
-#include "prefix_tree.h"
-#include "dr_bl.h"
-
-
-static struct dr_bl *drbl_lists = NULL;
-
-static char **bl_lists=NULL;
-static unsigned int bl_lists_size = 0;
-
-
-int set_dr_bl( modparam_t type, void* val)
-{
-	bl_lists = pkg_realloc( bl_lists, (bl_lists_size+1)*sizeof(char*));
-	if (bl_lists==NULL) {
-		LM_ERR("failed to realloc\n");
-		return -1;
-	}
-	bl_lists[bl_lists_size] = (char*)val;
-	bl_lists_size++;
-	return 0;
-}
-
-
-int init_dr_bls(void)
-{
-	unsigned int i;
-	struct dr_bl *drbl;
-	str name;
-	str val;
-	char *p;
-
-	if (bl_lists==NULL)
-		return 0;
-
-	for( i=0 ; i<bl_lists_size ; i++ ) {
-		LM_DBG("processing bl definition <%s>\n",bl_lists[i]);
-		/* get name */
-		p = strchr( bl_lists[i], '=');
-		if (p==NULL || p== bl_lists[i]) {
-			LM_ERR("blaclist definition <%s> has no name",bl_lists[i]);
-			return -1;
-		}
-		name.s = bl_lists[i];
-		name.len = p - name.s;
-		trim(&name);
-		if (name.len==0) {
-			LM_ERR("empty name in blacklist definition <%s>\n",bl_lists[i]);
-			return -1;
-		}
-		LM_DBG("found list name <%.*s>\n",name.len,name.s);
-		/* alloc structure */
-		drbl = (struct dr_bl*)shm_malloc( sizeof(struct dr_bl) );
-		if (drbl==NULL) {
-			LM_ERR("no more shme memory\n");
-			return -1;
-		}
-		memset( drbl, 0, sizeof(struct dr_bl));
-		/* fill in the types */
-		p++;
-		do {
-			if (drbl->no_types==MAX_TYPES_PER_BL) {
-				LM_ERR("too many types per rule <%s>\n",bl_lists[i]);
-				shm_free(drbl);
-				return -1;
-			}
-			val.s = p;
-			p = strchr( p, ',');
-			if (p==NULL) {
-				val.len = strlen(val.s);
-			} else {
-				val.len = (int)(long)(p - val.s);
-				p++;
-			}
-			trim(&val);
-			if (val.len==0) {
-				LM_ERR("invalid types listing in <%s>\n",bl_lists[i]);
-				shm_free(drbl);
-				return -1;
-			}
-			LM_DBG("found type <%.*s>\n",val.len,val.s);
-			if (str2int( &val, &drbl->types[drbl->no_types])!=0) {
-				LM_ERR("nonnumerical type <%.*s>\n",val.len,val.s);
-				shm_free(drbl);
-				return -1;
-			}
-			drbl->no_types++;
-		}while(p!=NULL);
-
-		pkg_free(bl_lists[i]);
-		bl_lists[i] = NULL;
-
-		/* create backlist for it */
-		//drbl->bl = create_bl_head( 131313, 0/*flags*/, NULL, NULL, &name);
-		//if (drbl->bl==NULL) {
-		//	LM_ERR("failed to create bl <%.*s>\n",name.len,name.s);
-		//	shm_free(drbl);
-		//	return -1;
-		//}
-
-		/* link it */
-		drbl->next = drbl_lists;
-		drbl_lists = drbl;
-	}
-
-	pkg_free(bl_lists);
-	bl_lists = NULL;
-
-	return 0;
-}
-
-
-
-void destroy_dr_bls(void)
-{
-	struct dr_bl *drbl;
-	struct dr_bl *drbl1;
-
-	for( drbl=drbl_lists ; drbl ; ) {
-		drbl1 = drbl;
-		drbl = drbl->next;
-		shm_free(drbl1);
-	}
-}
-
-
-int populate_dr_bls(pgw_addr_t *pgwa)
-{
-	unsigned int i;
-	struct dr_bl *drbl;
-	pgw_addr_t *gw;
-	struct bl_rule *drbl_first;
-	struct bl_rule *drbl_last;
-	struct net *gw_net;
-
-	/* each bl list at a time */
-	for( drbl=drbl_lists ; drbl ; drbl = drbl->next ) {
-		drbl_first = drbl_last = NULL;
-		/* each type at a time */
-		for ( i=0 ; i<drbl->no_types ; i++ ) {
-			/* search in the GW list all GWs of this type */
-			for( gw=pgwa ; gw ; gw=gw->next ) {
-				if (gw->type==drbl->types[i]) {
-					gw_net = mk_net_bitlen( &gw->ip, gw->ip.len*8);
-					if (gw_net==NULL) {
-						LM_ERR("failed to build net mask\n");
-						continue;
-					}
-					/* add this destination to the BL */
-					//add_rule_to_list( &drbl_first, &drbl_last,
-					//	gw_net,
-					//	NULL/*body*/,
-					//	0/*port*/,
-					//	PROTO_NONE/*proto*/,
-					//	0/*flags*/);
-					pkg_free(gw_net);
-				}
-			}
-		}
-		/* the new content for the BL */
-		//if (add_list_to_head( drbl->bl, drbl_first, drbl_last, 1, 0)!=0) {
-		//	LM_ERR("failed to update bl\n");
-		//	return -1;
-		//}
-	}
-
-	return 0;
-}
-
diff --git a/modules_k/drouting/dr_bl.h b/modules_k/drouting/dr_bl.h
deleted file mode 100644
index e9547b0..0000000
--- a/modules_k/drouting/dr_bl.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2005-2009 Voice Sistem SRL
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * History:
- * ---------
- *  2009-01-19  first version (bogdan)
- */
-
-
-#ifndef _DR_DR_BL_H
-#define _DR_DR_BL_H
-
-#include "../../sr_module.h"
-//#include "../../blacklists.h"
-#include "prefix_tree.h"
-
-#define MAX_TYPES_PER_BL 32
-
-struct dr_bl {
-	unsigned int no_types;
-	unsigned int types[MAX_TYPES_PER_BL];
-	struct bl_head *bl;
-	struct dr_bl *next;
-};
-
-int set_dr_bl( modparam_t type, void* val);
-
-int init_dr_bls(void);
-
-void destroy_dr_bls(void);
-
-int populate_dr_bls(pgw_addr_t *pgwa);
-
-#endif
diff --git a/modules_k/drouting/drouting.c b/modules_k/drouting/drouting.c
index 9c92a31..7120338 100644
--- a/modules_k/drouting/drouting.c
+++ b/modules_k/drouting/drouting.c
@@ -50,7 +50,6 @@
 #include "dr_load.h"
 #include "prefix_tree.h"
 #include "routing.h"
-#include "dr_bl.h"
 
 
 /*** DB relatede stuff ***/
@@ -174,7 +173,6 @@ static param_export_t params[] = {
 	{"sort_order",      INT_PARAM, &sort_order      },
 	{"fetch_rows",      INT_PARAM, &dr_fetch_rows   },
 	{"force_dns",       INT_PARAM, &dr_force_dns    },
-	{"define_blacklist",STR_PARAM|USE_FUNC_PARAM, (void*)set_dr_bl },
 	{0, 0, 0}
 };
 
@@ -261,9 +259,6 @@ static inline int dr_reload_data( void )
 	if (old_data)
 		free_rt_data( old_data, 1 );
 
-	/* generate new blacklist from the routing info */
-	populate_dr_bls((*rdata)->pgw_addr_l);
-
 	return 0;
 }
 
@@ -346,11 +341,6 @@ static int dr_init(void)
 		}
 	}
 
-	if (init_dr_bls()!=0) {
-		LM_ERR("failed to init DR blacklists\n");
-		return E_CFG;
-	}
-
 	/* data pointer in shm */
 	rdata = (rt_data_t**)shm_malloc( sizeof(rt_data_t*) );
 	if (rdata==0) {
@@ -467,9 +457,6 @@ static int dr_exit(void)
 	if(data_refcnt)
 		shm_free(data_refcnt);
 
-	/* destroy blacklists */
-	destroy_dr_bls();
-
 	return 0;
 }
 




More information about the sr-dev mailing list