Skip to content

Commit

Permalink
config: Add command to request all filters
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse authored and villesavolainen committed Feb 21, 2018
1 parent 014ac02 commit d89bdb7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/config/config-connection.c
Expand Up @@ -150,6 +150,36 @@ static int config_connection_request(struct config_connection *conn,
return 0;
}

static int config_filters_request(struct config_connection *conn)
{
struct config_filter_parser *const *filters = config_filter_get_all(config_filter);
o_stream_cork(conn->output);
while(*filters != NULL) {
const struct config_filter *filter = &(*filters)->filter;
o_stream_nsend_str(conn->output, "FILTER");
if (filter->service != NULL)
o_stream_nsend_str(conn->output, t_strdup_printf("\tservice=%s",
filter->service));
if (filter->local_name != NULL)
o_stream_nsend_str(conn->output, t_strdup_printf("\tlocal-name=%s",
filter->local_name));
if (filter->local_bits > 0)
o_stream_nsend_str(conn->output, t_strdup_printf("\tlocal-net=%s/%u",
net_ip2addr(&filter->local_net),
filter->local_bits));
if (filter->remote_bits > 0)
o_stream_nsend_str(conn->output, t_strdup_printf("\tremote-net=%s/%u",
net_ip2addr(&filter->remote_net),
filter->remote_bits));
o_stream_nsend_str(conn->output, "\n");
filters++;
}
o_stream_nsend_str(conn->output, "\n");
o_stream_uncork(conn->output);
return 0;
}


static void config_connection_input(struct config_connection *conn)
{
const char *const *args, *line;
Expand Down Expand Up @@ -186,6 +216,10 @@ static void config_connection_input(struct config_connection *conn)
if (config_connection_request(conn, args + 1) < 0)
break;
}
if (strcmp(args[0], "FILTERS") == 0) {
if (config_filters_request(conn) < 0)
break;
}
}
}

Expand Down

0 comments on commit d89bdb7

Please sign in to comment.