[netperf-dev] netperf2 commit notice r372 - trunk/src

raj at netperf.org raj at netperf.org
Mon Dec 20 15:43:26 PST 2010


Author: raj
Date: 2010-12-20 15:43:26 -0800 (Mon, 20 Dec 2010)
New Revision: 372

Modified:
   trunk/src/netsh.c
   trunk/src/netsh.h
   trunk/src/nettest_omni.c
Log:
make the omni minus d option friendlier by accepting a broader range of inputs to set direction

Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c	2010-12-20 22:16:36 UTC (rev 371)
+++ trunk/src/netsh.c	2010-12-20 23:43:26 UTC (rev 372)
@@ -440,6 +440,59 @@
 }
 
 int
+parse_direction(char direction_string[])
+{
+  char arg1[BUFSIZ],arg2[BUFSIZ];
+  int left, right;
+
+  if (NULL == direction_string) {
+    return 0;
+  }
+
+  if (direction_string[0] == '\0') {
+    return 0;
+  }
+
+  /* allow someone to "or" break_args_explicit will split at the first
+     '|' in the string so if arg1 exists as something other than '\0'
+     we know it has no '|' in it */
+  break_args_explicit_sep(direction_string,'|',arg1,arg2);
+
+  /* at this point only arg2 could contain a '|' so recurse on that */
+  right = parse_direction(arg2);
+
+  /* now we parse the "left side" or arg1 */
+  if (arg1[0] == '\0') {
+    left = 0;
+  }
+  else if ((strcasecmp(arg1,"xmit") == 0) ||
+	   (strcasecmp(arg1,"send") == 0) ||
+	   (strcasecmp(arg1,"stream") == 0) ||
+	   (strcasecmp(arg1,"transmit") == 0)) {
+    /* yes, a magic number - we need to make NETPERF_XMIT known to
+       netsh */
+    left = 0x2;
+  }
+  else if ((strcasecmp(arg1,"recv") == 0) ||
+	   (strcasecmp(arg1,"receive") == 0) ||
+	   (strcasecmp(arg1,"maerts") == 0)) {
+    /* yes, another magic number... */
+    left =  0x4;
+  }
+  else  if (strcasecmp(arg1,"rr") == 0) {
+    left = 0x6;
+  }
+  else {
+    /* we now "ass-u-me" it is a number that can be parsed by strtol()
+     */
+    left = strtol(arg1,NULL,0);
+  }
+
+  return (left | right);
+
+}
+
+int
 parse_protocol(char protocol_string[]) 
 {
   char temp[10];

Modified: trunk/src/netsh.h
===================================================================
--- trunk/src/netsh.h	2010-12-20 22:16:36 UTC (rev 371)
+++ trunk/src/netsh.h	2010-12-20 23:43:26 UTC (rev 372)
@@ -73,6 +73,7 @@
 extern int      parse_address_family(char family_string[]);
 extern int      parse_socket_type(char socket_string[]);
 extern int      parse_protocol(char protocol_string[]);
+extern int      parse_direction(char direction_string[]);
 extern void     set_defaults();
 extern void     scan_cmd_line(int argc, char *argv[]);
 extern void     dump_globals();

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2010-12-20 22:16:36 UTC (rev 371)
+++ trunk/src/nettest_omni.c	2010-12-20 23:43:26 UTC (rev 372)
@@ -7511,7 +7511,7 @@
       break;
     case 'd':
       /* arbitrarily set the direction variable */
-      direction = strtol(optarg,NULL,0);
+      direction = parse_direction(optarg);
       break;
     case 'D':
       /* set the TCP nodelay flag */



More information about the netperf-dev mailing list