diff --git a/README.md b/README.md index 9ca3e4d92..32c3804e6 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ option and which are reproduced below: -G, --graphite-interval=INT Graphite data statistics send interval --graphite-prefix=STRING Graphite prefix for every line -T, --tos=INT TOS value to set on streams + --control-tos=INT TOS value to set on control-ng interface -o, --timeout=SECS RTP timeout -s, --silent-timeout=SECS RTP timeout for muted -a, --final-timeout=SECS Call timeout @@ -308,6 +309,11 @@ The options are described in more detail below. Takes an integer as argument and if given, specifies the TOS value that should be set in outgoing packets. The default is to leave the TOS field untouched. A typical value is 184 (*Expedited Forwarding*). +* --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. + * -o, --timeout Takes the number of seconds as argument after which a media stream should be considered dead if no media 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/cli.c b/daemon/cli.c index b089a8e69..8ea48eaa5 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -172,8 +172,8 @@ static void cli_incoming_list_totals(char* buffer, int len, struct callmaster* m printlen = snprintf(replybuffer,(outbufend-replybuffer), "Control statistics:\n\n"); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " %20s | %10s | %10s | %10s | %10s | %10s | %10s | %10s | %10s \n", - "Proxy", "Offer", "Answer", "Delete", "Ping", "List", "Query", "StartRec", "Errors"); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " %20s | %10s | %10s | %10s | %10s | %10s | %10s | %10s | %10s | %10s \n", + "Proxy", "Offer", "Answer", "Delete", "Ping", "List", "Query", "StartRec", "StopRec", "Errors"); ADJUSTLEN(printlen,outbufend,replybuffer); mutex_lock(&m->cngs_lock); 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); diff --git a/etc/rtpengine.sample.conf b/etc/rtpengine.sample.conf index 14df93156..a8ee15e19 100644 --- a/etc/rtpengine.sample.conf +++ b/etc/rtpengine.sample.conf @@ -21,6 +21,7 @@ listen-ng = 127.0.0.1:2223 timeout = 60 silent-timeout = 3600 tos = 184 +#control-tos = 184 # delete-delay = 30 # final-timeout = 10800