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

Function add_rule_api

modules/drouting/dr_api_internal.c:188–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188static int add_rule_api(dr_head_p partition,unsigned int rid,
189 str *prefix, unsigned int gr_id, unsigned int priority,
190 tmrec_expr *time_rec, void *attr)
191{
192 rt_info_t * rule = shm_malloc(sizeof(rt_info_t));
193 if (rule == NULL){
194 LM_ERR("no more shm mem(1)\n");
195 return -1;
196 }
197
198 memset(rule, 0, sizeof(rt_info_t));
199 rule->id = rid;
200 rule->priority = priority;
201 rule->time_rec = time_rec;
202 rule->attrs.s = (char*) attr;
203
204 if (prefix->len) {
205 if ( add_prefix(partition->pt, prefix, rule, gr_id,
206 shm_malloc_func, shm_free_func)!=0 ) {
207 LM_ERR("failed to add prefix route\n");
208 return -1;
209 }
210 } else {
211 if ( add_rt_info( &partition->noprefix, rule, gr_id,
212 shm_malloc_func, shm_free_func)!=0 ) {
213 LM_ERR("failed to add prefixless route\n");
214 return -1;
215 }
216 }
217 return 0;
218}
219

Callers

nothing calls this directly

Calls 3

shm_mallocFunction · 0.85
add_prefixFunction · 0.85
add_rt_infoFunction · 0.85

Tested by

no test coverage detected