Browse Source

Add option to set TOS for control-ng interface

pull/430/head
Claudiu Boriga 8 years ago
parent
commit
3472821ccc
6 changed files with 22 additions and 10 deletions
  1. +1
    -0
      daemon/call.h
  2. +9
    -4
      daemon/control_ng.c
  3. +1
    -1
      daemon/control_ng.h
  4. +7
    -1
      daemon/main.c
  5. +1
    -3
      daemon/media_socket.h
  6. +3
    -1
      daemon/socket.h

+ 1
- 0
daemon/call.h View File

@ -405,6 +405,7 @@ struct callmaster_config {
unsigned int redis_expires_secs;
char *b2b_url;
unsigned char default_tos;
unsigned char control_tos;
enum xmlrpc_format fmt;
endpoint_t graphite_ep;
int graphite_interval;


+ 9
- 4
daemon/control_ng.c View File

@ -305,7 +305,7 @@ out:
struct control_ng *control_ng_new(struct poller *p, endpoint_t *ep, struct callmaster *m) {
struct control_ng *control_ng_new(struct poller *p, endpoint_t *ep, struct callmaster *m, unsigned char tos) {
struct control_ng *c;
if (!p || !m)
@ -318,9 +318,14 @@ struct control_ng *control_ng_new(struct poller *p, endpoint_t *ep, struct callm
if (udp_listener_init(&c->udp_listeners[0], p, ep, control_ng_incoming, &c->obj))
goto fail2;
if (ipv46_any_convert(ep) && udp_listener_init(&c->udp_listeners[1], p, ep, control_ng_incoming, &c->obj))
goto fail2;
if (tos)
set_tos(&c->udp_listeners[0].sock,tos);
if (ipv46_any_convert(ep)) {
if (udp_listener_init(&c->udp_listeners[1], p, ep, control_ng_incoming, &c->obj))
goto fail2;
if (tos)
set_tos(&c->udp_listeners[1].sock,tos);
}
return c;
fail2:


+ 1
- 1
daemon/control_ng.h View File

@ -30,6 +30,6 @@ struct control_ng {
struct udp_listener udp_listeners[2];
};
struct control_ng *control_ng_new(struct poller *, endpoint_t *, struct callmaster *);
struct control_ng *control_ng_new(struct poller *, endpoint_t *, struct callmaster *, unsigned char);
#endif

+ 7
- 1
daemon/main.c View File

@ -58,6 +58,7 @@ static endpoint_t homer_ep;
static int homer_protocol = SOCK_DGRAM;
static int homer_id = 2001;
static int tos;
static int control_tos;
static int table = -1;
static int no_fallback;
static unsigned int timeout;
@ -268,6 +269,7 @@ static void options(int *argc, char ***argv) {
{ "graphite-interval", 'G', 0, G_OPTION_ARG_INT, &graphite_interval, "Graphite send interval in seconds", "INT" },
{ "graphite-prefix",0, 0, G_OPTION_ARG_STRING, &graphite_prefix_s, "Prefix for graphite line", "STRING"},
{ "tos", 'T', 0, G_OPTION_ARG_INT, &tos, "Default TOS value to set on streams", "INT" },
{ "control-tos",0 , 0, G_OPTION_ARG_INT, &control_tos, "Default TOS value to set on control-ng", "INT" },
{ "timeout", 'o', 0, G_OPTION_ARG_INT, &timeout, "RTP timeout", "SECS" },
{ "silent-timeout",'s',0,G_OPTION_ARG_INT, &silent_timeout,"RTP timeout for muted", "SECS" },
{ "final-timeout",'a',0,G_OPTION_ARG_INT, &final_timeout, "Call timeout", "SECS" },
@ -371,6 +373,9 @@ static void options(int *argc, char ***argv) {
if (tos < 0 || tos > 255)
die("Invalid TOS value");
if (control_tos < 0 || control_tos > 255)
die("Invalid control-ng TOS value");
if (timeout <= 0)
timeout = 60;
@ -528,6 +533,7 @@ no_kernel:
mc.final_timeout = final_timeout;
mc.delete_delay = delete_delay;
mc.default_tos = tos;
mc.control_tos = control_tos;
mc.b2b_url = b2b_url;
mc.fmt = xmlrpc_fmt;
mc.graphite_ep = graphite_ep;
@ -562,7 +568,7 @@ no_kernel:
cn = NULL;
if (ng_listen_ep.port) {
interfaces_exclude_port(ng_listen_ep.port);
cn = control_ng_new(ctx->p, &ng_listen_ep, ctx->m);
cn = control_ng_new(ctx->p, &ng_listen_ep, ctx->m, control_tos);
if (!cn)
die("Failed to open UDP control connection port");
}


+ 1
- 3
daemon/media_socket.h View File

@ -78,9 +78,7 @@ int is_local_endpoint(const struct intf_address *addr, unsigned int port);
//int get_port(socket_t *r, unsigned int port, const struct local_intf *lif, const struct call *c);
//void release_port(socket_t *r, const struct local_intf *);
INLINE void set_tos(socket_t *s, unsigned int tos) {
s->family->tos(s, tos);
}
int __get_consecutive_ports(GQueue *out, unsigned int num_ports, unsigned int wanted_start_port,
struct intf_spec *spec, const str *);
int get_consecutive_ports(GQueue *out, unsigned int num_ports, const struct logical_intf *log, const str *);


+ 3
- 1
daemon/socket.h View File

@ -261,7 +261,9 @@ INLINE int ipv46_any_convert(endpoint_t *ep) {
#define endpoint_packet_header(o, src, dst, len) (dst)->address.family->packet_header(o, src, dst, len)
INLINE void set_tos(socket_t *s, unsigned int tos) {
s->family->tos(s, tos);
}
socktype_t *get_socket_type(const str *s);
socktype_t *get_socket_type_c(const char *s);


Loading…
Cancel
Save