[netperf-dev] netperf4 commit notice r43 - in trunk: . src

raj at netperf.org raj at netperf.org
Tue Jan 24 16:37:36 PST 2006


Author: raj
Date: 2006-01-24 16:37:30 -0800 (Tue, 24 Jan 2006)
New Revision: 43

Added:
   trunk/src/netmsg.h
Modified:
   trunk/config.h.in
   trunk/configure
   trunk/configure.ac
   trunk/src/netconfidence.h
   trunk/src/netlib.c
   trunk/src/netlib.h
   trunk/src/netlib_linux.c
   trunk/src/netmsg.c
   trunk/src/netperf.c
   trunk/src/netperf.h
   trunk/src/netserver.c
   trunk/src/nettest_dns.c
Log:
Protect netperf include files from double inclusion, provide externs and 
get rid of a bunch, but not all of the compilation warnings with gcc -Wall


Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/config.h.in	2006-01-25 00:37:30 UTC (rev 43)
@@ -195,6 +195,9 @@
 /* Define to 1 if you have the <sys/param.h> header file. */
 #undef HAVE_SYS_PARAM_H
 
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#undef HAVE_SYS_RESOURCE_H
+
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 

Modified: trunk/configure
===================================================================
--- trunk/configure	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/configure	2006-01-25 00:37:30 UTC (rev 43)
@@ -20994,7 +20994,9 @@
 
 
 
-for ac_header in arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h math.h arpa/nameser.h resolv.h poll.h pthread.h sched.h
+
+
+for ac_header in arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h math.h arpa/nameser.h resolv.h poll.h pthread.h sched.h dlfcn.h sys/resource.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/configure.ac	2006-01-25 00:37:30 UTC (rev 43)
@@ -33,7 +33,7 @@
 # Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h math.h arpa/nameser.h resolv.h poll.h pthread.h sched.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h math.h arpa/nameser.h resolv.h poll.h pthread.h sched.h dlfcn.h sys/resource.h])
 
 # Some platforms require these.  There may be a better way.
 AC_HAVE_LIBRARY(socket)

Modified: trunk/src/netconfidence.h
===================================================================
--- trunk/src/netconfidence.h	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netconfidence.h	2006-01-25 00:37:30 UTC (rev 43)
@@ -1,4 +1,41 @@
+/*
 
+Copyright (c) 2005,2006 Hewlett-Packard Company
+
+$Id$
+
+This file is part of netperf4.
+
+Netperf4 is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+Netperf4 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA.
+
+In addition, as a special exception, the copyright holders give
+permission to link the code of netperf4 with the OpenSSL project's
+"OpenSSL" library (or with modified versions of it that use the same
+license as the "OpenSSL" library), and distribute the linked
+executables.  You must obey the GNU General Public License in all
+respects for all of the code used other than "OpenSSL".  If you modify
+this file, you may extend this exception to your version of the file,
+but you are not obligated to do so.  If you do not wish to do so,
+delete this exception statement from your version.
+
+*/
+
+#ifndef _NETCONFIDENCE_H
+#define _NETCONFIDENCE_H
+
 typedef struct confidence {
   double value;
   int    count;
@@ -14,5 +51,5 @@
 
 int    set_confidence_level( char *desired_level );
 
+#endif
 
-

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netlib.c	2006-01-25 00:37:30 UTC (rev 43)
@@ -75,10 +75,20 @@
 #endif
 #endif
 
+#ifdef HAVE_POLL_H
 #include <poll.h>
+#endif
+
 #include <sys/resource.h>
+
+#ifdef HAVE_PTHREAD_H
 #include <pthread.h>
+#endif
 
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
 #if HAVE_GLIB_H
 #include <glib.h>
 #endif 
@@ -347,9 +357,6 @@
   int          ret;
   test_hash_t *h;
   test_t      *test;
-  char        *state;
-  char        *req_st;
-  double       a=-1.0,b=-1.0,c=-1.0,d=-1.0;
   int          i;
 
   fprintf(where,"\n\n%4s %4s %15s %4s %4s %4s %8s %8s %8s %8s\n",
@@ -714,7 +721,7 @@
 }
 
 int
-get_test_function(test_t *test, xmlChar *func)
+get_test_function(test_t *test, const xmlChar *func)
 {
   int tmp = debug;
   void    *lib_handle = test->library_handle;
@@ -1274,7 +1281,6 @@
 recv_control_message(int control_sock, xmlDocPtr *message)
 {
   int loc_debug = 0;
-  int tmp;
   int32_t bytes_recvd = 0,
           bytes_left,
           counter;
@@ -1285,7 +1291,7 @@
 
   struct pollfd fds;
 
-  struct timeval timeout;
+  int timeout = 15000;
 
 
   /* one of these days, we probably aught to make sure that what
@@ -1311,7 +1317,7 @@
     /* poll had better return one, or there was either a problem or
        a timeout... */
 
-    if ((counter = poll(&fds, 1, 15000)) != 1) {
+    if ((counter = poll(&fds, 1, timeout)) != 1) {
       if (debug) {
         fprintf(where,
                 "recv_control_message: poll error or timeout. errno %d counter %d\n",
@@ -1465,7 +1471,7 @@
 send_control_message(const int control_sock,
                      xmlNodePtr body,
                      xmlChar *nid,
-                     xmlChar *fromnid)
+                     const xmlChar *fromnid)
 {
   int  rc = NPE_SUCCESS;
 

Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netlib.h	2006-01-25 00:37:30 UTC (rev 43)
@@ -1,5 +1,7 @@
 /*
 
+Copyright (c) 2005,2006 Hewlett-Packard Company 
+
 $Id$
 
 This file is part of netperf4.
@@ -31,12 +33,37 @@
 
 */
 
-#ifdef NOTDEF
+#ifndef _NETLIB_H
+#define _NETLIB_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#endif
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 
-#include <poll.h>
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
 #endif
 
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+
 extern  void delete_test(const xmlChar *id);
 extern  test_t * find_test_in_hash(const xmlChar *id);
 extern  void report_test_status(test_t *test);
@@ -47,58 +74,33 @@
                               xmlChar *loc_type,
                               xmlChar *loc_value);
 
-/* do we REALLY want this stuff? */
-#ifdef NO_DLOPEN
-#include <dl.h>
-
-/* dlopen flags */
-#define RTLD_NOW        0x00000001  /* bind immediately */
-#define RTLD_LAZY       0x00000002  /* bind deferred */
-#define RTLD_GLOBAL     0x00000004  /* symbols are globally visible */
-#define RTLD_LOCAL      0x00000008  /* symbols only visible to this load */
-
-static void* dlopen(char* filename, unsigned int flags)
-{
-  shl_t handle;
-  handle = shl_load( filename, BIND_IMMEDIATE | BIND_VERBOSE , 0L );
-  return((void *)handle);
-}
-
-static void* dlsym(void* handle, const char* name)
-{
-  int rc;
-  void *value = NULL;
-  shl_t shl_handle = handle;
-  rc = shl_findsym( &shl_handle, name, TYPE_PROCEDURE, &value );
-  return(value);
-}
-
-static char* dlerror(void)
-{
-  switch (errno) {
-    case ENOEXEC:
-      return("The specified file is not a shared library, or a format error was detected.");
-    case ENOSYM:
-      return("Some symbol required by the shared library could not be found.");
-    case EINVAL:
-      return("The specified handle or index is not valid or an attempt was made to load a library at an invalid address.");
-    case ENOMEM:
-      return("There is insufficient room in the address space to load the library.");
-    case ENOENT:
-      return("The specified library does not exist.");
-    case EACCES:
-      return("Read or execute permission is denied for the specified library.");
-    case 0:
-      return("Symbol not found.");
-    default:
-      return("Unknown error");
-  }
-}
-
+#ifdef HAVE_GETHRTIME
+extern void netperf_timestamp(hrtime_t *timestamp);
+extern int  delta_micro(hrtime_t *begin, hrtime_t *end);
+extern int  delta_milli(hrtime_t *begin, hrtime_t *end);
 #else
-#include <dlfcn.h>
+extern void netperf_timestamp(struct timeval *timestamp);
+extern int  delta_micro(struct timeval *begin,struct timeval *end);
+extern int  delta_milli(struct timeval *begin,struct timeval *end);
 #endif
 
+extern int strtofam(xmlChar *familystr);
+extern void dump_addrinfo(FILE *dumploc, struct addrinfo *info,
+			  xmlChar *host, xmlChar *port, int family);
+extern int establish_control(xmlChar *hostname,  xmlChar *port, int remfam,
+			     xmlChar *localhost, xmlChar *localport, int locfam);
+extern int get_test_function(test_t *test, const xmlChar *func);
+extern int add_test_to_hash(test_t *new_test);
+extern int send_control_message(const int control_sock, xmlNodePtr body,
+				xmlChar *nid, const xmlChar *fromnid);
+extern int32_t recv_control_message(int control_sock, xmlDocPtr *message);
+extern void report_server_error(server_t *server);
+extern int launch_thread(pthread_t *tid, void *(*start_routine)(void *), void *data);
+extern int set_thread_locality(test_t *test, char *loc_type, char *loc_value);
+extern void break_args_explicit(char *s, char *arg1, char *arg2);
+extern int parse_address_family(char family_string[]);
+extern int establish_listen(char *hostname, char *service, int af, socklen_t *addrlenp);
+
 /* state machine data structure for process message */
 
 typedef int (*msg_func_t)(xmlNodePtr msg, xmlDocPtr doc, server_t *server);
@@ -112,4 +114,4 @@
 void netlib_init();
 
 void display_test_hash();
-
+#endif

Modified: trunk/src/netlib_linux.c
===================================================================
--- trunk/src/netlib_linux.c	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netlib_linux.c	2006-01-25 00:37:30 UTC (rev 43)
@@ -44,6 +44,10 @@
 #include <sched.h>
 #endif
 
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
 #include <errno.h>
 
 #include "netperf.h"

Modified: trunk/src/netmsg.c
===================================================================
--- trunk/src/netmsg.c	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netmsg.c	2006-01-25 00:37:30 UTC (rev 43)
@@ -225,45 +225,14 @@
   return(rc);
 }
 
-/*
-   netserver verify the version message from a netperf
-   Valid responses from a netserver in an error message if version
-   does not match or a version check response if it matches.
-*/
 
-int
-ns_version_check(xmlNodePtr msg, xmlDocPtr doc, server_t *netperf)
-{
-  int rc = NPE_SUCCESS;
-  xmlChar  * new_nid;
-  xmlNodePtr message;
-
-  if (!xmlStrcmp(xmlGetProp(msg,(const xmlChar *)"vers"),NETPERF_VERSION) &&
-      !xmlStrcmp(xmlGetProp(msg,(const xmlChar *)"updt"),NETPERF_UPDATE)  &&
-      !xmlStrcmp(xmlGetProp(msg,(const xmlChar *)"fix"), NETPERF_FIX))     {
-    /* versions match */
-    netperf->state      =  NSRV_VERS;
-    netperf->state_req  =  NSRV_WORK;
-    rc = send_version_message(netperf,my_nid);
-  } else {
-    /* versions don't match */
-    if (debug) {
-      fprintf(where,"ns_version_chk: version check failed\n");
-      fflush(where);
-    }
-    rc = NPE_BAD_VERSION;
-  }
-  return(rc);
-}
-
-
 /*
    generate a version message and send it out the control
    socket.  XML may be the wizziest thing since sliced bits, but it
    sure does lead to some rather cumbersome coding... raj 2003-02-27
 */
 int
-send_version_message(server_t *server, xmlChar *fromnid)
+send_version_message(server_t *server, const xmlChar *fromnid)
 {
   int rc = NPE_SUCCESS;
   xmlNodePtr message;
@@ -314,7 +283,37 @@
 }
 
 
+/*
+   netserver verify the version message from a netperf
+   Valid responses from a netserver in an error message if version
+   does not match or a version check response if it matches.
+*/
+
 int
+ns_version_check(xmlNodePtr msg, xmlDocPtr doc, server_t *netperf)
+{
+  int rc = NPE_SUCCESS;
+
+  if (!xmlStrcmp(xmlGetProp(msg,(const xmlChar *)"vers"),NETPERF_VERSION) &&
+      !xmlStrcmp(xmlGetProp(msg,(const xmlChar *)"updt"),NETPERF_UPDATE)  &&
+      !xmlStrcmp(xmlGetProp(msg,(const xmlChar *)"fix"), NETPERF_FIX))     {
+    /* versions match */
+    netperf->state      =  NSRV_VERS;
+    netperf->state_req  =  NSRV_WORK;
+    rc = send_version_message(netperf,my_nid);
+  } else {
+    /* versions don't match */
+    if (debug) {
+      fprintf(where,"ns_version_chk: version check failed\n");
+      fflush(where);
+    }
+    rc = NPE_BAD_VERSION;
+  }
+  return(rc);
+}
+
+
+int
 die_message(xmlNodePtr msg, xmlDocPtr doc, server_t *server)
 {
   int        rc = NPE_SUCCESS;
@@ -405,7 +404,6 @@
   int          rc = NPE_SUCCESS;
   xmlChar     *testid;
   test_t      *test;
-  xmlNodePtr  stats;
 
 
   testid = xmlGetProp(msg,(const xmlChar *)"tid");
@@ -437,7 +435,6 @@
   int          rc = NPE_SUCCESS;
   xmlChar     *testid;
   test_t      *test;
-  xmlNodePtr  stats;
 
 
   testid = xmlGetProp(msg,(const xmlChar *)"tid");
@@ -842,9 +839,6 @@
   int        rc = NPE_SUCCESS;
   test_t    *new_test;
   xmlNodePtr test_node;
-  xmlNodePtr reply;
-  xmlNodePtr new_node;
-  xmlChar   *test_name;
   xmlChar   *testid;
   xmlChar   *loc_type;
   xmlChar   *loc_value;

Added: trunk/src/netmsg.h
===================================================================
--- trunk/src/netmsg.h	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netmsg.h	2006-01-25 00:37:30 UTC (rev 43)
@@ -0,0 +1,15 @@
+
+
+#ifndef _NETMSG_H
+#define _NETMSG_H
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include "netperf.h"
+#include "netlib.h"
+
+extern int send_version_message(server_t *server, const xmlChar *fromnid);
+extern int process_message(server_t *server, xmlDocPtr doc);
+extern int ns_version_check(xmlNodePtr msg, xmlDocPtr doc, server_t *netperf);
+#endif

Modified: trunk/src/netperf.c
===================================================================
--- trunk/src/netperf.c	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netperf.c	2006-01-25 00:37:30 UTC (rev 43)
@@ -61,6 +61,7 @@
 
 #include "netperf.h"
 #include "netlib.h"
+#include "netmsg.h"
 
 extern struct msgs NP_Msgs;
 
@@ -719,7 +720,7 @@
     if (poll(&fds,1,5000) > 0) {
       if (debug) {
         fprintf(where,"wait_for_version_response ");
-        fprintf(where,"calling recv_control_messaage\n");
+        fprintf(where,"calling recv_control_message\n");
         fflush(where);
       }
       pthread_rwlock_rdlock(&server->rwlock);
@@ -870,13 +871,11 @@
 {
   test_t     *test            = data;
   xmlChar    *id;
-  xmlDocPtr   doc;
   xmlNodePtr  dep_data        = NULL;
   int         rc              = NPE_SUCCESS;
   xmlNodePtr  cur             = NULL;
   xmlNodePtr  msg             = NULL;
   server_t   *server;
-  xmlNodePtr  testnode        = test->node;
   
   if (debug) {
     fprintf(where,"entering initialize_test\n");
@@ -1315,11 +1314,8 @@
 report_stats_command(xmlNodePtr my_cmd, uint32_t junk)
 {
   int            rc   = NPE_SUCCESS;
-  xmlDocPtr      doc;
   xmlNodePtr     commands;
   xmlNodePtr     cmd;
-  xmlNsPtr       ns;
-  char          *myfile;
   char          *output_file;
   char          *report_flags;
   xmlChar       *set_name;
@@ -1331,7 +1327,6 @@
   int            max_count;
   int            sample_count = 0;
   GenReport      gen_report   = NULL;
-  void          *data = NULL;
   
   commands      = my_cmd->xmlChildrenNode;
 
@@ -1893,7 +1888,6 @@
   xmlDocPtr   doc;
   xmlNodePtr  commands;
   xmlNodePtr  cmd;
-  xmlNsPtr    ns;
 
   if (debug) {
     fprintf(where,"process_commands_and_events: calling parse_xml_file\n");

Modified: trunk/src/netperf.h
===================================================================
--- trunk/src/netperf.h	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netperf.h	2006-01-25 00:37:30 UTC (rev 43)
@@ -1,3 +1,41 @@
+/*
+
+Copyright (c) 2005,2006 Hewlett-Packard Company
+
+$Id$
+
+This file is part of netperf4.
+
+Netperf4 is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+Netperf4 is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+USA.
+
+In addition, as a special exception, the copyright holders give
+permission to link the code of netperf4 with the OpenSSL project's
+"OpenSSL" library (or with modified versions of it that use the same
+license as the "OpenSSL" library), and distribute the linked
+executables.  You must obey the GNU General Public License in all
+respects for all of the code used other than "OpenSSL".  If you modify
+this file, you may extend this exception to your version of the file,
+but you are not obligated to do so.  If you do not wish to do so,
+delete this exception statement from your version.
+
+*/
+
+#ifndef _NETPERF_H
+#define _NETPERF_H
+
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -448,3 +486,4 @@
 };
 
 #endif
+#endif

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/netserver.c	2006-01-25 00:37:30 UTC (rev 43)
@@ -79,6 +79,7 @@
 
 #include "netperf.h"
 #include "netlib.h"
+#include "netmsg.h"
 
 extern struct msgs NS_Msgs;
 
@@ -750,7 +751,6 @@
   int               namelen      = sizeof(name);
   netperf_socklen_t peerlen      = namelen;
   int               sock;
-  int               rc;
   int               listenfd     = 0;
   int               loop         = 1;
 
@@ -855,16 +855,12 @@
 {
   int   i;
   int   rc;
-  int   sock;
 
   struct sockaddr  name;
-  struct sockaddr *peeraddr     = &name;
   int              namelen      = sizeof(name);
-  int              peerlen      = namelen;
 
   NETPERF_DEBUG_ENTRY(debug,where);
 
-  char *service = NULL;
 
   for (i = 0; i < NETPERF_HASH_BUCKETS; i++) {
     netperf_hash[i].server = NULL;
@@ -907,7 +903,7 @@
 int
 main (int argc, char **argv)
 {
-  int rc;
+
   int sock;
   struct sockaddr name;
   netperf_socklen_t namelen = sizeof(name);

Modified: trunk/src/nettest_dns.c
===================================================================
--- trunk/src/nettest_dns.c	2006-01-24 22:48:31 UTC (rev 42)
+++ trunk/src/nettest_dns.c	2006-01-25 00:37:30 UTC (rev 43)
@@ -112,6 +112,7 @@
 #endif
 
 #include "netperf.h"
+#include "netlib.h"
 
 #include "nettest_dns.h"
 
@@ -1381,19 +1382,14 @@
   uint32_t          new_state;
   int               len;
   int               ret;
-  int               i;
   int               response_len;
   int               bytes_left;
-  int               req_size;
   uint16_t         *rsp_ptr;
-  uint16_t          message_id;
   uint16_t          response_id;
-  int               num_to_check;
   dns_data_t       *my_data;
   dns_request_status_t *status_entry;
   struct pollfd     fds;
   int               keep_going=1;
-  NETPERF_TIMESTAMP_T    now;
 
   /* this aught to be enough to hold it - modulo stuff like large
      requests on TCP connections... and we make it of type uint16_t so
@@ -1569,7 +1565,6 @@
   int               ret;
   int               len;
   int               bytes_left;
-  int               req_size;
   uint16_t         *rsp_ptr;
   dns_data_t       *my_data;
   struct pollfd     fds;
@@ -2018,7 +2013,6 @@
   FILE          *outfd;
   dns_results_t *rd;
   double         elapsed_seconds;
-  double         sys_util;
   double         calibration;
   double         local_idle;
   double         local_busy;



More information about the netperf-dev mailing list