/* use tree tn, match var, by mode, output in avp params */ static int mt_match(sip_msg_t *msg, str *tname, str *tomatch, int mval) { m_tree_t *tr = NULL; if(msg==NULL) { LM_ERR("received null msg\n"); return -1; } again: lock_get( mt_lock ); if (mt_reload_flag) { lock_release( mt_lock ); sleep_us(5); goto again; } mt_tree_refcnt++; lock_release( mt_lock ); tr = mt_get_tree(tname); if(tr==NULL) { /* no tree with such name*/ goto error; } if(mt_match_prefix(msg, tr, tomatch, mval)<0) { LM_DBG("no prefix found in [%.*s] for [%.*s]\n", tname->len, tname->s, tomatch->len, tomatch->s); goto error; } lock_get( mt_lock ); mt_tree_refcnt--; lock_release( mt_lock ); return 1; error: lock_get( mt_lock ); mt_tree_refcnt--; lock_release( mt_lock ); return -1; }
/* use tree tn, match var, by mode, output in avp params */ static int mt_match(struct sip_msg *msg, gparam_t *tn, gparam_t *var, gparam_t *mode) { str tname; str tomatch; int mval; m_tree_t *tr = NULL; if(msg==NULL) { LM_ERR("received null msg\n"); return -1; } if(fixup_get_svalue(msg, tn, &tname)<0) { LM_ERR("cannot get the tree name\n"); return -1; } if(fixup_get_svalue(msg, var, &tomatch)<0) { LM_ERR("cannot get the match var\n"); return -1; } if(fixup_get_ivalue(msg, mode, &mval)<0) { LM_ERR("cannot get the mode\n"); return -1; } again: lock_get( mt_lock ); if (mt_reload_flag) { lock_release( mt_lock ); sleep_us(5); goto again; } mt_tree_refcnt++; lock_release( mt_lock ); tr = mt_get_tree(&tname); if(tr==NULL) { /* no tree with such name*/ goto error; } if(mt_match_prefix(msg, tr, &tomatch, mval)<0) { LM_DBG("no prefix found in [%.*s] for [%.*s]\n", tname.len, tname.s, tomatch.len, tomatch.s); goto error; } lock_get( mt_lock ); mt_tree_refcnt--; lock_release( mt_lock ); return 1; error: lock_get( mt_lock ); mt_tree_refcnt--; lock_release( mt_lock ); return -1; }