From ed690fc3489e97c95344773c178b7e8327a56a08 Mon Sep 17 00:00:00 2001
From: Jason Parker <jparker@digium.com>
Date: Mon, 15 Oct 2007 23:20:40 +0000
Subject: [PATCH] Switch dundi to new tos config format. Remove old unused
 defines for old style.

Closes issue 10860, patch by IgorG.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85764 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 UPGRADE.txt               | 16 ++++++++++------
 channels/chan_h323.c      |  5 -----
 channels/chan_iax2.c      |  3 ---
 channels/chan_mgcp.c      |  4 ----
 channels/chan_sip.c       |  3 ---
 channels/iax2-provision.c |  4 ----
 configs/dundi.conf.sample |  3 +++
 doc/tex/qos.tex           |  4 +---
 main/acl.c                |  9 ---------
 pbx/pbx_dundi.c           | 25 +++----------------------
 10 files changed, 17 insertions(+), 59 deletions(-)

diff --git a/UPGRADE.txt b/UPGRADE.txt
index 31253bd865..3036d0e0bf 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -1,12 +1,6 @@
 Information for Upgrading From Previous Asterisk Releases
 =========================================================
 
-Manager:
-
-* The CallerID fields across Manager events have now been made more
-  consistent. CallerID Number will be sent as CallerIDNum and CallerID
-  Name will be sent as CallerIDName wherever used.
-
 AEL:
 
 * Macros are now implemented underneath with the Gosub() application.
@@ -113,8 +107,18 @@ Channel Drivers:
   semicolon, in order to make the Local channel driver compatible with the comma
   delimiter change in applications.
 
+Configuration:
+
+* pbx_dundi.c: tos parameter changed to use new values. Old values like lowdelay,
+  lowcost and other is not acceptable now. Look into qos.tex for description of 
+  this parameter.
+
 Manager:
 
+* The CallerID fields across Manager events have now been made more
+  consistent. CallerID Number will be sent as CallerIDNum and CallerID
+  Name will be sent as CallerIDName wherever used.
+
 * The IAXpeers command output has been changed to more closely resemble the
   output of the SIPpeers command.
 
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 03f05d775f..c9b86f0a91 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -54,11 +54,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <sys/socket.h>
 #include <sys/signal.h>
 #include <sys/param.h>
-#if defined(BSD)
-#ifndef IPTOS_MINCOST
-#define IPTOS_MINCOST 0x02
-#endif
-#endif
 #include <arpa/inet.h>
 #include <net/if.h>
 #include <netinet/in.h>
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 516ac32a8e..7c62f7af7e 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -108,9 +108,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
    thread is actually doing. */
 #define DEBUG_SCHED_MULTITHREAD
 
-#ifndef IPTOS_MINCOST
-#define IPTOS_MINCOST 0x02
-#endif
 
 #ifdef SO_NO_CHECK
 static int nochecksums = 0;
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index a509dea7d0..a7679ccddf 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -79,10 +79,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/abstract_jb.h"
 #include "asterisk/event.h"
 
-#ifndef IPTOS_MINCOST
-#define IPTOS_MINCOST 0x02
-#endif
-
 /*
  * Define to work around buggy dlink MGCP phone firmware which
  * appears not to know that "rt" is part of the "G" package.
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index e69a696ed6..7546f0b2e7 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -156,9 +156,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #define XMIT_ERROR		-2
 
 #define VIDEO_CODEC_MASK        0x1fc0000 /*!< Video codecs from H.261 thru AST_FORMAT_MAX_VIDEO */
-#ifndef IPTOS_MINCOST
-#define IPTOS_MINCOST           0x02
-#endif
 
 /* #define VOCAL_DATA_HACK */
 
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index 782a4097e1..3fe789ec8d 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -51,10 +51,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "iax2-provision.h"
 #include "iax2-parser.h"
 
-#ifndef IPTOS_MINCOST
-#define IPTOS_MINCOST 0x02
-#endif
-
 static int provinit = 0;
 
 struct iax_template {
diff --git a/configs/dundi.conf.sample b/configs/dundi.conf.sample
index 4b7f156179..fa3d255d5b 100644
--- a/configs/dundi.conf.sample
+++ b/configs/dundi.conf.sample
@@ -27,6 +27,9 @@
 ;bindaddr=0.0.0.0
 ;port=4520
 ;
+; See doc/qos.tex for a description of the tos parameter.
+;tos=ef
+;
 ; Our entity identifier (Should generally be the MAC address of the
 ; machine it's running on.  Defaults to the first eth address, but you
 ; can override it here, as long as you set it to the MAC of *something*
diff --git a/doc/tex/qos.tex b/doc/tex/qos.tex
index 4788d78f83..3a04c50642 100644
--- a/doc/tex/qos.tex
+++ b/doc/tex/qos.tex
@@ -53,9 +53,7 @@ ef (expedited forwarding),
 The tos* parameters also take numeric values.
 
 The lowdelay, throughput, reliability, mincost, and none values are
-deprecated because they set the IP TOS using the outdated "IP
-precedence" model as defined in RFC 791 and RFC 1349. They still
-work in this version of Asterisk, but will be removed in future releases.
+removed in current releases.
 
 \subsubsection{802.1p CoS values}
 
diff --git a/main/acl.c b/main/acl.c
index efbc9d1835..487d8354cd 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -53,15 +53,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <sys/sockio.h>
 #endif
 
-/* netinet/ip.h may not define the following (See RFCs 791 and 1349) */
-#if !defined(IPTOS_LOWCOST)
-#define       IPTOS_LOWCOST           0x02
-#endif
-
-#if !defined(IPTOS_MINCOST)
-#define       IPTOS_MINCOST           IPTOS_LOWCOST
-#endif
-
 #include "asterisk/acl.h"
 #include "asterisk/logger.h"
 #include "asterisk/channel.h"
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 860690f09b..5bace5d8df 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -115,7 +115,7 @@ static struct sched_context *sched;
 static int netsocket = -1;
 static pthread_t netthreadid = AST_PTHREADT_NULL;
 static pthread_t precachethreadid = AST_PTHREADT_NULL;
-static int tos = 0;
+static unsigned int tos = 0;
 static int dundidebug = 0;
 static int authdebug = 0;
 static int dundi_ttl = DUNDI_DEFAULT_TTL;
@@ -4661,7 +4661,6 @@ static int set_config(char *config_file, struct sockaddr_in* sin, int reload)
 	struct ast_config *cfg;
 	struct ast_variable *v;
 	char *cat;
-	int format;
 	int x;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	char hn[MAXHOSTNAMELEN] = "";
@@ -4738,26 +4737,8 @@ static int set_config(char *config_file, struct sockaddr_in* sin, int reload)
 			else
 				ast_log(LOG_WARNING, "Invalid global endpoint identifier '%s' at line %d\n", v->value, v->lineno);
 		} else if (!strcasecmp(v->name, "tos")) {
-			if (sscanf(v->value, "%d", &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;
-#if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(SOLARIS)
-			else if (!strcasecmp(v->value, "mincost"))
-				tos = IPTOS_MINCOST;
-#endif
-			else if (!strcasecmp(v->value, "none"))
-				tos = 0;
-			else
-#if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(SOLARIS)
-				ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
-#else
-				ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', or 'none'\n", v->lineno);
-#endif
+			if (ast_str2tos(v->value, &tos)) 
+				ast_log(LOG_WARNING, "Invalid tos value at line %d, please read docs/qos.tex\n", v->lineno);
 		} else if (!strcasecmp(v->name, "department")) {
 			ast_copy_string(dept, v->value, sizeof(dept));
 		} else if (!strcasecmp(v->name, "organization")) {
-- 
GitLab