summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-07-30 20:49:23 +0000
committerMark Spencer <markster@digium.com>2003-07-30 20:49:23 +0000
commit56f1a461213de7533fe8ab94e5f9ae30e520d320 (patch)
tree9bb9c8aa5363d5619ad4aaf708bb315648965a49 /channels
parentd407e8e25ea3b8df0b731464105c9c9ff83cfd46 (diff)
Fix TOS bit in SIP when verbose < 2, add support for mgcp TOS bits
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1243 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_mgcp.c35
-rwxr-xr-xchannels/chan_sip.c9
2 files changed, 36 insertions, 8 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index faeb828d7..596fc5c87 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -45,9 +45,16 @@
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/signal.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+
#include <asterisk/dsp.h>
#include <ctype.h>
+#ifndef IPTOS_MINCOST
+#define IPTOS_MINCOST 0x02
+#endif
+
#define MGCPDUMPER
#define DEFAULT_EXPIREY 120
#define MAX_EXPIREY 3600
@@ -100,6 +107,8 @@ static unsigned int cur_pickupgroup = 0;
/* inbanddtmf is actually hooked up. */
/* static int relaxdtmf = 0; */
+static int tos = 0;
+
static int immediate = 0;
static int callwaiting = 0;
@@ -2890,6 +2899,21 @@ int load_module()
ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value);
else
capability &= ~format;
+ } else if (!strcasecmp(v->name, "tos")) {
+ if (sscanf(v->value, "%i", &format) == 1)
+ tos = format & 0xff;
+ else if (!strcasecmp(v->value, "lowdelay"))
+ tos = IPTOS_LOWDELAY;
+ else if (!strcasecmp(v->value, "throughput"))
+ tos = IPTOS_THROUGHPUT;
+ else if (!strcasecmp(v->value, "reliability"))
+ tos = IPTOS_RELIABILITY;
+ else if (!strcasecmp(v->value, "mincost"))
+ tos = IPTOS_MINCOST;
+ else if (!strcasecmp(v->value, "none"))
+ tos = 0;
+ else
+ ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
} else if (!strcasecmp(v->name, "port")) {
if (sscanf(v->value, "%i", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
@@ -2943,9 +2967,14 @@ int load_module()
strerror(errno));
close(mgcpsock);
mgcpsock = -1;
- } else if (option_verbose > 1) {
- ast_verbose(VERBOSE_PREFIX_2 "MGCP Listening on %s:%d\n",
- inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
+ } else {
+ if (option_verbose > 1) {
+ ast_verbose(VERBOSE_PREFIX_2 "MGCP Listening on %s:%d\n",
+ inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
+ ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
+ }
+ if (setsockopt(mgcpsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
+ ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
}
}
pthread_mutex_unlock(&netlock);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7a58af1ec..70ea4fd32 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -5654,15 +5654,14 @@ static int reload_config(void)
strerror(errno));
close(sipsock);
sipsock = -1;
- } else if (option_verbose > 1) {
- ast_verbose(VERBOSE_PREFIX_2 "SIP Listening on %s:%d\n",
+ } else {
+ if (option_verbose > 1) {
+ ast_verbose(VERBOSE_PREFIX_2 "SIP Listening on %s:%d\n",
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
- if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
-
+ }
if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
-
}
}
}