Skip to content

Commit e7d09a1

Browse files
committed
mi: create new tcp class for listing and terminating
1 parent 7194f2f commit e7d09a1

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

mi/mi_core.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,15 +1047,6 @@ static const mi_export_t mi_core_cmds[] = {
10471047
{w_log_mute_state_2, {"consumer", "mute_state", 0}},
10481048
{EMPTY_MI_RECIPE}}, {0}
10491049
},
1050-
{ "list_tcp_conns", "list all ongoing TCP based connections, optionally filtered by proto", 0, 0, {
1051-
{mi_tcp_list_conns, {0}},
1052-
{mi_tcp_list_conns, {"proto", 0}},
1053-
{EMPTY_MI_RECIPE}}, {0}
1054-
},
1055-
{ "tcp_close_conn", "close a given TCP connection", 0, 0, {
1056-
{mi_tcp_close_conn, {"ipport", 0}},
1057-
{EMPTY_MI_RECIPE}}, {0}
1058-
},
10591050
{ "reload_routes", "triggers the script (routes only) reload", 0, 0, {
10601051
{w_reload_routes, {0}},
10611052
{EMPTY_MI_RECIPE}}, {0}
@@ -1067,6 +1058,19 @@ static const mi_export_t mi_core_cmds[] = {
10671058
},
10681059
{EMPTY_MI_EXPORT}
10691060
};
1061+
1062+
static const mi_export_t mi_tcp_cmds[] = {
1063+
{ "list", "list all ongoing TCP based connections, optionally filtered by proto", 0, 0, {
1064+
{mi_tcp_list_conns, {0}},
1065+
{mi_tcp_list_conns, {"proto", 0}},
1066+
{EMPTY_MI_RECIPE}}, {"list_tcp_conns", 0}
1067+
},
1068+
{ "close", "close a given TCP connection", 0, 0, {
1069+
{mi_tcp_close_conn, {"ipport", 0}},
1070+
{EMPTY_MI_RECIPE}}, {0}
1071+
},
1072+
{EMPTY_MI_EXPORT}
1073+
};
10701074
static const mi_export_t mi_mem_cmds[] = {
10711075
#if defined(Q_MALLOC) && defined(DBG_MALLOC)
10721076
{ "shm_check", "complete scan of the shared memory pool "
@@ -1171,6 +1175,10 @@ int init_mi_core(void)
11711175
LM_ERR("unable to register core MI cmds\n");
11721176
return -1;
11731177
}
1178+
if (register_mi_mod( "tcp", mi_tcp_cmds)<0) {
1179+
LM_ERR("unable to register tcp MI cmds\n");
1180+
return -1;
1181+
}
11741182
if (register_mi_mod( "mem", mi_mem_cmds)<0) {
11751183
LM_ERR("unable to register mem MI cmds\n");
11761184
return -1;

0 commit comments

Comments
 (0)