MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / init_dr_bls

Function init_dr_bls

modules/drouting/dr_bl.c:71–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69
70
71int init_dr_bls(struct head_db * head_db_start)
72{
73 struct dr_bl *drbl;
74 str name;
75 str val;
76 str part_name;
77 char *p = NULL;
78 blk_list_raw_t *it_blk, *to_clean;
79 struct head_db * current_partition;
80
81 if (bl_lists==NULL)
82 return 0;
83 it_blk = bl_lists;
84
85 while( it_blk!=NULL ) {
86 LM_DBG("processing bl definition <%s>\n",it_blk->def);
87 /* get name */
88 if( use_partitions ) {
89 p = strchr(it_blk->def, ':');
90 part_name.s = it_blk->def;
91 part_name.len = p-part_name.s;
92 if( p==NULL || p==it_blk->def ) {
93 LM_ERR("blacklist definition <%s> has no partition name\n",
94 it_blk->def);
95 return -1;
96 }
97 trim(&part_name);
98 if( (current_partition = get_partition(&part_name))==NULL ) {
99 LM_ERR("could not find partition name <%.*s> from blacklist "
100 "definition <%s>\n", part_name.len, part_name.s,
101 it_blk->def);
102 return -1;
103 }
104 name.s = p+1;
105 } else {
106 current_partition = head_db_start;
107 if( current_partition == 0 ) {
108 LM_CRIT("Default partition not registered\n");
109 }
110 name.s = it_blk->def;
111 }
112 p = strchr( name.s, '=');
113 if (p==NULL || p==name.s) {
114 LM_ERR("blacklist definition <%s> has no name",it_blk->def);
115 return -1;
116 }
117 name.len = p - name.s;
118 trim(&name);
119 if (name.len==0) {
120 LM_ERR("empty name in blacklist definition <%s>\n",it_blk->def);
121 return -1;
122 }
123 LM_DBG("found list name <%.*s>\n",name.len,name.s);
124 /* alloc structure */
125 drbl = (struct dr_bl*)shm_malloc( sizeof(struct dr_bl) );
126 if (drbl==NULL) {
127 LM_ERR("no more shme memory\n");
128 return -1;

Callers 1

dr_initFunction · 0.85

Calls 7

trimFunction · 0.85
shm_mallocFunction · 0.85
shm_freeFunction · 0.85
str2intFunction · 0.85
create_bl_headFunction · 0.85
_strClass · 0.85
get_partitionFunction · 0.70

Tested by

no test coverage detected