diff --git a/daemon/call.h b/daemon/call.h index 73602e688..af6fbd331 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -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; diff --git a/daemon/control_ng.c b/daemon/control_ng.c index c956be322..ee46baafd 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -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: diff --git a/daemon/control_ng.h b/daemon/control_ng.h index fe4ee9a6c..027ab8234 100644 --- a/daemon/control_ng.h +++ b/daemon/control_ng.h @@ -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 diff --git a/daemon/main.c b/daemon/main.c index a3e05023f..1c3a00c6b 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -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"); } diff --git a/daemon/media_socket.h b/daemon/media_socket.h index 6e27679b5..7886a2a5b 100644 --- a/daemon/media_socket.h +++ b/daemon/media_socket.h @@ -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 *); diff --git a/daemon/socket.h b/daemon/socket.h index 424e529c5..5c57fa5a5 100644 --- a/daemon/socket.h +++ b/daemon/socket.h @@ -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);