Skip to content

Commit

Permalink
[avpops] moved avp_print() in core
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-iancu committed Feb 17, 2024
1 parent fa3471e commit c33aea7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 64 deletions.
39 changes: 38 additions & 1 deletion core_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static int w_get_timestamp(struct sip_msg *msg, pv_spec_t *sec_avp,
static int w_script_trace(struct sip_msg *msg, int *log_level,
pv_elem_t *fmt_string, void *info_str);
static int w_is_myself(struct sip_msg *msg, str *host, int *port);
static int w_print_avp(struct sip_msg* msg, char* foo, char *bar)

#ifndef FUZZ_BUILD
static
Expand Down Expand Up @@ -359,7 +360,8 @@ const cmd_export_t core_cmds[]={
{CMD_PARAM_STR, fixup_sr_group, 0},
{CMD_PARAM_STR|CMD_PARAM_OPT, 0, 0}, {0,0,0}},
ALL_ROUTES},

{"avp_print", (cmd_function)w_print_avps, {{0, 0, 0}},
ALL_ROUTES},
{0,0,{{0,0,0}},0}
};

Expand Down Expand Up @@ -1426,3 +1428,38 @@ static int w_is_myself(struct sip_msg *msg, str *host, int *port)
else
return -1;
}

static int w_print_avp(struct sip_msg* msg, char* foo, char *bar)
{
struct usr_avp **avp_list;
struct usr_avp *avp;
int_str val;
str *name;

/* go through all list */
avp_list = get_avp_list();
avp = *avp_list;

LM_INFO("----------- All AVPs in this context --------\n");
LM_INFO(" (SIP txn, script event, timer route, etc.)\n");
for ( ; avp ; avp=avp->next)
{
LM_INFO("p=%p, flags=0x%04X\n",avp, avp->flags);
name = get_avp_name(avp);
LM_INFO(" name=<%.*s>\n",name->len,name->s);
LM_INFO(" id=<%d>\n",avp->id);
get_avp_val( avp, &val);
if (avp->flags&AVP_VAL_STR)
{
LM_INFO(" val_str=<%.*s / %d>\n",val.s.len,val.s.s,
val.s.len);
} else {
LM_INFO(" val_int=<%d>\n",val.n);
}
}
LM_INFO("---------------- END ALL AVPs ---------------\n");

return 1;
}


8 changes: 0 additions & 8 deletions modules/avpops/avpops.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ static int fixup_free_pvname_list(void** param);
static int fixup_free_avp_dbparam(void** param);
static int fixup_avp_shuffle_name(void** param);

static int w_print_avps(struct sip_msg* msg, char* foo, char *bar);
static int w_dbload_avps(struct sip_msg* msg, void* source,
void* param, void *url, str *prefix);
static int w_dbdelete_avps(struct sip_msg* msg, void* source,
Expand Down Expand Up @@ -141,9 +140,6 @@ static const acmd_export_t acmds[] = {
* Exported functions
*/
static const cmd_export_t cmds[] = {
{"avp_print", (cmd_function)w_print_avps, {{0, 0, 0}},
REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|ONREPLY_ROUTE|LOCAL_ROUTE|
STARTUP_ROUTE|TIMER_ROUTE|EVENT_ROUTE},

{"avp_db_load", (cmd_function)w_dbload_avps, {
{CMD_PARAM_STR|CMD_PARAM_NO_EXPAND, fixup_db_avp_source, fixup_free_pkg},
Expand Down Expand Up @@ -1563,8 +1559,4 @@ static int w_is_avp_set(struct sip_msg* msg, char* param, char *op)
return ops_is_avp_set(msg, (struct fis_param*)param);
}

static int w_print_avps(struct sip_msg* msg, char* foo, char *bar)
{
return ops_print_avp();
}

33 changes: 0 additions & 33 deletions modules/avpops/avpops_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,39 +1498,6 @@ int ops_check_avp( struct sip_msg* msg, struct fis_param* src,
}


int ops_print_avp(void)
{
struct usr_avp **avp_list;
struct usr_avp *avp;
int_str val;
str *name;

/* go through all list */
avp_list = get_avp_list();
avp = *avp_list;

LM_INFO("----------- All AVPs in this context --------\n");
LM_INFO(" (SIP txn, script event, timer route, etc.)\n");
for ( ; avp ; avp=avp->next)
{
LM_INFO("p=%p, flags=0x%04X\n",avp, avp->flags);
name = get_avp_name(avp);
LM_INFO(" name=<%.*s>\n",name->len,name->s);
LM_INFO(" id=<%d>\n",avp->id);
get_avp_val( avp, &val);
if (avp->flags&AVP_VAL_STR)
{
LM_INFO(" val_str=<%.*s / %d>\n",val.s.len,val.s.s,
val.s.len);
} else {
LM_INFO(" val_int=<%d>\n",val.n);
}
}
LM_INFO("---------------- END ALL AVPs ---------------\n");

return 1;
}

int ops_subst(struct sip_msg* msg, struct fis_param** src,
struct subst_expr* se)
{
Expand Down
22 changes: 0 additions & 22 deletions modules/avpops/doc/avpops_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1017,28 +1017,6 @@ $avp(foo) = "str3";
xlog("Initial AVP list is: $(avp(foo)[*])\n"); # str3 str2 str1
if(avp_shuffle("$avp(foo)"))
xlog("Shuffled AVP list is: $(avp(foo)[*])\n"); # str1, str3, str2 (for example)
...
</programlisting>
</example>
</section>
<section id="func_avp_print" xreflabel="avp_print()">
<title>
<function moreinfo="none">avp_print()
</function>
</title>
<para>
Prints the list with all the AVPs from memory. This is only a
helper/debug function.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
</para>
<example>
<title><function>avp_print</function> usage</title>
<programlisting format="linespecific">
...
avp_print();
...
</programlisting>
</example>
Expand Down

0 comments on commit c33aea7

Please sign in to comment.