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

raj at netperf.org raj at netperf.org
Fri Jan 25 15:27:24 PST 2008


Author: raj
Date: 2008-01-25 15:27:24 -0800 (Fri, 25 Jan 2008)
New Revision: 182

Modified:
   trunk/src/netlib.c
   trunk/src/netsh.c
   trunk/src/netsh.h
   trunk/src/nettest_omni.c
Log:
I HATE STRING MANIPULATION

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2008-01-25 19:22:42 UTC (rev 181)
+++ trunk/src/netlib.c	2008-01-25 23:27:24 UTC (rev 182)
@@ -221,7 +221,7 @@
 SOCKET  server_sock = INVALID_SOCKET;
 
 /* global variables to hold the value for processor affinity */
-int     local_proc_affinity,remote_proc_affinity = -1;
+int     local_proc_affinity = -1,remote_proc_affinity = -1;
 
 /* these are to allow netperf to be run easily through those evil,
    end-to-end breaking things known as firewalls */

Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c	2008-01-25 19:22:42 UTC (rev 181)
+++ trunk/src/netsh.c	2008-01-25 23:27:24 UTC (rev 182)
@@ -115,6 +115,7 @@
 
 /* some names and such                                                  */
 char	*program;		/* program invocation name		*/
+char    *command_line;          /* a copy of the entire command line    */
 char	username[BUFSIZ];	/* login name of user			*/
 char	cmd_file[BUFSIZ];	/* name of the commands file		*/
 
@@ -525,7 +526,10 @@
 {
   extern int	optind;           /* index of first unused arg 	*/
   extern char	*optarg;	  /* pointer to option string	*/
-  
+
+  int           cmnd_len;
+  char          *p;
+
   int		c;
   
   char	arg1[BUFSIZ],  /* argument holders		*/
@@ -537,7 +541,35 @@
     exit(1);
   }
   strcpy(program, argv[0]);
-  
+
+  /* brute force, but effective */
+  command_line = NULL;
+  cmnd_len = 0;
+  for (c = 0; c < argc; c++) {
+    cmnd_len += strlen(argv[c]);
+  }
+  cmnd_len += argc;  /* forget thee not the spaces */
+  command_line = malloc(cmnd_len+1);
+
+  if (command_line == NULL) {
+    printf("malloc(%d) failed!\n",cmnd_len);
+    exit(-1);
+  }
+  p = command_line;
+  for (c = 0; c < argc; c++) {
+    memcpy(p,argv[c],strlen(argv[c]));
+    p += strlen(argv[c]);
+    *p = ' ';
+    p += 1;
+  }
+  *--p = 0;
+#if 0
+  for (c = 0; c < cmnd_len; c++)
+    printf("command_line[%d] is |%c| 0x%x\n",c,command_line[c],command_line[c]);
+#endif
+
+  printf("strlen(command_line) %d cmnd_len %d\n",strlen(command_line),cmnd_len);
+
   /* Go through all the command line arguments and break them */
   /* out. For those options that take two parms, specifying only */
   /* the first will set both to that value. Specifying only the */

Modified: trunk/src/netsh.h
===================================================================
--- trunk/src/netsh.h	2008-01-25 19:22:42 UTC (rev 181)
+++ trunk/src/netsh.h	2008-01-25 23:27:24 UTC (rev 182)
@@ -34,7 +34,8 @@
 #endif /* MAXLONG */
 
 #ifndef NETSH
-extern char		*program;		/* program invocation name		*/
+extern char		*program; /* program invocation name		*/
+extern char             *command_line;  /* how we were invoked          */
 
 /* stuff to say where this test is going                                */
 extern char	host_name[HOSTNAMESIZE];/* remote host name or ip addr  */

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2008-01-25 19:22:42 UTC (rev 181)
+++ trunk/src/nettest_omni.c	2008-01-25 23:27:24 UTC (rev 182)
@@ -213,8 +213,10 @@
   ELAPSED_TIME,
   SOURCE_PORT,
   SOURCE_ADDR,
+  SOURCE_FAMILY,
   DEST_PORT,
   DEST_ADDR,
+  DEST_FAMILY,
   THROUGHPUT,
   THROUGHPUT_UNITS,
   RT_LATENCY,
@@ -422,10 +424,14 @@
     return "SOURCE_PORT";
   case   SOURCE_ADDR:
     return "SOURCE_ADDR";
+  case SOURCE_FAMILY:
+    return "SOURCE_FAMILY";
   case   DEST_PORT:
     return "DEST_PORT";
   case   DEST_ADDR:
     return "DEST_ADDR";
+  case DEST_FAMILY:
+    return "DEST_FAMILY";
   case THROUGHPUT:
     return "THROUGHPUT";
   case THROUGHPUT_UNITS:
@@ -638,8 +644,8 @@
   netperf_output_source[COMMAND_LINE].output_name = COMMAND_LINE;
   netperf_output_source[COMMAND_LINE].line1 = "Command";
   netperf_output_source[COMMAND_LINE].line2 = "Line";
-  netperf_output_source[COMMAND_LINE].format = "%s";
-  netperf_output_source[COMMAND_LINE].display_value = NULL;
+  netperf_output_source[COMMAND_LINE].format = "\"%s\"";
+  netperf_output_source[COMMAND_LINE].display_value = command_line;
   netperf_output_source[COMMAND_LINE].max_line_len = 
     NETPERF_LINE_MAX(COMMAND_LINE);
   netperf_output_source[COMMAND_LINE].tot_line_len = 
@@ -705,6 +711,16 @@
   netperf_output_source[SOURCE_ADDR].tot_line_len = 
     NETPERF_LINE_TOT(SOURCE_ADDR);
 
+  netperf_output_source[SOURCE_FAMILY].output_name = SOURCE_FAMILY;
+  netperf_output_source[SOURCE_FAMILY].line1 = "Source";
+  netperf_output_source[SOURCE_FAMILY].line2 = "Family";
+  netperf_output_source[SOURCE_FAMILY].format = "%d";
+  netperf_output_source[SOURCE_FAMILY].display_value = &local_data_family;
+  netperf_output_source[SOURCE_FAMILY].max_line_len = 
+    NETPERF_LINE_MAX(SOURCE_FAMILY);
+  netperf_output_source[SOURCE_FAMILY].tot_line_len = 
+    NETPERF_LINE_TOT(SOURCE_FAMILY);
+
   netperf_output_source[DEST_PORT].output_name = DEST_PORT;
   netperf_output_source[DEST_PORT].line1 = "Destination";
   netperf_output_source[DEST_PORT].line2 = "Port";
@@ -725,6 +741,16 @@
   netperf_output_source[DEST_ADDR].tot_line_len = 
     NETPERF_LINE_TOT(DEST_ADDR);
 
+  netperf_output_source[DEST_FAMILY].output_name = DEST_FAMILY;
+  netperf_output_source[DEST_FAMILY].line1 = "Destination";
+  netperf_output_source[DEST_FAMILY].line2 = "Family";
+  netperf_output_source[DEST_FAMILY].format = "%d";
+  netperf_output_source[DEST_FAMILY].display_value = &remote_data_family;
+  netperf_output_source[DEST_FAMILY].max_line_len = 
+    NETPERF_LINE_MAX(DEST_FAMILY);
+  netperf_output_source[DEST_FAMILY].tot_line_len = 
+    NETPERF_LINE_TOT(DEST_FAMILY);
+
   netperf_output_source[THROUGHPUT].output_name = THROUGHPUT;
   netperf_output_source[THROUGHPUT].line1 = "Throughput";
   netperf_output_source[THROUGHPUT].line2 = "";
@@ -1000,7 +1026,7 @@
   netperf_output_source[LOCAL_CPU_BIND].line3 = "Bind";
   netperf_output_source[LOCAL_CPU_BIND].line4 = "";
   netperf_output_source[LOCAL_CPU_BIND].format = "%4d";
-  netperf_output_source[LOCAL_CPU_BIND].display_value = NULL;
+  netperf_output_source[LOCAL_CPU_BIND].display_value = &local_proc_affinity;
   netperf_output_source[LOCAL_CPU_BIND].max_line_len = 
     NETPERF_LINE_MAX(LOCAL_CPU_BIND);
   netperf_output_source[LOCAL_CPU_BIND].tot_line_len = 
@@ -1300,7 +1326,7 @@
   netperf_output_source[REMOTE_CPU_BIND].line3 = "Bind";
   netperf_output_source[REMOTE_CPU_BIND].line4 = "";
   netperf_output_source[REMOTE_CPU_BIND].format = "%4d";
-  netperf_output_source[REMOTE_CPU_BIND].display_value = NULL;
+  netperf_output_source[REMOTE_CPU_BIND].display_value = &remote_proc_affinity;
   netperf_output_source[REMOTE_CPU_BIND].max_line_len = 
     NETPERF_LINE_MAX(REMOTE_CPU_BIND);
   netperf_output_source[REMOTE_CPU_BIND].tot_line_len = 
@@ -1381,10 +1407,10 @@
   for (i = OUTPUT_NONE; i < NETPERF_OUTPUT_MAX; i++)
     output_csv_list[i] = OUTPUT_END;
 
-  output_csv_list[0] = LSS_SIZE_REQ;
-  output_csv_list[1] = LSS_SIZE;
-  output_csv_list[2] = LSS_SIZE_END;
-  output_csv_list[3] = BURST_SIZE;
+  output_csv_list[0] = LSS_SIZE_END;
+  output_csv_list[1] = SOURCE_ADDR;
+  output_csv_list[2] = COMMAND_LINE;
+  output_csv_list[3] = LSS_SIZE_END;
   
 
   for (j = 0; j < NETPERF_MAX_BLOCKS; j++)
@@ -1393,7 +1419,9 @@
 
   output_human_list[0][0] = LSS_SIZE_REQ;
   output_human_list[0][1] = LSS_SIZE;
-  output_human_list[0][2] = LSS_SIZE_END;
+  output_human_list[0][2] = COMMAND_LINE;
+  output_human_list[0][3] = LSS_SIZE_END;
+
 }
 
 /* why? because one cannot simply pass a pointer to snprintf :) for
@@ -1441,6 +1469,7 @@
 my_snprintf(char *buffer, size_t size, const char *format, void *value)
 {
   const char *fmt = format;
+
   while (*fmt)
     switch (*fmt++) {
     case 's':
@@ -1479,10 +1508,10 @@
       vallen = my_snprintf(tmpval,
 			   1024,
 			   netperf_output_source[output_csv_list[j]].format,
-			   (netperf_output_source[output_csv_list[j]].display_value));
+			   (netperf_output_source[output_csv_list[j]].display_value)) + 1;
     else
       vallen = 0;
-    
+
     if (vallen > 
 	netperf_output_source[output_csv_list[j]].tot_line_len)
       netperf_output_source[output_csv_list[j]].tot_line_len = vallen;
@@ -1533,6 +1562,7 @@
 			netperf_output_source[output_csv_list[j]].tot_line_len,
 			netperf_output_source[output_csv_list[j]].format,
 			netperf_output_source[output_csv_list[j]].display_value);
+
       /* nuke the trailing \n" from the string routine.  */
       *(v1 + len) = ',';
       v1 += len + 1;
@@ -1592,7 +1622,7 @@
 	vallen = my_snprintf(tmpval,
 			     1024,
 			     netperf_output_source[output_human_list[i][j]].format,
-			     (netperf_output_source[output_human_list[i][j]].display_value));
+			     (netperf_output_source[output_human_list[i][j]].display_value)) + 1; /* need to count the \n */
       else
 	vallen = 0;
 
@@ -2081,6 +2111,12 @@
 		     socket_type,
 		     protocol,
 		     0);
+  printf("local_data_address is at %p\n",local_data_address);
+  if (local_data_address)
+    printf("local_data_address is %s\n",local_data_address);
+  printf("remote_data_address is at %p\n", remote_data_address);
+  if (remote_data_address)
+    printf("remote_data_address is %s\n");
 
   if ( print_headers ) {
     print_top_test_header("OMNI TEST",local_res,remote_res);
@@ -3492,7 +3528,7 @@
 	/* make sure we leave room for the NULL termination boys and
 	   girls. raj 2005-02-82 */ 
 	remote_data_address = malloc(strlen(arg1)+1);
-	strncpy(remote_data_address,arg1,strlen(arg1));
+	strcpy(remote_data_address,arg1);
       }
       if (arg2[0])
 	remote_data_family = parse_address_family(arg2);
@@ -3503,7 +3539,7 @@
 	/* make sure we leave room for the NULL termination boys and
 	   girls. raj 2005-02-82 */ 
 	local_data_address = malloc(strlen(arg1)+1);
-	strncpy(local_data_address,arg1,strlen(arg1));
+	strcpy(local_data_address,arg1);
       }
       if (arg2[0])
 	local_data_family = parse_address_family(arg2);



More information about the netperf-dev mailing list