Skip to content

Commit 213e777

Browse files
committed
rtpproxy: restructure rtpproxy_mi show command
Due to the initial structure, some useful information was stripped by the mi_json module. Added the "Set" as root node, followed by a child for each node
1 parent 20c1753 commit 213e777

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

modules/rtpproxy/rtpproxy.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@
206206
#define MI_RTP_PROXY_NOT_FOUND_LEN (sizeof(MI_RTP_PROXY_NOT_FOUND)-1)
207207
#define MI_PING_DISABLED "NATping disabled from script"
208208
#define MI_PING_DISABLED_LEN (sizeof(MI_PING_DISABLED)-1)
209-
#define MI_SET "set"
209+
#define MI_SET "Set"
210210
#define MI_SET_LEN (sizeof(MI_SET)-1)
211+
#define MI_NODE "node"
212+
#define MI_NODE_LEN (sizeof(MI_NODE)-1)
211213
#define MI_INDEX "index"
212214
#define MI_INDEX_LEN (sizeof(MI_INDEX)-1)
213215
#define MI_DISABLED "disabled"
@@ -999,15 +1001,15 @@ static struct mi_root* mi_enable_rtp_proxy(struct mi_root* cmd_tree,
9991001
}
10001002

10011003

1002-
#define add_rtpp_node_int_info(_parent, _name, _name_len, _value, _child,\
1004+
#define add_rtpp_node_int_info(_parent, _name, _name_len, _value, _attr,\
10031005
_len, _string, _error)\
10041006
do {\
10051007
(_string) = int2str((_value), &(_len));\
10061008
if((_string) == 0){\
10071009
LM_ERR("cannot convert int value\n");\
10081010
goto _error;\
10091011
}\
1010-
if(((_child) = add_mi_node_child((_parent), MI_DUP_VALUE, (_name), \
1012+
if(((_attr) = add_mi_attr((_parent), MI_DUP_VALUE, (_name), \
10111013
(_name_len), (_string), (_len)) ) == 0)\
10121014
goto _error;\
10131015
}while(0);
@@ -1061,7 +1063,7 @@ static struct mi_root* mi_reload_rtpproxies(struct mi_root* cmd_tree, void* para
10611063
static struct mi_root* mi_show_rtpproxies(struct mi_root* cmd_tree,
10621064
void* param)
10631065
{
1064-
struct mi_node* node, *crt_node, *child;
1066+
struct mi_node* node, *crt_node, *set_node;
10651067
struct mi_root* root;
10661068
struct mi_attr * attr;
10671069
struct rtpp_set * rtpp_list;
@@ -1086,37 +1088,38 @@ static struct mi_root* mi_show_rtpproxies(struct mi_root* cmd_tree,
10861088
for(rtpp_list = (*rtpp_set_list)->rset_first; rtpp_list != NULL;
10871089
rtpp_list = rtpp_list->rset_next){
10881090

1091+
id = int2str(rtpp_list->id_set, &id_len);
1092+
if(!id){
1093+
LM_ERR("cannot convert set id\n");
1094+
goto error;
1095+
}
1096+
1097+
if(!(set_node = add_mi_node_child(node, MI_IS_ARRAY|MI_DUP_VALUE, MI_SET, MI_SET_LEN,
1098+
id, id_len))) {
1099+
LM_ERR("cannot add the set node to the tree\n");
1100+
goto error;
1101+
}
1102+
10891103
for(crt_rtpp = rtpp_list->rn_first; crt_rtpp != NULL;
10901104
crt_rtpp = crt_rtpp->rn_next){
10911105

1092-
id = int2str(rtpp_list->id_set, &id_len);
1093-
if(!id){
1094-
LM_ERR("cannot convert set id\n");
1095-
goto error;
1096-
}
1097-
1098-
if(!(crt_node = add_mi_node_child(node, 0, crt_rtpp->rn_url.s,
1099-
crt_rtpp->rn_url.len, 0,0)) ) {
1106+
if(!(crt_node = add_mi_node_child(set_node, MI_DUP_VALUE,
1107+
MI_NODE, MI_NODE_LEN,
1108+
crt_rtpp->rn_url.s, crt_rtpp->rn_url.len)) ) {
11001109
LM_ERR("cannot add the child node to the tree\n");
11011110
goto error;
11021111
}
11031112

11041113
LM_DBG("adding node name %s \n",crt_rtpp->rn_url.s );
11051114

1106-
if((attr = add_mi_attr(crt_node, MI_DUP_VALUE, MI_SET, MI_SET_LEN,
1107-
id, id_len))== 0){
1108-
LM_ERR("cannot add attributes to the node\n");
1109-
goto error;
1110-
}
1111-
11121115
add_rtpp_node_int_info(crt_node, MI_INDEX, MI_INDEX_LEN,
1113-
crt_rtpp->idx, child, len,string,error);
1116+
crt_rtpp->idx, attr, len,string,error);
11141117
add_rtpp_node_int_info(crt_node, MI_DISABLED, MI_DISABLED_LEN,
1115-
crt_rtpp->rn_disabled, child, len,string,error);
1118+
crt_rtpp->rn_disabled, attr, len,string,error);
11161119
add_rtpp_node_int_info(crt_node, MI_WEIGHT, MI_WEIGHT_LEN,
1117-
crt_rtpp->rn_weight, child, len, string,error);
1120+
crt_rtpp->rn_weight, attr, len, string,error);
11181121
add_rtpp_node_int_info(crt_node, MI_RECHECK_TICKS,MI_RECHECK_T_LEN,
1119-
crt_rtpp->rn_recheck_ticks, child, len, string, error);
1122+
crt_rtpp->rn_recheck_ticks, attr, len, string, error);
11201123
}
11211124
}
11221125

0 commit comments

Comments
 (0)