Skip to content

Commit e8101df

Browse files
committed
usrloc: consolidate mi output for ul_show_contact
- same output format for ul_show_contact and ul_dump
1 parent 4f070e2 commit e8101df

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

modules/usrloc/ul_mi.c

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ struct mi_root* mi_usrloc_show_contact(struct mi_root *cmd, void *param)
577577
ucontact_t* con;
578578
str *aor;
579579
int ret;
580-
str use_sock_str;
580+
time_t t;
581581

582582
node = cmd->node.kids;
583583
if (node==NULL || node->next==NULL || node->next->next!=NULL)
@@ -593,6 +593,8 @@ struct mi_root* mi_usrloc_show_contact(struct mi_root *cmd, void *param)
593593
if ( mi_fix_aor(aor)!=0 )
594594
return init_mi_tree( 400, "Domain missing in AOR", 21);
595595

596+
t = time(0);
597+
596598
lock_udomain( dom, aor);
597599

598600
ret = get_urecord( dom, aor, &rec);
@@ -606,16 +608,6 @@ struct mi_root* mi_usrloc_show_contact(struct mi_root *cmd, void *param)
606608
rpl = 0;
607609

608610
for( con=rec->contacts ; con ; con=con->next) {
609-
if(con->sock) {
610-
if(con->sock->adv_sock_str.len) {
611-
use_sock_str = con->sock->adv_sock_str;
612-
} else {
613-
use_sock_str = con->sock->sock_str;
614-
}
615-
} else {
616-
use_sock_str.s = "NULL";
617-
use_sock_str.len = 4;
618-
}
619611

620612
if (VALID_CONTACT( con, act_time)) {
621613
if (rpl_tree==0) {
@@ -626,28 +618,7 @@ struct mi_root* mi_usrloc_show_contact(struct mi_root *cmd, void *param)
626618
rpl->flags |= MI_IS_ARRAY;
627619
}
628620

629-
node = addf_mi_node_child( rpl, 0, "Contact", 7,
630-
"<%.*s>;q=%s;expires=%d;flags=0x%X;cflags=0x%X;socket=<%.*s>;"
631-
"callid=<%.*s>;"
632-
"methods=0x%X"
633-
"%s%.*s%s" /*received*/
634-
"%s%.*s%s" /*user-agent*/
635-
"%s%.*s%s", /*path*/
636-
con->c.len, ZSW(con->c.s),
637-
q2str(con->q, 0), (int)(con->expires - act_time),
638-
con->flags, con->cflags,
639-
use_sock_str.len,use_sock_str.s,
640-
con->callid.len, ZSW(con->callid.s),
641-
con->methods,
642-
con->received.len?";received=<":"",con->received.len,
643-
ZSW(con->received.s), con->received.len?">":"",
644-
con->user_agent.len?";user_agent=<":"",con->user_agent.len,
645-
ZSW(con->user_agent.s), con->user_agent.len?">":"",
646-
con->path.len?";path=<":"", con->path.len,
647-
ZSW(con->path.s), con->path.len?">":""
648-
);
649-
if (node==0)
650-
goto error;
621+
if (mi_add_aor_node(rpl, rec, t, 0)!=0) goto error;
651622
}
652623
}
653624

0 commit comments

Comments
 (0)