[netperf-dev] netperf2 commit notice r492 - trunk/src
raj at netperf.org
raj at netperf.org
Wed Sep 28 14:52:09 PDT 2011
Author: raj
Date: 2011-09-28 14:52:09 -0700 (Wed, 28 Sep 2011)
New Revision: 492
Modified:
trunk/src/netsh.c
trunk/src/nettest_bsd.c
Log:
presumably this will also set class for IPv6 now
Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c 2011-09-22 18:56:48 UTC (rev 491)
+++ trunk/src/netsh.c 2011-09-28 21:52:09 UTC (rev 492)
@@ -966,13 +966,13 @@
break;
case 'Y':
break_args(optarg, arg1, arg2);
-#if defined(IP_TOS)
+#if defined(IP_TOS) || defined(IPV6_TCLASS)
if (arg1[0])
local_socket_tos = strtol(arg1,NULL,0);
#else
if (debug) {
fprintf(where,
- "Setting IP_TOS is not supported on this platform, request to set IP_TOS locally ignored.\n");
+ "Setting IP type-of-service is not supported on this platform, request to set it locally ignored.\n");
fflush(where);
}
local_socket_tos = -1;
Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c 2011-09-22 18:56:48 UTC (rev 491)
+++ trunk/src/nettest_bsd.c 2011-09-28 21:52:09 UTC (rev 492)
@@ -1175,8 +1175,72 @@
}
return ret;
}
+
+int
+set_socket_tos(SOCKET sock, int family, int socket_tos) {
+ int my_tos = -3;
+ netperf_socklen_t sock_opt_len;
+
+ switch (family) {
+#if defined(IP_TOS)
+ case AF_INET:
+ /* should I mask-away anything above the byte? */
+ my_tos = socket_tos;
+ if (setsockopt(sock,
+ IPPROTO_IP,
+ IP_TOS,
+ &my_tos,sizeof(my_tos)) == SOCKET_ERROR) {
+ fprintf(where,
+ "%s ip_tos failed with %s (errno %d)\n",
+ __FUNCTION__,
+ strerror(errno),
+ errno);
+ fflush(where);
+ my_tos = -2;
+ }
+ else {
+ sock_opt_len = sizeof(my_tos);
+ getsockopt(sock,
+ IPPROTO_IP,
+ IP_TOS,
+ &my_tos,
+ &sock_opt_len);
+ }
+ break;
+#endif
+#if defined(IPV6_TCLASS)
+ case AF_INET6:
+ /* should I mask-away anything above the byte? */
+ my_tos = socket_tos;
+ if (setsockopt(sock,
+ IPPROTO_IPV6,
+ IPV6_TCLASS,
+ &my_tos,sizeof(my_tos)) == SOCKET_ERROR) {
+ fprintf(where,
+ "%s ip_tos failed with %s (errno %d)\n",
+ __FUNCTION__,
+ strerror(errno),
+ errno);
+ fflush(where);
+ my_tos = -2;
+ }
+ else {
+ sock_opt_len = sizeof(my_tos);
+ getsockopt(sock,
+ IPPROTO_IPV6,
+ IPV6_TCLASS,
+ &my_tos,
+ &sock_opt_len);
+ }
+ break;
+#endif
+ }
+ return my_tos;
+}
+
+
/* This routine will create a data (listen) socket with the
apropriate options set and return it to the caller. this replaces
all the duplicate code in each of the test routines and should help
@@ -1496,36 +1560,12 @@
local_socket_prio = -3;
#endif
-#if defined(IP_TOS)
- if (local_socket_tos >= 0) {
- unsigned char my_tos = (unsigned char) (local_socket_tos & 0xFF);
- if (setsockopt(temp_socket,
- (res->ai_family == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP,
- IP_TOS,
- &my_tos,
- sizeof(my_tos)) == SOCKET_ERROR) {
- fprintf(where,
- "netperf: create_data_socket: ip_tos: errno %d\n",
- errno);
- fflush(where);
- local_socket_tos = -2;
- }
- else {
- sock_opt_len = 1;
- /* I wonder if some error checking might be indicated */
- getsockopt(temp_socket,
- (res->ai_family == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP,
- IP_TOS,
- &my_tos,
- &sock_opt_len);
- local_socket_tos = my_tos;
- }
- }
-#else
- local_socket_tos = -3;
+#if defined (IP_TOS) || defined(IPV6_TCLASS)
+ if (local_socket_tos > 0)
+ local_socket_tos = set_socket_tos(temp_socket,res->ai_family, local_socket_tos);
#endif
- return(temp_socket);
+ return temp_socket;
}
#ifdef KLUDGE_SOCKET_OPTIONS
More information about the netperf-dev
mailing list