[asterisk-commits] branch oej/test-this-branch r10709 - in /team/oej/test-this-branch: ./ channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 22 08:41:58 MST 2006


Author: oej
Date: Wed Feb 22 09:41:47 2006
New Revision: 10709

URL: http://svn.digium.com/view/asterisk?rev=10709&view=rev
Log:
Adding IPtos

Modified:
    team/oej/test-this-branch/acl.c
    team/oej/test-this-branch/channels/chan_iax2.c
    team/oej/test-this-branch/channels/chan_sip.c
    team/oej/test-this-branch/channels/iax2-provision.c

Modified: team/oej/test-this-branch/acl.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/acl.c?rev=10709&r1=10708&r2=10709&view=diff
==============================================================================
--- team/oej/test-this-branch/acl.c (original)
+++ team/oej/test-this-branch/acl.c Wed Feb 22 09:41:47 2006
@@ -257,15 +257,56 @@
 	int fval;
 	if (sscanf(value, "%i", &fval) == 1)
 		*tos = fval & 0xff;
-	else if (!strcasecmp(value, "lowdelay"))
+	else if (!strcasecmp(value, "lowdelay")) {
 		*tos = IPTOS_LOWDELAY;
-	else if (!strcasecmp(value, "throughput"))
+		ast_log(LOG_WARNING, "tos value %s is deprecated.  See doc/README.tos for more information.", value);
+	} else if (!strcasecmp(value, "throughput")) {
 		*tos = IPTOS_THROUGHPUT;
-	else if (!strcasecmp(value, "reliability"))
+		ast_log(LOG_WARNING, "tos value %s is deprecated.  See doc/README.tos for more information.", value);
+	} else if (!strcasecmp(value, "reliability")) {
 		*tos = IPTOS_RELIABILITY;
-	else if (!strcasecmp(value, "mincost"))
+		ast_log(LOG_WARNING, "tos value %s is deprecated.  See doc/README.tos for more information.", value);
+	} else if (!strcasecmp(value, "mincost")) {
 		*tos = IPTOS_MINCOST;
-	else if (!strcasecmp(value, "none"))
+		ast_log(LOG_WARNING, "tos value %s is deprecated.  See doc/README.tos for more information.", value);
+	} else if (!strcasecmp(value, "none")) {
+		*tos = 0;
+		ast_log(LOG_WARNING, "tos value %s is deprecated.  See doc/README.tos for more information.", value);
+	} else if (!strcasecmp(value, "ef"))
+		*tos = 46 << 2;
+	else if (!strcasecmp(value, "af43"))
+		*tos = 38 << 2;
+	else if (!strcasecmp(value, "af42"))
+		*tos = 36 << 2;
+	else if (!strcasecmp(value, "af41"))
+		*tos = 34 << 2;
+	else if (!strcasecmp(value, "cs4"))
+		*tos = 32 << 2;
+	else if (!strcasecmp(value, "af33"))
+		*tos = 30 << 2;
+	else if (!strcasecmp(value, "af32"))
+		*tos = 28 << 2;
+	else if (!strcasecmp(value, "af31"))
+		*tos = 26 << 2;
+	else if (!strcasecmp(value, "cs3"))
+		*tos = 24 << 2;
+	else if (!strcasecmp(value, "af23"))
+		*tos = 22 << 2;
+	else if (!strcasecmp(value, "af22"))
+		*tos = 20 << 2;
+	else if (!strcasecmp(value, "af21"))
+		*tos = 18 << 2;
+	else if (!strcasecmp(value, "cs2"))
+		*tos = 16 << 2;
+	else if (!strcasecmp(value, "af13"))
+		*tos = 14 << 2;
+	else if (!strcasecmp(value, "af12"))
+		*tos = 12 << 2;
+	else if (!strcasecmp(value, "af11"))
+		*tos = 10 << 2;
+	else if (!strcasecmp(value, "cs1"))
+		*tos = 8 << 2;
+	else if (!strcasecmp(value, "be"))
 		*tos = 0;
 	else
 		return -1;

Modified: team/oej/test-this-branch/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_iax2.c?rev=10709&r1=10708&r2=10709&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_iax2.c (original)
+++ team/oej/test-this-branch/channels/chan_iax2.c Wed Feb 22 09:41:47 2006
@@ -8613,7 +8613,7 @@
 	tosval = ast_variable_retrieve(cfg, "general", "tos");
 	if (tosval) {
 		if (ast_str2tos(tosval, &tos))
-			ast_log(LOG_WARNING, "Invalid tos value, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n");
+			ast_log(LOG_WARNING, "Invalid tos value, see doc/README.tos for more information.\n");
 	}
 	while(v) {
 		if (!strcasecmp(v->name, "bindport")){ 
@@ -8751,7 +8751,7 @@
 				ast_context_create(NULL, regcontext, "IAX2");
 		} else if (!strcasecmp(v->name, "tos")) {
 			if (ast_str2tos(v->value, &tos))
-				ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
+				ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/README.tos for more information.'\n", v->lineno);
 		} else if (!strcasecmp(v->name, "accountcode")) {
 			ast_copy_string(accountcode, v->value, sizeof(accountcode));
 		} else if (!strcasecmp(v->name, "amaflags")) {

Modified: team/oej/test-this-branch/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_sip.c?rev=10709&r1=10708&r2=10709&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_sip.c (original)
+++ team/oej/test-this-branch/channels/chan_sip.c Wed Feb 22 09:41:47 2006
@@ -372,7 +372,9 @@
 #define DEFAULT_ALLOWGUEST	TRUE
 #define DEFAULT_SRVLOOKUP	FALSE		/*!< Recommended setting is ON */
 #define DEFAULT_COMPACTHEADERS	FALSE
-#define DEFAULT_TOS		FALSE
+#define DEFAULT_TOS_SIP         0               /*!< Call signalling packets should be marked as DSCP CS3, but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_TOS_AUDIO       0               /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding), but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_TOS_VIDEO       0               /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */
 #define DEFAULT_ALLOW_EXT_DOM	TRUE
 #define DEFAULT_REALM		"asterisk"
 #define DEFAULT_NOTIFYRINGING	TRUE
@@ -414,7 +416,9 @@
 static int global_regattempts_max;	/*!< Registration attempts before giving up */
 static int global_allowguest;		/*!< allow unauthenticated users/peers to connect? */
 static int global_mwitime;		/*!< Time between MWI checks for peers */
-static int global_tos;			/*!< IP Type of service */
+static int global_tos_sip;		/*!< IP Type of service for SIP */
+static int global_tos_audio;		/*!< IP Type of service for RTP audio */
+static int global_tos_video;		/*!< IP Type of service for RTP video */
 static int compactheaders;		/*!< send compact sip headers */
 static int recordhistory;		/*!< Record SIP history. Off by default */
 static int dumphistory;			/*!< Dump history to verbose before destroying SIP dialog */
@@ -3299,9 +3303,9 @@
 			free(p);
 			return NULL;
 		}
-		ast_rtp_settos(p->rtp, global_tos);
+		ast_rtp_settos(p->rtp, global_tos_audio);
 		if (p->vrtp)
-			ast_rtp_settos(p->vrtp, global_tos);
+			ast_rtp_settos(p->vrtp, global_tos_video);
 		p->rtptimeout = global_rtptimeout;
 		p->rtpholdtimeout = global_rtpholdtimeout;
 		p->rtpkeepalive = global_rtpkeepalive;
@@ -8550,7 +8554,9 @@
 	ast_cli(fd, "  From: Domain:           %s\n", default_fromdomain);
 	ast_cli(fd, "  Record SIP history:     %s\n", recordhistory ? "On" : "Off");
 	ast_cli(fd, "  Call Events:            %s\n", global_callevents ? "On" : "Off");
-	ast_cli(fd, "  IP ToS:                 0x%x\n", global_tos);
+	ast_cli(fd, "  IP ToS SIP:             0x%x\n", global_tos_sip);
+	ast_cli(fd, "  IP ToS RTP audio:       0x%x\n", global_tos_audio);
+	ast_cli(fd, "  IP ToS RTP video:       0x%x\n", global_tos_video);
 #ifdef OSP_SUPPORT
 	ast_cli(fd, "  OSP Support:            Yes\n");
 #else
@@ -12660,6 +12666,7 @@
 	int auto_sip_domains = FALSE;
 	struct sockaddr_in old_bindaddr = bindaddr;
 	int registry_count = 0, peer_count = 0, user_count = 0;
+	int temp_tos = 0;
 
 	cfg = ast_config_load(config);
 
@@ -12681,7 +12688,9 @@
 	outboundproxyip.sin_family = AF_INET;	/* Type of address: IPv4 */
 	ourport = DEFAULT_SIP_PORT;
 	srvlookup = DEFAULT_SRVLOOKUP;
-	global_tos = DEFAULT_TOS;
+	global_tos_sip = DEFAULT_TOS_SIP;
+	global_tos_audio = DEFAULT_TOS_AUDIO;
+	global_tos_video = DEFAULT_TOS_VIDEO;
 	externhost[0] = '\0';			/* External host name (for behind NAT DynDNS support) */
 	externexpire = 0;			/* Expiration for DNS re-issuing */
 	externrefresh = 10;
@@ -12907,8 +12916,22 @@
 			if (sip_register(v->value, v->lineno, NULL) == 0)
 				registry_count++;
 		} else if (!strcasecmp(v->name, "tos")) {
-			if (ast_str2tos(v->value, &global_tos))
-				ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
+			if (!ast_str2tos(v->value, &temp_tos)) {
+				global_tos_sip = temp_tos;
+				global_tos_audio = temp_tos;
+				global_tos_video = temp_tos;
+				ast_log(LOG_WARNING, "tos value at line %d is deprecated.  See doc/README.tos for more information.", v->lineno);
+			} else
+				ast_log(LOG_WARNING, "Invalid tos value at line %d, See doc/README.tos for more information.\n", v->lineno);
+		} else if (!strcasecmp(v->name, "tos_sip")) {
+			if (ast_str2tos(v->value, &global_tos_sip))
+				ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, recommended value is 'cs3'. See doc/README.tos.\n", v->lineno);
+		} else if (!strcasecmp(v->name, "tos_audio")) {
+			if (ast_str2tos(v->value, &global_tos_audio))
+				ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, recommended value is 'ef'. See doc/README.tos.\n", v->lineno);
+		} else if (!strcasecmp(v->name, "tos_video")) {
+			if (ast_str2tos(v->value, &global_tos_video))
+				ast_log(LOG_WARNING, "Invalid tos_video value at line %d, recommended value is 'af41'. See doc/README.tos.\n", v->lineno);
 		} else if (!strcasecmp(v->name, "bindport")) {
 			if (sscanf(v->value, "%d", &ourport) == 1) {
 				bindaddr.sin_port = htons(ourport);
@@ -13021,10 +13044,10 @@
 				if (option_verbose > 1) { 
 					ast_verbose(VERBOSE_PREFIX_2 "SIP Listening on %s:%d\n", 
 					ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port));
-					ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", global_tos);
+					ast_verbose(VERBOSE_PREFIX_2 "Using SIP TOS bits %d\n", global_tos_sip);
 				}
-				if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &global_tos, sizeof(global_tos))) 
-					ast_log(LOG_WARNING, "Unable to set TOS to %d\n", global_tos);
+				if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &global_tos_sip, sizeof(global_tos_sip))) 
+					ast_log(LOG_WARNING, "Unable to set SIP TOS to %d\n", global_tos_sip);
 			}
 		}
 	}

Modified: team/oej/test-this-branch/channels/iax2-provision.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/iax2-provision.c?rev=10709&r1=10708&r2=10709&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/iax2-provision.c (original)
+++ team/oej/test-this-branch/channels/iax2-provision.c Wed Feb 22 09:41:47 2006
@@ -328,20 +328,8 @@
 			} else
 				ast_log(LOG_WARNING, "Ignoring invalid codec '%s' for '%s' at line %d\n", v->value, s, v->lineno);
 		} else if (!strcasecmp(v->name, "tos")) {
-			if (sscanf(v->value, "%d", &x) == 1)
-				cur->tos = x & 0xff;
-			else if (!strcasecmp(v->value, "lowdelay"))
-				cur->tos = IPTOS_LOWDELAY;
-			else if (!strcasecmp(v->value, "throughput"))
-				cur->tos = IPTOS_THROUGHPUT;
-			else if (!strcasecmp(v->value, "reliability"))
-				cur->tos = IPTOS_RELIABILITY;
-			else if (!strcasecmp(v->value, "mincost"))
-				cur->tos = IPTOS_MINCOST;
-			else if (!strcasecmp(v->value, "none"))
-				cur->tos = 0;
-			else
-				ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
+			if (ast_str2tos(v->value, &cur->tos))
+				ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/README.tos for more information.\n", v->lineno);
 		} else if (!strcasecmp(v->name, "user")) {
 			strncpy(cur->user, v->value, sizeof(cur->user) - 1);
 			if (strcmp(cur->user, v->value))
@@ -453,7 +441,7 @@
 			ast_cli(fd, "Alternate:    %s\n", iax_server(iabuf, sizeof(iabuf), cur->altserver));
 			ast_cli(fd, "Flags:        %s\n", iax_provflags2str(iabuf, sizeof(iabuf), cur->flags));
 			ast_cli(fd, "Format:       %s\n", ast_getformatname(cur->format));
-			ast_cli(fd, "TOS:          %d\n", cur->tos);
+			ast_cli(fd, "TOS:          0x%x\n", cur->tos);
 			found++;
 		}
 	}



More information about the asterisk-commits mailing list