[SR-Users] Simulating kamailio config flows

Victor Seva linuxmaniac at torreviejawireless.org
Fri May 24 09:22:45 CEST 2013


2013/5/23 Victor Seva <linuxmaniac at torreviejawireless.org>:
> 2013/5/23 Daniel-Constantin Mierla <miconda at gmail.com>:
>> - update the interpreter to use pv cache instead of own spec per pv (I can
>> do it, being in my list and hopefully is no big change)
>
> I will try to do it myself just to get familliar with this area. Let's
> see how it goes.

You mean modifiing cfg.y on:

pvar: PVAR {
pv_spec=pkg_malloc(sizeof(*pv_spec));
if (!pv_spec) {
yyerror("Not enough memory");
YYABORT;
}
memset(pv_spec, 0, sizeof(*pv_spec));
s_tmp.s=$1; s_tmp.len=strlen($1);
if (pv_parse_spec(&s_tmp, pv_spec)==0){
yyerror("unknown script pseudo variable %s", $1 );
pkg_free(pv_spec);
pv_spec=0;
YYABORT;
}
$$=pv_spec;
}
;

avp_pvar: AVP_OR_PVAR {
lval_tmp=pkg_malloc(sizeof(*lval_tmp));
if (!lval_tmp) {
yyerror("Not enough memory");
YYABORT;
}
memset(lval_tmp, 0, sizeof(*lval_tmp));
s_tmp.s=$1; s_tmp.len=strlen(s_tmp.s);
if (pv_parse_spec2(&s_tmp, &lval_tmp->lv.pvs, 1)==0){
/* not a pvar, try avps */
/* lval_tmp might be partially filled by the failed
  pv_parse_spec2() (especially if the avp name is the
  same as a pv class) => clean it again */
memset(lval_tmp, 0, sizeof(*lval_tmp));
lval_tmp->lv.avps.type|= AVP_NAME_STR;
lval_tmp->lv.avps.name.s.s = s_tmp.s+1;
lval_tmp->lv.avps.name.s.len = s_tmp.len-1;
lval_tmp->type=LV_AVP;
}else{
lval_tmp->type=LV_PVAR;
}
$$ = lval_tmp;
DBG("parsed ambigous avp/pvar \"%.*s\" to %d\n",
s_tmp.len, s_tmp.s, lval_tmp->type);
}
;

Not malloc pv_spec and instead use pv_cache_get()?

Cheers,
Victor



More information about the sr-users mailing list