Browse Source

Make 'rtpengine-ctl' configurable via rtpengine-ctl

pull/456/head
Claudiu Boriga 8 years ago
parent
commit
ff2a278ad7
5 changed files with 48 additions and 6 deletions
  1. +2
    -1
      README.md
  2. +39
    -0
      daemon/cli.c
  3. +3
    -1
      daemon/control_ng.c
  4. +1
    -0
      daemon/control_ng.h
  5. +3
    -4
      daemon/main.c

+ 2
- 1
README.md View File

@ -296,7 +296,8 @@ The options are described in more detail below.
* --control-tos
Takes an integer as argument and if given, specifies the TOS value that should be set in the control-ng
interface packets. The default is to leave the TOS field untouched.
interface packets. The default is to leave the TOS field untouched. This parameter can also be set or listed
via rtpengine-ctl.
* -o, --timeout


+ 39
- 0
daemon/cli.c View File

@ -51,6 +51,7 @@ static void cli_incoming_set_redisallowederrors(str *instr, struct streambuf *re
static void cli_incoming_set_redisdisabletime(str *instr, struct streambuf *replybuffer);
static void cli_incoming_set_redisconnecttimeout(str *instr, struct streambuf *replybuffer);
static void cli_incoming_set_rediscmdtimeout(str *instr, struct streambuf *replybuffer);
static void cli_incoming_set_controltos(str *instr, struct streambuf *replybuffer);
static void cli_incoming_list_numsessions(str *instr, struct streambuf *replybuffer);
static void cli_incoming_list_maxsessions(str *instr, struct streambuf *replybuffer);
@ -66,6 +67,7 @@ static void cli_incoming_list_redisallowederrors(str *instr, struct streambuf *r
static void cli_incoming_list_redisdisabletime(str *instr, struct streambuf *replybuffer);
static void cli_incoming_list_redisconnecttimeout(str *instr, struct streambuf *replybuffer);
static void cli_incoming_list_rediscmdtimeout(str *instr, struct streambuf *replybuffer);
static void cli_incoming_list_controltos(str *instr, struct streambuf *replybuffer);
static const cli_handler_t cli_top_handlers[] = {
{ "list", cli_incoming_list },
@ -88,6 +90,7 @@ static const cli_handler_t cli_set_handlers[] = {
{ "redisdisabletime", cli_incoming_set_redisdisabletime },
{ "redisconnecttimeout", cli_incoming_set_redisconnecttimeout },
{ "rediscmdtimeout", cli_incoming_set_rediscmdtimeout },
{ "controltos", cli_incoming_set_controltos },
{ NULL, },
};
static const cli_handler_t cli_list_handlers[] = {
@ -104,6 +107,7 @@ static const cli_handler_t cli_list_handlers[] = {
{ "redisdisabletime", cli_incoming_list_redisdisabletime },
{ "redisconnecttimeout", cli_incoming_list_redisconnecttimeout },
{ "rediscmdtimeout", cli_incoming_list_rediscmdtimeout },
{ "controltos", cli_incoming_list_controltos },
{ NULL, },
};
@ -1026,3 +1030,38 @@ static void cli_incoming_set_rediscmdtimeout(str *instr, struct streambuf *reply
if (!fail)
streambuf_printf(replybuffer, "Success setting redis-cmd-timeout to %ld\n", timeout);
}
static void cli_incoming_list_controltos(str *instr, struct streambuf *replybuffer) {
rwlock_lock_r(&rtpe_config.config_lock);
streambuf_printf(replybuffer, "%d\n", rtpe_config.control_tos);
rwlock_unlock_r(&rtpe_config.config_lock);
}
static void cli_incoming_set_controltos(str *instr, struct streambuf *replybuffer) {
long tos;
char *endptr;
int i;
if (str_shift(instr, 1)) {
streambuf_printf(replybuffer, "%s\n", "More parameters required.");
return ;
}
tos = strtol(instr->s, &endptr, 10);
if (tos < 0 || tos > 255) {
streambuf_printf(replybuffer, "Invalid control-tos value %ld, must be between 0 and 255\n", tos);
return;
}
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.control_tos = tos;
rwlock_unlock_w(&rtpe_config.config_lock);
for (i=0; i < G_N_ELEMENTS(rtpe_control_ng->udp_listeners); i++) {
if (rtpe_control_ng->udp_listeners[i].fd != -1) {
set_tos(&rtpe_control_ng->udp_listeners[i],tos);
}
}
streambuf_printf(replybuffer, "Success setting redis-connect-timeout to %ld\n", tos);
}

+ 3
- 1
daemon/control_ng.c View File

@ -18,7 +18,7 @@
mutex_t rtpe_cngs_lock;
GHashTable *rtpe_cngs_hash;
struct control_ng *rtpe_control_ng;
static void timeval_update_request_time(struct request_time *request, const struct timeval *offer_diff) {
@ -323,6 +323,8 @@ struct control_ng *control_ng_new(struct poller *p, endpoint_t *ep, unsigned cha
c = obj_alloc0("control_ng", sizeof(*c), NULL);
cookie_cache_init(&c->cookie_cache);
c->udp_listeners[0].fd = -1;
c->udp_listeners[1].fd = -1;
if (udp_listener_init(&c->udp_listeners[0], p, ep, control_ng_incoming, &c->obj))
goto fail2;


+ 1
- 0
daemon/control_ng.h View File

@ -33,5 +33,6 @@ void control_ng_init(void);
extern mutex_t rtpe_cngs_lock;
extern GHashTable *rtpe_cngs_hash;
extern struct control_ng *rtpe_control_ng;
#endif

+ 3
- 4
daemon/main.c View File

@ -501,7 +501,6 @@ static void init_everything() {
static void create_everything(void) {
struct control_tcp *ct;
struct control_udp *cu;
struct control_ng *cn;
struct cli *cl;
struct timeval tmp_tv;
struct timeval redis_start, redis_stop;
@ -556,11 +555,11 @@ no_kernel:
die("Failed to open UDP control connection port");
}
cn = NULL;
rtpe_control_ng = NULL;
if (rtpe_config.ng_listen_ep.port) {
interfaces_exclude_port(rtpe_config.ng_listen_ep.port);
cn = control_ng_new(rtpe_poller, &rtpe_config.ng_listen_ep, rtpe_config.control_tos);
if (!cn)
rtpe_control_ng = control_ng_new(rtpe_poller, &rtpe_config.ng_listen_ep, rtpe_config.control_tos);
if (!rtpe_control_ng)
die("Failed to open UDP control connection port");
}


Loading…
Cancel
Save