Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r790 committed - Updated to google style.

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r790 committed - Updated to google style.


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r790 committed - Updated to google style.
  • Date: Thu, 15 Nov 2012 21:35:44 +0000

Revision: 790
Author:

Date: Thu Nov 15 13:33:44 2012
Log: Updated to google style.
http://code.google.com/p/ndt/source/detail?r=790

Modified:
/trunk/src/analyze.c
/trunk/src/clt_tests.h
/trunk/src/fakewww.c
/trunk/src/genplot.c
/trunk/src/heuristics.c
/trunk/src/heuristics.h
/trunk/src/logging.c
/trunk/src/logging.h
/trunk/src/mrange.c
/trunk/src/mrange.h
/trunk/src/ndt_odbc.c
/trunk/src/ndt_odbc.h
/trunk/src/ndtptestconstants.c
/trunk/src/ndtptestconstants.h
/trunk/src/network.c
/trunk/src/network.h
/trunk/src/protocol.c
/trunk/src/protocol.h
/trunk/src/runningtest.c
/trunk/src/runningtest.h
/trunk/src/strlutils.c
/trunk/src/strlutils.h
/trunk/src/test_c2s_clt.c
/trunk/src/test_c2s_srv.c
/trunk/src/test_meta.h
/trunk/src/test_meta_clt.c
/trunk/src/test_meta_srv.c
/trunk/src/test_mid_clt.c
/trunk/src/test_mid_srv.c
/trunk/src/test_results_clt.c
/trunk/src/test_results_clt.h
/trunk/src/test_s2c_clt.c
/trunk/src/test_s2c_srv.c
/trunk/src/test_sfw.h
/trunk/src/test_sfw_clt.c
/trunk/src/test_sfw_srv.c
/trunk/src/testoptions.c
/trunk/src/testoptions.h
/trunk/src/tests_srv.h
/trunk/src/tr-mkmap.c
/trunk/src/tr-tree.c
/trunk/src/tr-tree.h
/trunk/src/tr-tree6.c
/trunk/src/troute.c
/trunk/src/troute.h
/trunk/src/troute6.c
/trunk/src/usage.c
/trunk/src/usage.h
/trunk/src/utils.c
/trunk/src/utils.h
/trunk/src/varinfo.h
/trunk/src/viewtrace.c
/trunk/src/web100-admin.c
/trunk/src/web100-admin.h
/trunk/src/web100-pcap.c
/trunk/src/web100-util.c
/trunk/src/web100clt.c
/trunk/src/web100srv.c
/trunk/src/web100srv.h

=======================================
--- /trunk/src/analyze.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/analyze.c Thu Nov 15 13:33:44 2012
@@ -30,8 +30,8 @@
#include <sys/select.h>
#include <math.h>

-#include "usage.h"
-#include "logging.h"
+#include "./usage.h"
+#include "./logging.h"

#define LOGFILE "web100srv.log"
#define PROTOLOGFILE "web100srvprotocol.log" /* protocol validation log */
@@ -39,12 +39,13 @@
#define WEB100_FILE "web100_variables" /*names of the variables to access*/
#define BUFFSIZE 512

-char buff[BUFFSIZE + 1];int window = 64000;
+char buff[BUFFSIZE + 1];
+int window = 64000;
int randomize = 0;
char *rmt_host;
char *VarFileName = NULL;
char *LogFileName = NULL;
-char *ProtoLogFileName = NULL; // Log file used to log protocol validation logs
+char *ProtoLogFileName = NULL; // Log file used to log protocol validation logs
double avgrtt, loss, loss2, rttsec, bw, bw2, rwin, swin, cwin, speed;
double rwintime, cwndtime, sendtime, timesec;
int n, m, one = 1;
@@ -64,7 +65,8 @@
FILE *fp;
int indx, links[4][16], max, total;
float runave[4];
-int c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack;
+int c2s_linkspeed_data, c2s_linkspeed_ack,
+ s2c_linkspeed_data, s2c_linkspeed_ack;
int j;
char spds[4][256], buff2[32];
char *str, tmpstr[32];
@@ -196,10 +198,10 @@
snprintf(btlneck, sizeof(btlneck), "a 'Dial-up modem' connection");
break;
case 2:
- if ((c2sspd / s2cspd > .8) && (c2sspd / s2cspd < 1.2)
- && (c2sspd > 1000))
+ if ((c2sspd / s2cspd > .8) && (c2sspd / s2cspd < 1.2) &&
+ (c2sspd > 1000)) {
snprintf(btlneck, sizeof(btlneck), "a 'T1' subnet");
- else {
+ } else {
if ((tail[3] > 1) || (s2c_linkspeed_ack == 3))
snprintf(btlneck, sizeof(btlneck), "a 'Cable Modem' connection");
else
@@ -313,8 +315,8 @@
"Acks = %0.4f, async speed = %0.4f, mismatch3 = %0.4f, CongOver = %d\n",
acks, aspeed, cong, CongestionOverCount);
printf(
- "idle = %0.4f, timeout/pkts = %0.4f, %%retranmissions = %0.2f, %%increase = %0.2f\n",
- idle, touts, retrn * 100, increase * 100);
+ "idle = %0.4f, timeout/pkts = %0.4f, %%retranmissions = %0.2f, "
+ "%%increase = %0.2f\n", idle, touts, retrn * 100, increase * 100);
printf(
"FastRetrans/Total = %0.4f, Fast/Retrans = %0.4f, Retrans/sec = %0.4f\n",
retrn, fr_ratio, retransec);
@@ -392,18 +394,18 @@
printf("\tWeb100 says link = %d, speed-chk says link = %d\n", link,
c2s_linkspeed_data);
printf(
- "\tSpeed-chk says {%d, %d, %d, %d}, Running average = {%0.1f, %0.1f, %0.1f, %0.1f}\n",
- c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack, runave[0], runave[1], runave[2],
+ "\tSpeed-chk says {%d, %d, %d, %d}, Running average = {"
+ "%0.1f, %0.1f, %0.1f, %0.1f}\n", c2s_linkspeed_data, c2s_linkspeed_ack,
+ s2c_linkspeed_data, s2c_linkspeed_ack, runave[0], runave[1], runave[2],
runave[3]);
- if (c2sspd > 1000)
- printf(
- "\tC2Sspeed = %0.2f Mbps, S2Cspeed = %0.2f Mbps, CWND-Limited = %0.2f Mbps, ",
- (float) c2sspd / 1000, (float) s2cspd / 1000,
- (float) s2c2spd / 1000);
- else
- printf(
- "\tC2Sspeed = %d kbps, S2Cspeed = %d kbps, CWND-Limited: %d kbps, ",
- c2sspd, s2cspd, s2c2spd);
+ if (c2sspd > 1000) {
+ printf("\tC2Sspeed = %0.2f Mbps, S2Cspeed = %0.2f Mbps, CWND-Limited = "
+ "%0.2f Mbps, ", (float) c2sspd / 1000, (float) s2cspd / 1000,
+ (float) s2c2spd / 1000);
+ } else {
+ printf("\tC2Sspeed = %d kbps, S2Cspeed = %d kbps, CWND-Limited: %d kbps, ",
+ c2sspd, s2cspd, s2c2spd);
+ }
if (bw > 1)
printf("Estimate = %0.2f Mbps (%0.2f Mbps)\n", bw, bw2);
else
@@ -414,9 +416,9 @@
else
printf("\tOld estimate is less than measured; ");

- if (CongestionSignals == -1)
+ if (CongestionSignals == -1) {
printf("No data collected to calculage new estimate\n");
- else {
+ } else {
if ((bw2 * 1000) > s2cspd)
printf("New estimate is greater than measured\n");
else
@@ -424,19 +426,19 @@
}

printf(
- "\tLoss = %0.2f%% (%0.2f%%), Out-of-Order = %0.2f%%, Long tail = {%d, %d, %d, %d}\n",
- loss * 100, loss2 * 100, order * 100, tail[0], tail[1], tail[2],
- tail[3]);
- printf(
- "\tDistribution = {%d, %d, %d, %d}, time spent {r=%0.1f%% c=%0.1f%% s=%0.1f%%}\n",
- head[0], head[1], head[2], head[3], rwintime * 100, cwndtime * 100,
- sendtime * 100);
+ "\tLoss = %0.2f%% (%0.2f%%), Out-of-Order = %0.2f%%, "
+ "Long tail = {%d, %d, %d, %d}\n", loss * 100, loss2 * 100, order * 100,
+ tail[0], tail[1], tail[2], tail[3]);
+ printf("\tDistribution = {%d, %d, %d, %d}, "
+ "time spent {r=%0.1f%% c=%0.1f%% s=%0.1f%%}\n",
+ head[0], head[1], head[2], head[3], rwintime * 100, cwndtime * 100,
+ sendtime * 100);
printf("\tAve(min) RTT = %0.2f (%d) msec, Buffers = {r=%d, c=%d, s=%d}\n",
avgrtt, MinRTT, MaxRwinRcvd, CurrentCwnd, Sndbuf / 2);
- printf(
- "\tbw*delay = {r=%0.2f, c=%0.2f, s=%0.2f}, Transitions/sec = {r=%0.1f, c=%0.1f, s=%0.1f}\n",
- recvbwd, cwndbwd, sendbwd, SndLimTransRwin / timesec,
- SndLimTransCwnd / timesec, SndLimTransSender / timesec);
+ printf("\tbw*delay = {r=%0.2f, c=%0.2f, s=%0.2f}, Transitions/sec = "
+ "{r=%0.1f, c=%0.1f, s=%0.1f}\n", recvbwd, cwndbwd, sendbwd,
+ SndLimTransRwin / timesec, SndLimTransCwnd / timesec,
+ SndLimTransSender / timesec);
printf(
"\tRetransmissions/sec = %0.1f, Timeouts/sec = %0.1f, SSThreshold = %d\n",
(float) PktsRetrans / timesec, (float) Timeouts / timesec,
@@ -457,7 +459,7 @@
int debug = 0;

iponly = 0;
- //while ((c = getopt_long(argc, argv, "dnhl:v", long_options, 0)) != -1) {
+ // while ((c = getopt_long(argc, argv, "dnhl:v", long_options, 0)) != -1) {
while ((c = getopt_long(argc, argv, "udnhl:v", long_options, 0)) != -1) {
switch (c) {
case 'h':
@@ -503,9 +505,9 @@
}
log_println(1, "log file = %s", LogFileName);

- //TODO do we need protocol log file in analyze????
+ // TODO do we need protocol log file in analyze????
if (ProtoLogFileName == NULL) {
- snprintf(tmpstr, 256, "%s/%s", BASEDIR, PROTOLOGFILE);
+ snprintf(tmpstr, sizeof(tmpstr), "%s/%s", BASEDIR, PROTOLOGFILE);
ProtoLogFileName = tmpstr;
}
log_println(1, "log file = %s", ProtoLogFileName);
@@ -934,7 +936,6 @@
display: log_println(1, "Web100 variables line received\n");
calculate();
}
-
}
return 0;
}
=======================================
--- /trunk/src/clt_tests.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/clt_tests.h Thu Nov 15 13:33:44 2012
@@ -6,18 +6,18 @@
*

*/

-#ifndef _JS_CLT_TESTS_H
-#define _JS_CLT_TESTS_H
+#ifndef SRC_CLT_TESTS_H_
+#define SRC_CLT_TESTS_H_

#define MIDBOX_TEST_LOG "Middlebox test"
#define S2C_TEST_LOG "S2C throughput test"
#define MIDBOX_TEST_RES_SIZE 512

int test_mid_clt(int ctlSocket, char tests, char* host, int conn_options,
- int buf_size, char* tmpstr2);
+ int buf_size, char* tmpstr2);
int test_c2s_clt(int ctlSocket, char tests, char* host, int conn_options,
- int buf_size);
+ int buf_size);
int test_s2c_clt(int ctlSocket, char tests, char* host, int conn_options,
- int buf_size, char* tmpstr);
+ int buf_size, char* tmpstr);

-#endif
+#endif // SRC_CLT_TESTS_H_
=======================================
--- /trunk/src/fakewww.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/fakewww.c Thu Nov 15 13:33:44 2012
@@ -21,7 +21,6 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>
-#include <unistd.h>
#include <time.h>
#include <string.h>
#include <errno.h>
@@ -29,12 +28,12 @@
#define SYSLOG_NAMES
#include <syslog.h>

-#include "usage.h"
-#include "troute.h"
-#include "tr-tree.h"
-#include "network.h"
-#include "logging.h"
-#include "web100-admin.h"
+#include "./usage.h"
+#include "./troute.h"
+#include "./tr-tree.h"
+#include "./network.h"
+#include "./logging.h"
+#include "./web100-admin.h"

#define LISTEN_PORT "7123"
#define AC_TIME_FORMAT "%d/%b/%Y:%H:%M:%S %z"
@@ -59,8 +58,8 @@
" <BODY>\n <meta http-equiv=\"refresh\" content=\"2; ";
char *MsgRedir5 =
"\">\n\n<h2>FLM server re-direction page</h2>\n"
-"<p><font size=\"+2\">Your client is being redirected to the 'closest' FLM server "
-"for configuration testing.\n <a ";
+"<p><font size=\"+2\">Your client is being redirected to the 'closest' FLM "
+"server for configuration testing.\n <a ";
char *MsgRedir6 = ">Click Here </a> if you are not "
"automatically redirected in the next 2 seconds.\n "
"</font></BODY>\n</HTML>";
@@ -97,18 +96,18 @@
int syslogfacility = LOG_FACILITY;
char *ProcessName = { "fakewww" };

-static struct option long_options[] = { { "debug", 0, 0, 'd' }, { "help", 0, 0,
- 'h' }, { "alog", 1, 0, 'l' }, { "elog", 1, 0, 'e' },
- { "port", 1, 0, 'p' }, { "ttl", 1, 0, 't' }, { "federated", 0, 0, 'F' },
- { "file", 1, 0, 'f' }, { "basedir", 1, 0, 'b' },
- { "syslog", 0, 0, 's' }, { "logfacility", 1, 0, 'S' }, { "version", 0,
- 0, 'v' }, { "dflttree", 1, 0, 301 },
+static struct option long_options[] = {
+ { "debug", 0, 0, 'd' }, { "help", 0, 0, 'h' }, { "alog", 1, 0, 'l' },
+ { "elog", 1, 0, 'e' }, { "port", 1, 0, 'p' }, { "ttl", 1, 0, 't' },
+ { "federated", 0, 0, 'F' }, { "file", 1, 0, 'f' }, { "basedir", 1, 0, 'b' },
+ { "syslog", 0, 0, 's' }, { "logfacility", 1, 0, 'S' },
+ { "version", 0, 0, 'v' }, { "dflttree", 1, 0, 301 },
#ifdef AF_INET6
- { "dflttree6", 1, 0, 302},
- { "ipv4", 0, 0, '4'},
- { "ipv6", 0, 0, '6'},
+ { "dflttree6", 1, 0, 302},
+ { "ipv4", 0, 0, '4'},
+ { "ipv6", 0, 0, '6'},
#endif
- { 0, 0, 0, 0 } };
+ { 0, 0, 0, 0 } };

void dowww(int, I2Addr, char*, char*, char*, int, int);
void reap();
@@ -145,8 +144,8 @@
#define GETOPT_LONG_INET6(x) x
#endif

- while ((c = getopt_long(argc, argv,
- GETOPT_LONG_INET6("dhl:e:p:t:Ff:b:sS:v"), long_options, 0)) != -1) {
+ while ((c = getopt_long(argc, argv, GETOPT_LONG_INET6("dhl:e:p:t:Ff:b:sS:v"),
+ long_options, 0)) != -1) {
switch (c) {
case '4':
conn_options |= OPT_IPV4_ONLY;
@@ -315,7 +314,6 @@
}
close(newsockfd);
}
-
}

#include <sys/wait.h>
@@ -327,8 +325,8 @@
int pid;
union wait status;

- while ((pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0)
- ;
+ while ((pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) {
+ }
}

/*
@@ -340,7 +338,9 @@
*/

int readline(fd, ptr, maxlen)
- register int fd;register char *ptr;register int maxlen; {
+ register int fd;
+ register char *ptr;
+ register int maxlen; {
int n, rc;
char c;

@@ -354,8 +354,9 @@
return (0); /* EOF, no data read */
else
break; /* EOF, some data was read */
- } else
+ } else {
return (-1); /* error */
+ }
}

*ptr = 0;
@@ -472,16 +473,16 @@
log_println(4,
"find_compare() returned 0, reset to [%s]",
onenodename);
- srv_addr = ((struct sockaddr_in*) I2AddrSAddr(serv_addr,
- NULL))->sin_addr.s_addr;
+ srv_addr =
+ ((struct sockaddr_in*) I2AddrSAddr(serv_addr, NULL))->
+ sin_addr.s_addr;
}

- log_println(
- 4,
- "Client host [%s] should be redirected to FLM server [%u.%u.%u.%u]",
- inet_ntoa(cli_addr->sin_addr), srv_addr & 0xff,
- (srv_addr >> 8) & 0xff, (srv_addr >> 16) & 0xff,
- (srv_addr >> 24) & 0xff);
+ log_println(4,
+ "Client host [%s] should be redirected to FLM server "
+ "[%u.%u.%u.%u]", inet_ntoa(cli_addr->sin_addr),
+ srv_addr & 0xff, (srv_addr >> 8) & 0xff,
+ (srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff);

/* At this point, the srv_addr variable contains the IP address of the
* server we want to re-direct the connect to. So we should generate a
@@ -502,7 +503,8 @@
writen(sd, MsgRedir3, strlen(MsgRedir3));
writen(sd, MsgRedir4, strlen(MsgRedir4));
answerSize = strlen(MsgRedir4);
- snprintf(line, sizeof(line), "url=http://%u.%u.%u.%u:%s/tcpbw100.html";,
+ snprintf(line, sizeof(line),
+ "url=http://%u.%u.%u.%u:%s/tcpbw100.html";,
srv_addr & 0xff, (srv_addr >> 8) & 0xff,
(srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
port);
@@ -510,7 +512,8 @@
answerSize += strlen(line);
writen(sd, MsgRedir5, strlen(MsgRedir5));
answerSize += strlen(MsgRedir5);
- snprintf(line, sizeof(line), "href=\"http://%u.%u.%u.%u:%s/tcpbw100.html\"";,
+ snprintf(line, sizeof(line),
+ "href=\"http://%u.%u.%u.%u:%s/tcpbw100.html\"";,
srv_addr & 0xff, (srv_addr >> 8) & 0xff,
(srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
port);
@@ -538,7 +541,10 @@
struct sockaddr_in6* cli_addr = (struct sockaddr_in6*) csaddr;
socklen_t onenode_len;
find_route6(nodename, IP6list, max_ttl);
- for (i = 0; memcmp(IP6list[i], &cli_addr->sin6_addr, sizeof(cli_addr->sin6_addr)); i++) {
+ for (i = 0;
+ memcmp(IP6list[i], &cli_addr->sin6_addr,
+ sizeof(cli_addr->sin6_addr));
+ i++) {
memset(onenodename, 0, 200);
onenode_len = 199;
inet_ntop(AF_INET6, (void *) IP6list[i], onenodename, onenode_len);
@@ -563,37 +569,46 @@
memset(onenodename, 0, 200);
nlen = 199;
I2AddrNodeName(serv_addr, onenodename, &nlen);
- log_println(4, "find_compare6() returned 0, reset to [%s]", onenodename);
- memcpy(srv_addr6, &((struct sockaddr_in6*)I2AddrSAddr(serv_addr, NULL))->sin6_addr, 16);
+ log_println(4, "find_compare6() returned 0, reset to [%s]",
+ onenodename);
+ struct sockaddr* sock_addr = I2AddrSAddr(serv_addr, NULL);
+ memcpy(srv_addr6,
+ &((struct sockaddr_in6*)sock_addr)->sin6_addr,
+ 16);
}

nlen = 199;
memset(onenodename, 0, 200);
inet_ntop(AF_INET6, (void *) srv_addr6, onenodename, nlen);

- log_println(4, "Client host [%s] should be redirected to FLM server [%s]",
- nodename, onenodename);
+ log_println(4, "Client host [%s] should be redirected to FLM server "
+ "[%s]", nodename, onenodename);

writen(sd, MsgRedir1, strlen(MsgRedir1));
writen(sd, MsgRedir2, strlen(MsgRedir2));
- snprintf(line, sizeof(line), "http://[%s]:%s/tcpbw100.html";, onenodename, port);
+ snprintf(line, sizeof(line), "http://[%s]:%s/tcpbw100.html";,
+ onenodename, port);
writen(sd, line, strlen(line));
writen(sd, MsgRedir3, strlen(MsgRedir3));
writen(sd, MsgRedir4, strlen(MsgRedir4));
answerSize = strlen(MsgRedir4);
- snprintf(line, sizeof(line), "url=http://[%s]:%s/tcpbw100.html";, onenodename, port);
+ snprintf(line, sizeof(line), "url=http://[%s]:%s/tcpbw100.html";,
+ onenodename, port);
writen(sd, line, strlen(line));
answerSize += strlen(line);
writen(sd, MsgRedir5, strlen(MsgRedir5));
answerSize += strlen(MsgRedir5);
- snprintf(line, sizeof(line), "href=\"http://[%s]:%s/tcpbw100.html\"";, onenodename, port);
+ snprintf(line, sizeof(line), "href=\"http://[%s]:%s/tcpbw100.html\"";,
+ onenodename, port);
writen(sd, line, strlen(line));
answerSize += strlen(line);
writen(sd, MsgRedir6, strlen(MsgRedir6));
answerSize += strlen(MsgRedir6);
- log_println(3, "%s redirected to remote server [[%s]:%s]", nodename, onenodename, port);
+ log_println(3, "%s redirected to remote server [[%s]:%s]", nodename,
+ onenodename, port);
tt = time(0);
- logErLog(ErLogFileName, &tt, "notice", "[%s] redirected to remote server [[%s]:%s]",
+ logErLog(ErLogFileName, &tt, "notice",
+ "[%s] redirected to remote server [[%s]:%s]",
nodename, onenodename, port);
logAcLog(AcLogFileName, &tt, nodename, lineBuf, 307, answerSize,
useragentBuf, refererBuf);
@@ -682,7 +697,8 @@
setenv("SERVER_NAME", onenodename, 1);
setenv("REMOTE_HOST", nodename, 1);
setenv("REMOTE_ADDR", "207.75.164.153", 1);
- system("/usr/bin/perl /usr/local/ndt/traceroute.pl > /tmp/rac-traceroute.pl");
+ system("/usr/bin/perl /usr/local/ndt/traceroute.pl > "
+ "/tmp/rac-traceroute.pl");
close(fd);
fd = open("/tmp/rac-traceroute.pl", 0);
}
@@ -712,8 +728,8 @@
}
}

-void logErLog(char* LogFileName, time_t* tt, char* severity, char* format, ...)
-{
+void logErLog(char* LogFileName, time_t* tt, char* severity,
+ char* format, ...) {
FILE *fp;
va_list ap;
if (LogFileName != NULL) {
=======================================
--- /trunk/src/genplot.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/genplot.c Thu Nov 15 13:33:44 2012
@@ -32,7 +32,7 @@
#include <web100.h>
#endif

-#include "usage.h"
+#include "./usage.h"

char *color[16] = { "green", "blue", "orange", "red", "yellow", "magenta",
"pink", "white", "black" };
@@ -51,7 +51,6 @@

void get_title(web100_snapshot* snap, web100_log* log, web100_agent* agent,
web100_group* group, char* title, char* remport) {
-
web100_var* var;
char buf[128];

@@ -108,7 +107,6 @@
void plot_var(char *list, int cnt, char *name, web100_snapshot* snap,
web100_log* log, web100_agent* agent, web100_group* group,
int(*func)(const int arg, const int value)) {
-
char *varg;
char buf[256];
web100_var* var;
@@ -132,10 +130,7 @@
fn = stdout;
strncpy(name, "Unknown", 7);
} else {
- strncpy(lname, name, strlen(name));
- strcat(lname, ".");
- strcat(lname, remport);
- strcat(lname, ".xpl");
+ snprintf(lname, sizeof(lname), "%s.%s.xpl", name, remport);
fn = fopen(lname, "w");
}

@@ -272,7 +267,6 @@
}
}
fprintf(fn, "go\n");
-
}

void plot_cwndtime(char *name, web100_snapshot* snap, web100_log* log,
@@ -296,10 +290,7 @@
fn = stdout;
strncpy(name, "Unknown", 7);
} else {
- strncpy(lname, name, strlen(name));
- strcat(lname, ".");
- strcat(lname, remport);
- strcat(lname, ".xpl");
+ snprintf(lname, sizeof(lname), "%s.%s.xpl", name, remport);
fn = fopen(lname, "w");
}

@@ -391,13 +382,11 @@
}
}
fprintf(fn, "go\n");
-
}

void print_var(char *varlist, web100_snapshot* snap, web100_log* log,
web100_agent* agent, web100_group* group,
void(*func)(const int arg, const int value)) {
-
char *varg, savelist[256], *text;
char buf[256], title[256], remport[8];
int i, j;
@@ -463,7 +452,6 @@
}
printf("\n");
}
-
}

/* workers */
@@ -550,7 +538,8 @@
plotboth = 1;
break;
case 'h':
- genplot_long_usage("ANL/Internet2 NDT version " VERSION " (genplot)", argv[0]);
+ genplot_long_usage("ANL/Internet2 NDT version " VERSION " (genplot)",
+ argv[0]);
break;
case 'v':
printf("ANL/Internet2 NDT version %s (genplot)\n", VERSION);
@@ -583,7 +572,7 @@
}

if (argc == 1) {
- short_usage (argv[0], "ANL/Internet2 NDT version " VERSION " (genplot)");
+ short_usage(argv[0], "ANL/Internet2 NDT version " VERSION " (genplot)");
}

for (j = optind; j < argc; j++) {
=======================================
--- /trunk/src/heuristics.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/heuristics.c Thu Nov 15 13:33:44 2012
@@ -8,9 +8,9 @@
#include <string.h>
#include <math.h>

-#include "utils.h"
-#include "logging.h"
-#include "heuristics.h"
+#include "./utils.h"
+#include "./logging.h"
+#include "./heuristics.h"

#define log_lvl_heur 2
/**
@@ -52,17 +52,17 @@
* @param is_c2stest is this a C->S test?
*
* */
-void calc_linkspeed(char spds[4][256], int spd_index, int *c2s_linkspeed_data, int *c2s_linkspeed_ack,
- int* s2c_linkspeed_data, int *s2c_linkspeed_ack, float runave[4], u_int32_t *dec_cnt,
- u_int32_t *same_cnt, u_int32_t *inc_cnt, int *timeout, int *dupack,
- int is_c2stest) {
-
- int index = 0; // speed array indices
- int links[16]; // link speed bin values
- int n = 0, j = 0; // temporary iterator variables
- int max; // max speed bin counter value
- int total; // total of the bin counts, used to calculate percentage
- int ifspeedlocal; // local if-speed indicator
+void calc_linkspeed(char spds[4][256], int spd_index, int *c2s_linkspeed_data,
+ int *c2s_linkspeed_ack, int* s2c_linkspeed_data,
+ int *s2c_linkspeed_ack, float runave[4], u_int32_t *dec_cnt,
+ u_int32_t *same_cnt, u_int32_t *inc_cnt, int *timeout,
+ int *dupack, int is_c2stest) {
+ int index = 0; // speed array indices
+ int links[16]; // link speed bin values
+ int n = 0, j = 0; // temporary iterator variables
+ int max; // max speed bin counter value
+ int total; // total of the bin counts, used to calculate percentage
+ int ifspeedlocal; // local if-speed indicator

for (n = 0; n < spd_index; n++) {
sscanf(spds[n],
@@ -78,7 +78,7 @@
total = 0;

if ((ifspeedlocal == -1) || (ifspeedlocal == 0) || (ifspeedlocal > 10))
- ifspeedlocal = 10; // ifspeed was probably not collected in these cases
+ ifspeedlocal = 10; // ifspeed was probably not collected in these cases

// get the ifspeed bin with the biggest counter value.
// NDT determines link speed using this
@@ -122,9 +122,8 @@

// classify link speed based on the max ifspeed seen
log_linkspeed(index);
- } //end section to determine speed.
-
-} //end method calc_linkspeed
+ } // end section to determine speed.
+} // end method calc_linkspeed

/**
* Calculate average round-trip-time in milliseconds.
@@ -163,9 +162,9 @@
double packetloss = (double) congsnsignals / pktsout;
if (packetloss == 0) {
if (c2sdatalinkspd > 5)
- packetloss = .0000000001; // set to 10^-10 for links faster than FastE
+ packetloss = .0000000001; // set to 10^-10 for links faster than FastE
else
- packetloss = .000001; // set to 10^-6 otherwise
+ packetloss = .000001; // set to 10^-6 otherwise
}
log_println(log_lvl_heur, "--packetloss=%d over %d=%f. Link spd=%d",
congsnsignals, pktsout, packetloss, c2sdatalinkspd);
@@ -220,7 +219,8 @@
*
* */
void calc_window_sizes(int *SndWinScale, int *RcvWinScale, int SendBuf,
- int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin, double *cwin) {
+ int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin,
+ double *cwin) {
if ((*SndWinScale > WINDOW_SCALE_THRESH) || (SendBuf < MAX_TCP_PORT))
*SndWinScale = 0;
if ((*RcvWinScale > WINDOW_SCALE_THRESH) || (MaxRwinRcvd < MAX_TCP_PORT))
@@ -231,8 +231,9 @@
*cwin = (double) MaxCwnd * BITS_8 / KILO_BITS / KILO_BITS;
log_println(
log_lvl_heur,
- "--window sizes: SndWinScale= %d, RcvwinScale=%d, MaxRwinRcvd=%d, maxCwnd=%d,rwin=%f, swin=%f, cwin=%f",
- *SndWinScale, *RcvWinScale, MaxRwinRcvd, MaxCwnd ,*rwin, *swin, *cwin);
+ "--window sizes: SndWinScale= %d, RcvwinScale=%d, MaxRwinRcvd=%d, "
+ "maxCwnd=%d,rwin=%f, swin=%f, cwin=%f",
+ *SndWinScale, *RcvWinScale, MaxRwinRcvd, MaxCwnd, *rwin, *swin, *cwin);
}

/**
@@ -353,7 +354,6 @@
if (midboxs2cspd > s2cspd)
thruputmismatch = 1;
return thruputmismatch;
-
}

/**
@@ -405,22 +405,22 @@
* @return int 1 if duplex mismatch is found, 0 if not.
* */
int detect_duplexmismatch(double cwndtime, double bwtheoretcl, int pktsretxed,
- double timesec, int maxsstartthresh, double idleRTO, int link,
- int s2cspd, int midboxspd, int multiple) {
+ double timesec, int maxsstartthresh, double idleRTO,
+ int link, int s2cspd, int midboxspd, int multiple) {
int duplex_mismatch_yes = 0;
- if ((cwndtime > .9) // more than 90% time spent being receiver window limited
- && (bwtheoretcl > 2) // theoretical max goodput > 2mbps
+ if ((cwndtime > .9) // more than 90% time spent being receiver window limited
+ && (bwtheoretcl > 2) // theoretical max goodput > 2mbps
&& (pktsretxed / timesec > 2)
// #of segments with pkt-retransmissions> 2
- && (maxsstartthresh > 0) // max slow start threshold > 0
- && (idleRTO > .01) // cumulative RTO time > 1% test duration
- && (link > 2) // not wireless link
- && is_limited_cwnd_throughput_better(midboxspd, s2cspd) //S->C throughput calculated
+ && (maxsstartthresh > 0) // max slow start threshold > 0
+ && (idleRTO > .01) // cumulative RTO time > 1% test duration
+ && (link > 2) // not wireless link
+ // S->C throughput calculated
+ && is_limited_cwnd_throughput_better(midboxspd, s2cspd)
// by server < client value
&& isNotMultipleTestMode(multiple)) {
-
duplex_mismatch_yes = 1;
- } //end if
+ } // end if
log_println(log_lvl_heur, "--duplexmismatch?: %d ", duplex_mismatch_yes);
return duplex_mismatch_yes;
}
@@ -435,9 +435,9 @@
int detect_internal_duplexmismatch(double s2cspd, double realthruput,
double rwintime, double packetloss) {
int duplex_mismatch_yes = 0;
- if ((s2cspd > 50) // S->C goodput > 50 Mbps
- && (realthruput < 5) // actual send throughput < 5 Mbps
- && (rwintime > .9) // receive window limited for >90% of the time
+ if ((s2cspd > 50) // S->C goodput > 50 Mbps
+ && (realthruput < 5) // actual send throughput < 5 Mbps
+ && (rwintime > .9) // receive window limited for >90% of the time
&& (packetloss < .01)) {
duplex_mismatch_yes = 1;
}
@@ -476,7 +476,6 @@
}
log_println(log_lvl_heur, "--faulty hardware?: %d ", faultyhw_found);
return faultyhw_found;
-
}

/**
@@ -533,8 +532,8 @@
* @return 1 if wireless link, 0 otherwise
* */
int detect_wirelesslink(double sendtime, double realthruput, double bw_theortcl,
- int sndlimtrans_rwin, int sndlimtrans_cwnd, double rwindowtime,
- int link) {
+ int sndlimtrans_rwin, int sndlimtrans_cwnd,
+ double rwindowtime, int link) {
int is_wireless = 0;
if ((sendtime == 0) && (realthruput < 5) && (bw_theortcl > 50)
&& ((sndlimtrans_rwin / sndlimtrans_cwnd) == 1)
@@ -574,7 +573,6 @@
}
log_println(log_lvl_heur, "--Is DSL/Cable?: %d ", is_dslorcable);
return is_dslorcable;
-
}

/**
=======================================
--- /trunk/src/heuristics.h Tue Sep 25 06:49:57 2012
+++ /trunk/src/heuristics.h Thu Nov 15 13:33:44 2012
@@ -5,14 +5,14 @@
* Author:

*/

-#ifndef HEURISTICS_H_
-#define HEURISTICS_H_
+#ifndef SRC_HEURISTICS_H_
+#define SRC_HEURISTICS_H_

// link speed algorithms
void calc_linkspeed(char spds[4][256], int spd_index, int *c2sdata, int *c2sack,
- int* s2cdata, int *s2cack, float runave[4], u_int32_t
*dec_cnt,
- u_int32_t *same_cnt, u_int32_t *inc_cnt, int *timeout, int
*dupack,
- int isc2stest);
+ int* s2cdata, int *s2cack, float runave[4],
+ u_int32_t *dec_cnt, u_int32_t *same_cnt, u_int32_t *inc_cnt,
+ int *timeout, int *dupack, int isc2stest);

// calculate average round trip time
double calc_avg_rtt(int sumRTT, int countRTT, double * avgRTT);
@@ -25,18 +25,19 @@

// calculate theoretical maximum goodput in bits
double calc_max_theoretical_throughput(int currentMSS, double rttsec,
- double packetloss);
+ double packetloss);

// finalize some window sizes
void calc_window_sizes(int *SndWinScale, int *RcvWinScale, int SendBuf,
- int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin,
double *cwin);
+ int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin,
+ double *cwin);

// calculate RTO Idle time
double calc_RTOIdle(int timeouts, int CurrentRTO, double totaltime);

// calculate total test time for S_C test
int calc_totaltesttime(int SndLimTimeRwin, int SndLimTimeCwnd,
- int SndLimTimeSender);
+ int SndLimTimeSender);

// get time ratio of 'Sender Limited' time due to congestion
double calc_sendlimited_cong(int SndLimTimeCwnd, int totaltime);
@@ -65,35 +66,35 @@

// detect duplex mismatch mode
int detect_duplexmismatch(double cwndtime, double bwtheoretcl, int pktsretxed,
- double timesec, int maxsstartthresh, double idleRTO, int link,
- int s2cspd, int midboxspd, int multiple);
+ double timesec, int maxsstartthresh, double idleRTO,
+ int link, int s2cspd, int midboxspd, int multiple);

// detect if faulty hardware may exist
int detect_faultyhardwarelink(double packetloss, double cwndtime,
- double timesec, int maxslowstartthresh);
+ double timesec, int maxslowstartthresh);

// Is this an ethernet link?
int detect_ethernetlink(double realthruput, double s2cspd, double packetloss,
- double oo_order, int link);
+ double oo_order, int link);

// Is wireless link?
int detect_wirelesslink(double sendtime, double realthruput, double bw_theortcl,
- int sndlimtrans_rwin, int sndlimtrans_cwnd, double
rwindowtime,
- int link);
+ int sndlimtrans_rwin, int sndlimtrans_cwnd,
+ double rwindowtime, int link);

// Is DSL/Cable modem?
int detect_DSLCablelink(int sndlim_timesender, int sndlim_transsender,
- double realthruput, double bw_theoretical, int link);
+ double realthruput, double bw_theoretical, int link);

// Is a half_duplex link present?
int detect_halfduplex(double rwintime, int sndlim_transrwin,
- int sndlim_transsender, double totaltesttime);
+ int sndlim_transsender, double totaltesttime);

// Is congestion detected?
int detect_congestionwindow(double cwndtime, int mismatch, double cwin,
- double rwin, double rttsec);
+ double rwin, double rttsec);

// Is internal network link duplex mismatch detected?
int detect_internal_duplexmismatch(double s2cspd, double realthruput,
- double rwintime, double packetloss);
-#endif /* HEURISTICS_H_ */
+ double rwintime, double packetloss);
+#endif // SRC_HEURISTICS_H_
=======================================
--- /trunk/src/logging.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/logging.c Thu Nov 15 13:33:44 2012
@@ -19,11 +19,11 @@
#include <zlib.h>
/* #endif */

-#include "logging.h"
+#include "./logging.h"
/* #include "testoptions.h" */
-#include "strlutils.h"
-#include "utils.h"
-#include "protocol.h"
+#include "./strlutils.h"
+#include "./utils.h"
+#include "./protocol.h"

static int _debuglevel = 0;
static char* _programname = "";
@@ -36,7 +36,7 @@
static I2LogImmediateAttr _immediateattr_nl;
static I2LogImmediateAttr _immediateattr;
static time_t timestamp;
-static long int utimestamp;
+static int64_t utimestamp;

/**
* Compress snaplog, tcpdump, and cputime files to save disk space.
@@ -59,7 +59,6 @@
*/

int zlib_def(char *src_fn) {
-
int ret, flush, level = Z_DEFAULT_COMPRESSION;
char dest_fn[256];
FILE *dest, *source;
@@ -112,7 +111,6 @@
(void) deflateEnd(&strm);
return Z_ERRNO;
}
-
} while (strm.avail_out == 0);
assert(strm.avail_in == 0); /* all input will be used */

@@ -123,7 +121,8 @@
/* clean up and return */
(void) deflateEnd(&strm);

- /* compressed version of file is now created, remove the original uncompressed version */
+ // compressed version of file is now created, remove the original uncompressed
+ // version
remove(src_fn);

return Z_OK;
@@ -201,20 +200,18 @@

// Protocol log location being set
if (dirname == NULL) {
- //use default of BASEDIR/LOGDIR
+ // use default of BASEDIR/LOGDIR
log_println(5, "PV: 1: NULL proto location =%s;\n", ProtocolLogDirName);
return;
} else if (dirname[0] != '/') {
snprintf(localstr, sizeof(localstr), "%s/%s/", BASEDIR, dirname);
ProtocolLogDirName = localstr;
log_println(5, "PV: 2: non-dir proto location. So=%s;\n", dirname);
- } //end protocol dir name
- else {
+ } else { // end protocol dir name
snprintf(localstr, sizeof(localstr), "%s", dirname);
ProtocolLogDirName = dirname;
log_println(5, "PV33: proto location=%s;\n", ProtocolLogDirName);
}
-
}

/**
@@ -222,7 +219,7 @@
* @return directory where protocol logs are placed
*/
char* get_protologdir() {
- log_println(5," Protocol file location=%s;\n", ProtocolLogDirName);
+ log_println(5, " Protocol file location=%s;\n", ProtocolLogDirName);
return ProtocolLogDirName;
}

@@ -244,11 +241,13 @@
void create_protolog_dir() {
if ( get_protocolloggingenabled() ) {
set_timestamp();
- snprintf(protocollogfilestore, sizeof(protocollogfilestore), "%s/", get_protologdir());
- log_println(5,"Creating protocol log directory=%s", protocollogfilestore);
- create_named_logdir(protocollogfilestore, sizeof(protocollogfilestore), "", get_protocolloggingenabled());
+ snprintf(protocollogfilestore, sizeof(protocollogfilestore), "%s/",
+ get_protologdir());
+ log_println(5, "Creating protocol log directory=%s", protocollogfilestore);
+ create_named_logdir(protocollogfilestore, sizeof(protocollogfilestore), "",
+ get_protocolloggingenabled());
set_protologdir(protocollogfilestore);
- log_println(9,"DataDir remains=%s", DataDirName);
+ log_println(9, "DataDir remains=%s", DataDirName);
}
}

@@ -289,7 +288,8 @@
* @return The protocol log filename
*/

-char* get_protologfile(int socketNum, char *protologfilename, size_t filename_size) {
+char* get_protologfile(int socketNum, char *protologfilename,
+ size_t filename_size) {
char localAddr[64]="", remoteAddr[64]="";
I2Addr tmp_addr = NULL;
size_t tmpstrlen = sizeof(localAddr);
@@ -299,7 +299,7 @@
// get remote address
tmp_addr =
I2AddrBySockFD(get_errhandle(), socketNum, False);
- I2AddrNodeName(tmp_addr, remoteAddr, &tmpstrlen); //client name
+ I2AddrNodeName(tmp_addr, remoteAddr, &tmpstrlen); // client name

// get local address
tmp_addr = I2AddrByLocalSockFD(get_errhandle(), socketNum, False);
@@ -307,9 +307,10 @@
I2AddrNodeName(tmp_addr, localAddr, &tmpstrlen);

// copy address into filename String
- snprintf(protologfilename, filename_size, "%s/%s%s%s%s%s%s", ProtocolLogDirName, PROTOLOGPREFIX,
- localAddr, "_",remoteAddr, PROTOLOGSUFFIX, "\0");
- //log_print(0, "Log file name ---%s---", protologfilename);
+ snprintf(protologfilename, filename_size, "%s/%s%s%s%s%s%s",
+ ProtocolLogDirName, PROTOLOGPREFIX, localAddr, "_", remoteAddr,
+ PROTOLOGSUFFIX, "\0");
+ // log_print(0, "Log file name ---%s---", protologfilename);

return protologfilename;
}
@@ -350,8 +351,7 @@
* ... - the additional arguments
*/

-void log_print(int lvl, const char* format, ...)
-{
+void log_print(int lvl, const char* format, ...) {
va_list ap;

if (lvl > _debuglevel) {
@@ -359,7 +359,7 @@
}

va_start(ap, format);
- I2ErrLogVT(_errorhandler,-1,0,format,ap);
+ I2ErrLogVT(_errorhandler, -1, 0, format, ap);
va_end(ap);
}

@@ -371,8 +371,7 @@
* ... - the additional arguments
*/

-void log_println(int lvl, const char* format, ...)
-{
+void log_println(int lvl, const char* format, ...) {
va_list ap;

if (lvl > _debuglevel) {
@@ -380,7 +379,7 @@
}

va_start(ap, format);
- I2ErrLogVT(_errorhandler_nl,-1,0,format,ap);
+ I2ErrLogVT(_errorhandler_nl, -1, 0, format, ap);
va_end(ap);
}

@@ -395,7 +394,8 @@
* @return number or characters written to the output buffer
* */

-int quote_delimiters(const char *line, int line_size, char *output_buf, int output_buf_size) {
+int quote_delimiters(const char *line, int line_size, char *output_buf,
+ int output_buf_size) {
static char quoted[4][2] = {
{ '\n', 'n' },
{ '"', '"' },
@@ -425,7 +425,7 @@
}
}

- output_buf[j] = '\0'; // make sure it's null-terminated
+ output_buf[j] = '\0'; // make sure it's null-terminated
log_println(8, "****Received=%s; len=%d; dest=%d; MSG=%s", line, line_size,
output_buf_size, output_buf);

@@ -444,9 +444,9 @@
void protolog_printgeneric(const char* key, const char* value, int socketnum) {
FILE * fp;
char isotime[64];
-
- char logmessage[4096]; /* 4096 is just a random default buffer size for the protocol message
- Ideally, twice the messsage size will suffice */
+ // 4096 is just a random default buffer size for the protocol message.
+ // Ideally, twice the messsage size will suffice
+ char logmessage[4096];
char tmplogname[FILENAME_SIZE];

if (!enableprotologging) {
@@ -482,7 +482,7 @@
void protolog_status(int pid, enum TEST_ID testid,
enum TEST_STATUS_INT teststatus, int socketnum) {
FILE * fp;
- //va_list ap;
+ // va_list ap;
char protomessage[256];
char currenttestarr[TEST_NAME_DESC_SIZE];
char currentstatusarr[TEST_STATUS_DESC_SIZE];
@@ -491,7 +491,7 @@
char *teststatusdesc = "";
char tmplogname[FILENAME_SIZE]="";

- //get descriptive strings for test name and status
+ // get descriptive strings for test name and status
currenttestname = get_testnamedesc(testid, currenttestarr);
teststatusdesc = get_teststatusdesc(teststatus, currentstatusarr);

@@ -502,10 +502,10 @@

fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
if (fp == NULL) {
- log_println(
- 5,
- "--Unable to open protocol log file while trying to record test status message: %s for the %s test \n",
- teststatusdesc, currenttestname);
+ log_println(5,
+ "--Unable to open protocol log file while trying to record "
+ "test status message: %s for the %s test \n", teststatusdesc,
+ currenttestname);
} else {
snprintf(protomessage, sizeof(protomessage),
" event=\"%s\", name=\"%s\", pid=\"%d\", time=\"%s\"\n",
@@ -527,11 +527,13 @@
* @param socketnum Socket fd
*/
void protolog_procstatus(int pid, enum TEST_ID testidarg,
- enum PROCESS_TYPE_INT procidarg, enum PROCESS_STATUS_INT teststatusarg, int socketnum) {
+ enum PROCESS_TYPE_INT procidarg,
+ enum PROCESS_STATUS_INT teststatusarg, int socketnum) {
FILE * fp;
char protomessage[256];
char isotime[64];
- char currentprocarr[TEST_NAME_DESC_SIZE]; // size suffices to describe process name name too
+ // size suffices to describe process name name too
+ char currentprocarr[TEST_NAME_DESC_SIZE];
char currentstatusarr[PROCESS_STATUS_DESC_SIZE];
char currenttestarr[TEST_NAME_DESC_SIZE];

@@ -541,7 +543,7 @@

char tmplogname[FILENAME_SIZE];

- //get descriptive strings for test name and status
+ // get descriptive strings for test name and status
currenttestname = get_testnamedesc(testidarg, currenttestarr);
currentprocname = get_processtypedesc(procidarg, currentprocarr);
procstatusdesc = get_procstatusdesc(teststatusarg, currentstatusarr);
@@ -554,15 +556,16 @@
fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");

if (fp == NULL) {
- log_println(
- 5,
- "--Unable to open protocol log file while trying to record process status message: %s for the %s test \n",
- procstatusdesc, currentprocname);
+ log_println(5,
+ "--Unable to open protocol log file while trying to record "
+ "process status message: %s for the %s test \n", procstatusdesc,
+ currentprocname);
} else {
- log_println(8, " a0\n %s, %s, %s,%d", procstatusdesc,currentprocname,currenttestname,pid);
- snprintf(protomessage, sizeof(protomessage),
- " event=\"%s\", name=\"%s\", test=\"%s\", pid=\"%d\", time=\"%s\"\n",
- procstatusdesc, currentprocname, currenttestname, pid,
+ log_println(8, " a0\n %s, %s, %s,%d", procstatusdesc, currentprocname,
+ currenttestname, pid);
+ snprintf(protomessage, sizeof(protomessage), " event=\"%s\", name=\"%s\", "
+ "test=\"%s\", pid=\"%d\", time=\"%s\"\n", procstatusdesc,
+ currentprocname, currenttestname, pid,
get_currenttime(isotime, sizeof(isotime)));
fprintf(fp, "%s", protomessage);
fclose(fp);
@@ -582,11 +585,13 @@
* @param charbinary 8 digit character that contains binary information
* @param binout_arr output array containing binary bits
*/
-void printbinary(char *charbinary, int inarray_size, char *binout_arr, int outarr_size) {
+void printbinary(char *charbinary, int inarray_size, char *binout_arr,
+ int outarr_size) {
int j = 7, i = 0;

if ( outarr_size < 8 ) {
- log_println(8, "Invalid array sizes while formatting protocol binary data. Quitting");
+ log_println(8, "Invalid array sizes while formatting protocol binary data. "
+ "Quitting");
return;
}

@@ -617,25 +622,27 @@
* @param sizemsgbits Output buffer size
* @return isbitfield
*/
-int getMessageBodyFormat(int type, int len, char* msgbodytype, char* msgpayload, char* msgbits, int sizemsgbits) {
+int getMessageBodyFormat(int type, int len, char* msgbodytype,
+ char* msgpayload, char* msgbits, int sizemsgbits) {
int isbitfielddata = 0;
enum MSG_BODY_TYPE msgbodyformat = NOT_KNOWN;

- if (type == MSG_LOGIN && len ==1 ) {
+ if (type == MSG_LOGIN && len ==1) {
msgbodyformat = BITFIELD;
- strlcpy(msgbodytype, (char *)getmessageformattype(msgbodyformat,msgbodytype), MSG_BODY_FMT_SIZE );
- printbinary (msgpayload, len, msgbits, sizemsgbits);
+ strlcpy(msgbodytype,
+ (char *)getmessageformattype(msgbodyformat, msgbodytype),
+ MSG_BODY_FMT_SIZE);
+ printbinary(msgpayload, len, msgbits, sizemsgbits);
isbitfielddata = 1;
- }
- else {
+ } else {
msgbodyformat = STRING;
- strlcpy(msgbodytype , (char *)getmessageformattype(msgbodyformat,msgbodytype), MSG_BODY_FMT_SIZE);
+ strlcpy(msgbodytype,
+ (char *)getmessageformattype(msgbodyformat, msgbodytype),
+ MSG_BODY_FMT_SIZE);
// make delimiters in message payload explicit
quote_delimiters(msgpayload, len, msgbits, sizemsgbits);
-
}
return isbitfielddata;
-
}

/** Log all send/receive protocol messages.
@@ -656,7 +663,7 @@
char msgtypedescarr[MSG_TYPE_DESC_SIZE];
char *currenttestname, *currentmsgtype;
char isotime[64];
- char logmessage[4096]; // message after replacing delimiter characters
+ char logmessage[4096]; // message after replacing delimiter characters
char protologfile[FILENAME_SIZE];
char msgbodytype[MSG_BODY_FMT_SIZE];

@@ -664,20 +671,23 @@
currenttestname = get_currenttestdesc();
currentmsgtype = get_msgtypedesc(type, msgtypedescarr);

- getMessageBodyFormat(type, len, msgbodytype, (char *) msg, logmessage, sizeof(logmessage));
+ getMessageBodyFormat(type, len, msgbodytype, (char *) msg, logmessage,
+ sizeof(logmessage));

- fp = fopen(get_protologfile(ctlSocket, protologfile, sizeof(protologfile)), "a");
+ fp = fopen(get_protologfile(ctlSocket, protologfile, sizeof(protologfile)),
+ "a");
if (fp == NULL) {
log_println(
5,
"Unable to open protocol log file '%s', continuing on without logging",
protologfile);
} else {
- fprintf(
- fp,
- " event=\"message\", direction=\"%s\", test=\"%s\", type=\"%s\", len=\"%d\", msg_body_format=\"%s\", msg=\"%s\", pid=\"%d\", socket=\"%d\", time=\"%s\"\n",
- msgdirection, currenttestname, currentmsgtype, len, msgbodytype, logmessage,
- processid, ctlSocket, get_currenttime(isotime, sizeof(isotime)));
+ fprintf(fp,
+ " event=\"message\", direction=\"%s\", test=\"%s\", type=\"%s\", "
+ "len=\"%d\", msg_body_format=\"%s\", msg=\"%s\", pid=\"%d\", "
+ "socket=\"%d\", time=\"%s\"\n", msgdirection, currenttestname,
+ currentmsgtype, len, msgbodytype, logmessage, processid, ctlSocket,
+ get_currenttime(isotime, sizeof(isotime)));
fclose(fp);
}
}
@@ -739,7 +749,6 @@
* RAC 5/6/09
* timestamp = time(NULL);
*/
-
}

/**
@@ -754,7 +763,7 @@
* Return the previously recorded utimestamp.
* @return The utimestamp
*/
-long int get_utimestamp() {
+int64_t get_utimestamp() {
return utimestamp;
}

@@ -765,7 +774,6 @@
*/

void get_YYYY(char *year, size_t year_strlen) {
-
struct tm *result;
time_t now;

@@ -783,7 +791,6 @@
*/

void get_MM(char *month, size_t month_strlen) {
-
struct tm *result;
time_t now;

@@ -805,7 +812,6 @@
*/

void get_DD(char *day, size_t day_strlen) {
-
struct tm *result;
time_t now;
setenv("TZ", "UTC", 0);
@@ -883,7 +889,7 @@
struct tm *result;
time_t rc;
rc = time(&rawtime);
- if(rc!=-1) {
+ if (rc != -1) {
result = gmtime(&rawtime);
return (fill_ISOtime(result, isoTime, isotimearrsize));
}
@@ -898,9 +904,7 @@
* @param Pointer to the string indicating ISO time
* @param character string with ISO time string.
*/
-char *
-get_ISOtime(char *isoTime, int isotimearrsize) {
-
+char * get_ISOtime(char *isoTime, int isotimearrsize) {
struct tm *result;
time_t now;

@@ -925,16 +929,16 @@
void writeMeta(int compress, int cputime, int snaplog, int tcpdump) {
FILE * fp;
char tmpstr[256];
- //char dir[128];
+ // char dir[128];
char dirpathstr[256]="";
char *tempptr;
- int ptrdiff=0;
+ int ptrdiff = 0;

- //char isoTime[64];
+ // char isoTime[64];
char filename[256];
size_t tmpstrlen = sizeof(tmpstr);
socklen_t len;
- //DIR *dp;
+ // DIR *dp;
char metafilesuffix[256] = "meta";

/* Get the clients domain name and same in metadata file
@@ -950,7 +954,8 @@
if (meta.family == AF_INET)
len = sizeof(struct sockaddr_in);

- // Look up the host name and service name information for given struct sockaddress and length
+ // Look up the host name and service name information for given struct
+ // sockaddress and length
if (getnameinfo((struct sockaddr *) &meta.c_addr, len, tmpstr, tmpstrlen,
NULL, 0, NI_NAMEREQD)) {
// No fully qualified domain name
@@ -979,15 +984,15 @@
if (tempptr != NULL) {
ptrdiff = tempptr - tmpstr;
strlcpy(dirpathstr, tmpstr, ptrdiff);
- } //obtained directory in "dirpathstr"
+ } // obtained directory in "dirpathstr"
log_println(5,
"Compression is enabled, compress all files in '%s' basedir",
dirpathstr);
- if (snaplog) { // if snaplog is enabled, compress those into .gz formats
-
+ if (snaplog) { // if snaplog is enabled, compress those into .gz formats
// Try compressing C->S test snaplogs
memset(filename, 0, sizeof(filename));
- snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.c2s_snaplog);
+ snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+ meta.c2s_snaplog);
if (zlib_def(filename) != 0)
log_println(0, "compression failed for file:%s: %s.", filename,
dirpathstr);
@@ -996,7 +1001,8 @@

// Try compressing S->C test snaplogs
memset(filename, 0, sizeof(filename));
- snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.s2c_snaplog);
+ snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+ meta.s2c_snaplog);
if (zlib_def(filename) != 0)
log_println(0, "compression failed for file :%s", filename);
else
@@ -1005,11 +1011,11 @@

// If tcpdump file writing is enabled, compress those
if (tcpdump) {
-
// Try compressing C->S test tcpdump.
// The tcpdump file extension is as specified in the "meta" data-structure
memset(filename, 0, sizeof(filename));
- snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.c2s_ndttrace);
+ snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+ meta.c2s_ndttrace);
if (zlib_def(filename) != 0)
log_println(0, "compression failed for tcpdump file %s =%s",
filename, meta.c2s_ndttrace);
@@ -1018,7 +1024,8 @@

// Try compressing S->C test tcpdumps
memset(filename, 0, sizeof(filename));
- snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.s2c_ndttrace);
+ snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+ meta.s2c_ndttrace);
if (zlib_def(filename) != 0)
log_println(0, "compression failed for tcpdump file %s =%s",
filename, meta.s2c_ndttrace);
@@ -1034,16 +1041,16 @@
log_println(0, "compression failed");
else
strlcat(meta.CPU_time, ".gz", sizeof(meta.CPU_time));
- } else
- log_println(
- 5,
- "Zlib compression disabled, log files will not be compressed in %s", tmpstr);
+ } else {
+ log_println(5, "Zlib compression disabled, log files will not be "
+ "compressed in %s", tmpstr);
+ }
}
/* #endif */

// Try logging metadata into the metadata logfile
fp = fopen(tmpstr, "w");
- if (fp == NULL) { // error, unable to open file in write mode
+ if (fp == NULL) { // error, unable to open file in write mode
log_println(
1,
"Unable to open metadata log file, continuing on without logging");
@@ -1093,9 +1100,8 @@
*/
void create_named_logdir(char *dirnamedestarg, int destnamearrsize,
char *finalsuffix, char isProtoLog) {
-
- //char namebuf[256];
- //size_t namebuflen = 255;
+ // char namebuf[256];
+ // size_t namebuflen = 255;
char dir[128];
DIR *dp;
if ( !isProtoLog ) {
@@ -1147,8 +1153,8 @@
* @param finalsuffixsize string constant suffix indicating C2S/S2c etc
*/
void create_client_logdir(struct sockaddr *cliaddrarg, socklen_t clilenarg,
- char *dirnamedestarg, int destnamearrsize, char *finalsuffix,
- int finalsuffixsize) {
+ char *dirnamedestarg, int destnamearrsize,
+ char *finalsuffix, int finalsuffixsize) {
char namebuf[256];
size_t namebuflen = 255;
char dir[128];
@@ -1161,14 +1167,14 @@
I2AddrNodeName(sockAddr, namebuf, &namebuflen);
socketaddrport = I2AddrPort(sockAddr);

- snprintf(dir, sizeof(dir), "%s_%s:%d.%s", get_ISOtime(isoTime, sizeof(isoTime)), namebuf,
+ snprintf(dir, sizeof(dir), "%s_%s:%d.%s",
+ get_ISOtime(isoTime, sizeof(isoTime)), namebuf,
socketaddrport, finalsuffix);
strlcpy(finalsuffix, dir, finalsuffixsize);

create_named_logdir(dirnamedestarg, destnamearrsize, finalsuffix, 0);

I2AddrFree(sockAddr);
-
}

/**
=======================================
--- /trunk/src/logging.h Mon Nov 5 10:30:55 2012
+++ /trunk/src/logging.h Thu Nov 15 13:33:44 2012
@@ -6,22 +6,22 @@
*

*/

-#ifndef _JS_LOGGING_H
-#define _JS_LOGGING_H
+#ifndef SRC_LOGGING_H_
+#define SRC_LOGGING_H_

#include <I2util/util.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include "ndtptestconstants.h"
-#include "runningtest.h" // protocol validation
-#define LOG_FACILITY LOG_LOCAL0 /* Syslog facility to log at */
-#define LOGDIR "serverdata" /* directory for detailed snaplog and tcpdump files */
-#define LOGFILE "web100srv.log" /* Name of log file */
-#define PROTOLOGFILE "web100srvprotocol.log" /* Name of protocol validation log file */
-#define PROTOLOGPREFIX "web100srvprotocol_" /* prefix for protocol validation log file */
-#define PROTOLOGSUFFIX ".log" /* suffix for protocol validation log file */
-#define FILENAME_SIZE 256 /* This could have been in utils.h, but will be used immediately here */
+#include "./ndtptestconstants.h"
+#include "./runningtest.h" // protocol validation
+#define LOG_FACILITY LOG_LOCAL0 /* Syslog facility to log at */
+#define LOGDIR "serverdata" // directory for detailed snaplog and tcpdump files
+#define LOGFILE "web100srv.log" /* Name of log file */
+#define PROTOLOGFILE "web100srvprotocol.log" // name of protocol log file
+#define PROTOLOGPREFIX "web100srvprotocol_" // prefix for protocol log file
+#define PROTOLOGSUFFIX ".log" // suffix for protocol validation log file
+#define FILENAME_SIZE 256
/* #define PROTOLOGDIR "protocollog" Protocol log dir */
void log_init(char* progname, int debuglvl);
void set_debuglvl(int debuglvl);
@@ -49,9 +49,9 @@
* Format used to exchange meta test data between client->server.
* */
struct metaentry {
- char key[64]; // key name
- char value[256]; // value associated with this meta key
- struct metaentry* next; // pointer to next link
+ char key[64]; // key name
+ char value[256]; // value associated with this meta key
+ struct metaentry* next; // pointer to next link
};

/**
@@ -60,55 +60,58 @@
* meta data file created for every session
* */
struct metadata {
- char c2s_snaplog[FILENAME_SIZE]; // C->S test Snaplog file name, changed to 256 to avoid truncation
- char c2s_ndttrace[FILENAME_SIZE]; // C->S NDT trace file name, changed to 256 to avoid truncation
- char s2c_snaplog[FILENAME_SIZE]; // S->C test Snaplog file name, changed to 256 to avoid truncation
- char s2c_ndttrace[FILENAME_SIZE]; // S->C NDT trace file name, changed to 256 to avoid truncation
- char CPU_time[FILENAME_SIZE]; // CPU time file
- char summary[256]; // Summary data
- char date[32]; // Date and,
- char time[16]; // time
- char client_ip[64]; // Client IP Address
- struct sockaddr_storage c_addr; // client socket details, not logged
- char client_name[64]; // client's host-name
- char client_os[32]; // client OS name
- char client_browser[32]; // client's browser name
- char client_application[32]; // client application name
- int ctl_port; // ctl port
- char server_ip[64]; // server IP address
- char server_name[64]; // server's host-name
- char server_os[32]; // server os name
- int family; // IP family
- struct metaentry* additional; // all other additional data
+ char c2s_snaplog[FILENAME_SIZE]; // C->S test Snaplog file name
+ char c2s_ndttrace[FILENAME_SIZE]; // C->S NDT trace file name
+ char s2c_snaplog[FILENAME_SIZE]; // S->C test Snaplog file name
+ char s2c_ndttrace[FILENAME_SIZE]; // S->C NDT trace file name
+ char CPU_time[FILENAME_SIZE]; // CPU time file
+ char summary[256]; // Summary data
+ char date[32]; // Date and,
+ char time[16]; // time
+ char client_ip[64]; // Client IP Address
+ struct sockaddr_storage c_addr; // client socket details, not logged
+ char client_name[64]; // client's host-name
+ char client_os[32]; // client OS name
+ char client_browser[32]; // client's browser name
+ char client_application[32]; // client application name
+ int ctl_port; // ctl port
+ char server_ip[64]; // server IP address
+ char server_name[64]; // server's host-name
+ char server_os[32]; // server os name
+ int family; // IP family
+ struct metaentry* additional; // all other additional data
};

void set_protologdir(char* dirname);
void set_protologfile(char* client_ip, char *protologfileparam);
char*
-get_protologfile(int socketNum, char *protologfilename, size_t filename_size) ;
+get_protologfile(int socketNum, char *protologfilename, size_t filename_size);
char* get_protologdir();
void enableprotocollogging();
char *createprotologfilename(char* client_ip, char* textappendarg);
void create_named_logdir(char *dirnamedestarg, int destnamearrsize,
- char *finalsuffix, char isProtoLog);
+ char *finalsuffix, char isProtoLog);
void create_client_logdir(struct sockaddr *cliaddrarg, socklen_t clilenarg,
- char *dirnamedestarg, int destnamearrsize, char *finalsuffix,
- int finalsuffixsize);
+ char *dirnamedestarg, int destnamearrsize,
+ char *finalsuffix, int finalsuffixsize);
void log_linkspeed(int index);

-void protolog_printgeneric(const char* key, const char* val,int socketnum);
+void protolog_printgeneric(const char* key, const char* val, int socketnum);
void protolog_status(int pid, enum TEST_ID testid,
- enum TEST_STATUS_INT teststatus,int socketnum);
+ enum TEST_STATUS_INT teststatus, int socketnum);
void protolog_sendprintln(const int type, void* msg, const int len,
- const int processid, const int ctlSocket);
+ const int processid, const int ctlSocket);
void protolog_rcvprintln(const int type, void* msg, const int len,
- const int processid, const int ctlSocket);
+ const int processid, const int ctlSocket);
void protolog_procstatus(int pid, enum TEST_ID testidarg,
- enum PROCESS_TYPE_INT procidarg, enum PROCESS_STATUS_INT teststatusarg, int socketnum);
+ enum PROCESS_TYPE_INT procidarg,
+ enum PROCESS_STATUS_INT teststatusarg, int socketnum);
void protolog_procstatuslog(int pid, enum TEST_ID testidarg,
- enum PROCESS_TYPE_INT procidarg, enum PROCESS_STATUS_INT teststatusarg, int socketnum);
+ enum PROCESS_TYPE_INT procidarg,
+ enum PROCESS_STATUS_INT teststatusarg,
+ int socketnum);
char get_protocolloggingenabled();
void create_protolog_dir();

struct metadata meta;
-#endif
+#endif // SRC_LOGGING_H_
=======================================
--- /trunk/src/mrange.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/mrange.c Thu Nov 15 13:33:44 2012
@@ -10,9 +10,9 @@
#include <assert.h>
#include <string.h>

-#include "utils.h"
-#include "logging.h"
-#include "strlutils.h"
+#include "./utils.h"
+#include "./logging.h"
+#include "./strlutils.h"

typedef struct range {
int min; /**< lower end of the range */
@@ -42,16 +42,16 @@
if (strlen(text) > 299) {
return 1;
}
- //strcpy(tmp, text);
+ // strcpy(tmp, text);
strlcpy(tmp, text, sizeof(tmp));
// tokenize based on a "," character.
// An example of the string : 2003:3000,4000:5000
ptr = strtok(tmp, ",");
- while (ptr != NULL) { // tokens found
- if ((sptr = strchr(ptr, ':')) != NULL) { // also found a ":" character,
+ while (ptr != NULL) { // tokens found
+ if ((sptr = strchr(ptr, ':')) != NULL) { // also found a ":" character,
// with sptr pointing to its location
*sptr++ = 0;
- if (strchr(sptr, ':') != NULL) { // should not find any more range
+ if (strchr(sptr, ':') != NULL) { // should not find any more range
return 1;
}
} else {
@@ -79,10 +79,10 @@
// result as "maximum"
if (check_rint(sptr, &mr_ptr->max, 1, MAX_TCP_PORT)) {
free(mr_ptr);
- return 1; // if invalid range, free allocated memory and return
+ return 1; // if invalid range, free allocated memory and return
}
mr_ptr->next = mrange_root;
- mrange_root = mr_ptr; // ready to point to next member
+ mrange_root = mr_ptr; // ready to point to next member
ptr = strtok(NULL, ",");
}
free(mr_ptr);
@@ -107,16 +107,16 @@

assert(port);

- if (check_rint(port, &val, 0, MAX_TCP_PORT)) { // check if valid
+ if (check_rint(port, &val, 0, MAX_TCP_PORT)) { // check if valid
log_println(0, "WARNING: invalid port number");
snprintf(port, port_strlen, RESERVED_PORT);
return port;
}
val++;
- while (val <= MAX_TCP_PORT) { // Maximum port number not exceeded
+ while (val <= MAX_TCP_PORT) { // Maximum port number not exceeded
ptr = mrange_root;
- while (ptr != NULL) { // While there is some data
- if ((val >= ptr->min) && (val <= ptr->max)) { // check range
+ while (ptr != NULL) { // While there is some data
+ if ((val >= ptr->min) && (val <= ptr->max)) { // check range
// and return port if valid
snprintf(port, port_strlen, "%d", val);
return port;
=======================================
--- /trunk/src/mrange.h Mon Nov 5 10:30:55 2012
+++ /trunk/src/mrange.h Thu Nov 15 13:33:44 2012
@@ -6,10 +6,10 @@
*

*/

-#ifndef _JS_MRANGE_H
-#define _JS_MRANGE_H
+#ifndef SRC_MRANGE_H_
+#define SRC_MRANGE_H_

int mrange_parse(char* text);
char* mrange_next(char* port, size_t port_strlen);

-#endif
+#endif // SRC_MRANGE_H_
=======================================
--- /trunk/src/ndt_odbc.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/ndt_odbc.c Thu Nov 15 13:33:44 2012
@@ -14,9 +14,9 @@
#include <sqlext.h>
#endif

-#include "ndt_odbc.h"
-#include "logging.h"
-#include "strlutils.h"
+#include "./ndt_odbc.h"
+#include "./logging.h"
+#include "./strlutils.h"

#if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
SQLHENV env;
@@ -102,9 +102,7 @@
* @param type SQLHandle type
* */

- static void
-extract_error(char *fn, SQLHANDLE handle, SQLSMALLINT type)
-{
+static void extract_error(char *fn, SQLHANDLE handle, SQLSMALLINT type) {
SQLINTEGER i = 0;
SQLINTEGER native;
SQLCHAR state[ 7 ];
@@ -112,17 +110,17 @@
SQLSMALLINT len;
SQLRETURN ret;

- log_println(2, "\nThe driver reported the following diagnostics whilst running %s:\n", fn);
- do
- {
- // get current values of multiple fields(error, warning, and status) of diagnostic record
- // and see if return value indicated success
- ret = SQLGetDiagRec(type, handle, ++i, state, &native, text,
- sizeof(text), &len );
+ log_println(2, "\nThe driver reported the following diagnostics whilst "
+ "running %s:\n", fn);
+ do {
+ // get current values of multiple fields(error, warning, and status) of
+ // diagnostic record and see if return value indicated success
+ ret = SQLGetDiagRec(type, handle, ++i, state, &native, text, sizeof(text),
+ &len);
if (SQL_SUCCEEDED(ret))
log_println(2, "%s:%ld:%ld:%s", state, i, native, text);
}
- while( ret == SQL_SUCCESS );
+ while (ret == SQL_SUCCESS);
}
#endif

@@ -143,8 +141,10 @@
SQLSMALLINT outstrlen;
char loginstring[1024];

- log_println(1, "Initializing DB with DSN='%s', UID='%s', PWD=%s", dsn, uid, pwd ? "yes" : "no");
- snprintf(createTableStmt, sizeof(createTableStmt), "%s%s%s%s", ctStmt_1, ctStmt_2, ctStmt_3, ctStmt_4);
+ log_println(1, "Initializing DB with DSN='%s', UID='%s', PWD=%s", dsn, uid,
+ pwd ? "yes" : "no");
+ snprintf(createTableStmt, sizeof(createTableStmt), "%s%s%s%s", ctStmt_1,
+ ctStmt_2, ctStmt_3, ctStmt_4);

// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
@@ -155,9 +155,9 @@
// Connect to the DSN after creating summarizing login data
// into "loginstring"
memset(loginstring, 0, 1024);
- snprintf(loginstring, 256, "DSN=%s;", dsn);
+ snprintf(loginstring, sizeof(loginstring), "DSN=%s;", dsn);
if (uid) {
- //strcat(loginstring, "UID=");
+ // strcat(loginstring, "UID=");
// strncat(loginstring, uid, 256);
// strcat(loginstring, ";");
strlcat(loginstring, "UID=", sizeof(loginstring));
@@ -165,13 +165,14 @@
strlcat(loginstring, ";", sizeof(loginstring));
}
if (pwd) {
- //strcat(loginstring, "PWD=");
+ // strcat(loginstring, "PWD=");
strlcat(loginstring, "PWD=", sizeof(loginstring));
- //strncat(loginstring, pwd, 256);
+ // strncat(loginstring, pwd, 256);
strlcat(loginstring, pwd, sizeof(loginstring));
}
ret = SQLDriverConnect(dbc, NULL, (unsigned char*) loginstring, SQL_NTS,
- outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_NOPROMPT);
+ outstr, sizeof(outstr), &outstrlen,
+ SQL_DRIVER_NOPROMPT);
if (SQL_SUCCEEDED(ret)) {
log_println(2, " Connected");
log_println(2, " Returned connection string was:\n\t%s", outstr);
@@ -180,27 +181,31 @@
extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
}
} else {
- log_println(0, " Failed to connect to the DSN\n Continuing without DB logging");
+ log_println(0, " Failed to connect to the DSN\n Continuing without DB "
+ "logging");
extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
return 1;
}
// Allocate a statement handle
ret = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
if (!SQL_SUCCEEDED(ret)) {
- log_println(0, " Failed to alloc statement handle\n Continuing without DB logging");
+ log_println(0, " Failed to alloc statement handle\n Continuing without "
+ "DB logging");
extract_error("SQLAllocHandle", dbc, SQL_HANDLE_DBC);
return 1;
}
// Retrieve a list of tables
- ret = SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, (unsigned char*) "TABLE", SQL_NTS);
+ ret = SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, (unsigned char*) "TABLE",
+ SQL_NTS);
if (!SQL_SUCCEEDED(ret)) {
- log_println(0, " Failed to fetch table info\n Continuing without DB logging");
+ log_println(0, " Failed to fetch table info\n Continuing without DB "
+ "logging");
extract_error("SQLTables", dbc, SQL_HANDLE_DBC);
return 1;
}
// How many columns are there?
SQLNumResultCols(stmt, &columns);
- log_println(3,"Fetched SQLNumResults:%d", columns);
+ log_println(3, "Fetched SQLNumResults:%d", columns);
// Loop through the rows in the result-set
while (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
SQLUSMALLINT i;
@@ -214,7 +219,7 @@
if (SQL_SUCCEEDED(ret)) {
// Handle null columns
if (indicator == SQL_NULL_DATA)
- //strcpy(buf, "NULL");
+ // strcpy(buf, "NULL");
strlcpy(buf, "NULL", sizeof(buf));
if (strcmp(buf, "ndt_test_results") == 0) {
// the table exists - do nothing
@@ -228,9 +233,11 @@
// the table doesn't exist - create it
SQLFreeStmt(stmt, SQL_CLOSE);
log_print(1, "The table 'ndt_test_results' doesn't exist, creating...");
- ret = SQLExecDirect(stmt, (unsigned char*) createTableStmt, strlen(createTableStmt));
+ ret = SQLExecDirect(stmt, (unsigned char*) createTableStmt,
+ strlen(createTableStmt));
if (!SQL_SUCCEEDED(ret)) {
- log_println(0, " Failed to create table\n Continuing without DB logging");
+ log_println(0, " Failed to create table\n Continuing without DB "
+ "logging");
extract_error("SQLExecDirect", dbc, SQL_HANDLE_DBC);
stmt = NULL;
return 1;
@@ -251,34 +258,36 @@
int db_insert(char spds[4][256], float runave[], char* cputimelog,
char* snaplog, char* c2s_snaplog, char* hostName, int testPort,
char* date, char* rmt_host, int s2c2spd, int s2cspd, int c2sspd,
- int Timeouts, int SumRTT, int CountRTT, int PktsRetrans, int FastRetran,
- int DataPktsOut, int AckPktsOut, int CurrentMSS, int DupAcksIn,
- int AckPktsIn, int MaxRwinRcvd, int Sndbuf, int MaxCwnd,
- int SndLimTimeRwin, int SndLimTimeCwnd, int SndLimTimeSender,
- int DataBytesOut, int SndLimTransRwin, int SndLimTransCwnd,
- int SndLimTransSender, int MaxSsthresh, int CurrentRTO,
- int CurrentRwinRcvd, int link, int mismatch, int bad_cable,
- int half_duplex, int congestion, int c2s_linkspeed_data, int c2s_linkspeed_ack, int s2c_linkspeed_data,
- int s2c_linkspeed_ack, int CongestionSignals, int PktsOut, int MinRTT,
- int RcvWinScale, int autotune, int CongAvoid, int CongestionOverCount,
- int MaxRTT, int OtherReductions, int CurTimeoutCount,
- int AbruptTimeouts, int SendStall, int SlowStart,
- int SubsequentTimeouts, int ThruBytesAcked, int minPeak, int maxPeak,
- int peaks) {
+ int Timeouts, int SumRTT, int CountRTT, int PktsRetrans,
+ int FastRetran, int DataPktsOut, int AckPktsOut, int CurrentMSS,
+ int DupAcksIn, int AckPktsIn, int MaxRwinRcvd, int Sndbuf,
+ int MaxCwnd, int SndLimTimeRwin, int SndLimTimeCwnd,
+ int SndLimTimeSender, int DataBytesOut, int SndLimTransRwin,
+ int SndLimTransCwnd, int SndLimTransSender, int MaxSsthresh,
+ int CurrentRTO, int CurrentRwinRcvd, int link, int mismatch,
+ int bad_cable, int half_duplex, int congestion,
+ int c2s_linkspeed_data, int c2s_linkspeed_ack,
+ int s2c_linkspeed_data, int s2c_linkspeed_ack,
+ int CongestionSignals, int PktsOut, int MinRTT, int RcvWinScale,
+ int autotune, int CongAvoid, int CongestionOverCount, int MaxRTT,
+ int OtherReductions, int CurTimeoutCount, int AbruptTimeouts,
+ int SendStall, int SlowStart, int SubsequentTimeouts,
+ int ThruBytesAcked, int minPeak, int maxPeak, int peaks) {
#if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
SQLRETURN ret;
char insertStmt[2048];
- int i_iter = 0, arr_len = 4; // 4 runspeed-averages are obtained
+ int i_iter = 0, arr_len = 4; // 4 runspeed-averages are obtained
if (!stmt) {
return 1;
}
- // Check if any of the run averages are nan numbers
+ // Check if any of the run averages are nan numbers
for (i_iter = 0; i_iter < arr_len; i_iter++) {
- log_println(3,"Odbc:Padding %f?", runave[i_iter]);
+ log_println(3, "Odbc:Padding %f?", runave[i_iter]);
pad_NaN(&runave[i_iter]);
- log_println(3,"Odbc:After Padding %f", runave[i_iter]);
+ log_println(3, "Odbc:After Padding %f", runave[i_iter]);
}
- snprintf(insertStmt, 2040, "INSERT INTO ndt_test_results VALUES ("
+ snprintf(insertStmt, sizeof(insertStmt),
+ "INSERT INTO ndt_test_results VALUES ("
"'%s','%s','%s','%s',%f,%f,%f,%f,"
"'%s','%s','%s','%s',%d,"
"'%s','%s',%d,%d,%d,%d,"
@@ -293,24 +302,25 @@
"%d,%d,%d,%d,"
"%d,%d,%d,%d,%d"
");",
- spds[0], spds[1], spds[2], spds[3], runave[0], runave[1], runave[2], runave[3],
- cputimelog, snaplog, c2s_snaplog, hostName, testPort,
+ spds[0], spds[1], spds[2], spds[3], runave[0], runave[1], runave[2],
+ runave[3], cputimelog, snaplog, c2s_snaplog, hostName, testPort,
date, rmt_host, s2c2spd, s2cspd, c2sspd, Timeouts,
SumRTT, CountRTT, PktsRetrans, FastRetran, DataPktsOut,
AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd,
Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
DataBytesOut, SndLimTransRwin, SndLimTransCwnd, SndLimTransSender,
MaxSsthresh, CurrentRTO, CurrentRwinRcvd, link, mismatch,
- bad_cable, half_duplex, congestion, c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
- s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale,
- autotune, CongAvoid, CongestionOverCount, MaxRTT, OtherReductions,
- CurTimeoutCount, AbruptTimeouts, SendStall, SlowStart,
- SubsequentTimeouts, ThruBytesAcked, minPeak, maxPeak, peaks
- );
+ bad_cable, half_duplex, congestion, c2s_linkspeed_data,
+ c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack,
+ CongestionSignals, PktsOut, MinRTT, RcvWinScale, autotune, CongAvoid,
+ CongestionOverCount, MaxRTT, OtherReductions, CurTimeoutCount,
+ AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
+ ThruBytesAcked, minPeak, maxPeak, peaks);
ret = SQLExecDirect(stmt, (unsigned char*) insertStmt, strlen(insertStmt));
- log_println(3, "Trying to insert data using the statement:%s", insertStmt);
+ log_println(3, "Trying to insert data using the statement:%s", insertStmt);
if (!SQL_SUCCEEDED(ret)) {
- log_println(0, " Failed to insert test results into the table\n Continuing without DB logging");
+ log_println(0, " Failed to insert test results into the table\n "
+ "Continuing without DB logging");
extract_error("SQLExecDirect", dbc, SQL_HANDLE_DBC);
stmt = NULL;
return 1;
@@ -330,6 +340,6 @@
void pad_NaN(float *float_val) {
if (*float_val != *float_val) {
*float_val = -1;
- log_println(0," A float value you tried to insert into the DB was NaN");
+ log_println(0, " A float value you tried to insert into the DB was NaN");
}
}
=======================================
--- /trunk/src/ndt_odbc.h Tue Sep 25 06:49:57 2012
+++ /trunk/src/ndt_odbc.h Thu Nov 15 13:33:44 2012
@@ -5,28 +5,28 @@
*

*/

-#ifndef _JS_NDT_ODBC_H
-#define _JS_NDT_ODBC_H
+#ifndef SRC_NDT_ODBC_H_
+#define SRC_NDT_ODBC_H_

int initialize_db(int options, char* dsn, char* uin, char* pwd);
int db_insert(char spds[4][256], float runave[], char* cputimelog,
- char* snaplog, char* c2s_snaplog, char* hostName, int
testPort,
- char* date, char* rmt_host, int s2c2spd, int s2cspd, int
c2sspd,
- int Timeouts, int SumRTT, int CountRTT, int PktsRetrans, int
FastRetran,
- int DataPktsOut, int AckPktsOut, int CurrentMSS, int
DupAcksIn,
- int AckPktsIn, int MaxRwinRcvd, int Sndbuf, int MaxCwnd,
- int SndLimTimeRwin, int SndLimTimeCwnd, int SndLimTimeSender,
- int DataBytesOut, int SndLimTransRwin, int SndLimTransCwnd,
- int SndLimTransSender, int MaxSsthresh, int CurrentRTO,
- int CurrentRwinRcvd, int link, int mismatch, int bad_cable,
- int half_duplex, int congestion, int c2sdata, int c2sack, int
s2cdata,
- int s2cack, int CongestionSignals, int PktsOut, int MinRTT,
- int RcvWinScale, int autotune, int CongAvoid, int
CongestionOverCount,
- int MaxRTT, int OtherReductions, int CurTimeoutCount,
- int AbruptTimeouts, int SendStall, int SlowStart,
- int SubsequentTimeouts, int ThruBytesAcked, int minPeaks, int
maxPeaks,
- int peaks);
+ char* snaplog, char* c2s_snaplog, char* hostName, int testPort,
+ char* date, char* rmt_host, int s2c2spd, int s2cspd, int c2sspd,
+ int Timeouts, int SumRTT, int CountRTT, int PktsRetrans,
+ int FastRetran, int DataPktsOut, int AckPktsOut, int CurrentMSS,
+ int DupAcksIn, int AckPktsIn, int MaxRwinRcvd, int Sndbuf,
+ int MaxCwnd, int SndLimTimeRwin, int SndLimTimeCwnd,
+ int SndLimTimeSender, int DataBytesOut, int SndLimTransRwin,
+ int SndLimTransCwnd, int SndLimTransSender, int MaxSsthresh,
+ int CurrentRTO, int CurrentRwinRcvd, int link, int mismatch,
+ int bad_cable, int half_duplex, int congestion, int c2sdata,
+ int c2sack, int s2cdata, int s2cack, int CongestionSignals,
+ int PktsOut, int MinRTT, int RcvWinScale, int autotune,
+ int CongAvoid, int CongestionOverCount, int MaxRTT,
+ int OtherReductions, int CurTimeoutCount, int AbruptTimeouts,
+ int SendStall, int SlowStart, int SubsequentTimeouts,
+ int ThruBytesAcked, int minPeaks, int maxPeaks, int peaks);

void pad_NaN(float *float_val);

-#endif
+#endif // SRC_NDT_ODBC_H_
=======================================
--- /trunk/src/ndtptestconstants.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/ndtptestconstants.c Thu Nov 15 13:33:44 2012
@@ -8,7 +8,7 @@
*/

#include <string.h>
-#include "ndtptestconstants.h"
+#include "./ndtptestconstants.h"

// The arrays below rely on the ordering of corresponding enum in the .h file.
// test names
@@ -38,7 +38,7 @@
* */
char *get_testnamedesc(enum TEST_ID testid, char *snamearg) {
snamearg = _testnamesarray[testid];
- //printf ("--current test name = %s for %d\n", snamearg ,testid);
+ // printf ("--current test name = %s for %d\n", snamearg ,testid);
return snamearg;
}

@@ -50,7 +50,7 @@
* */
char *get_teststatusdesc(enum TEST_STATUS_INT teststatus, char *sstatusarg) {
sstatusarg = _teststatusdescarray[teststatus];
- //printf ("--current test status = %s, for %d \n", sstatusarg, teststatus);
+ // printf ("--current test status = %s, for %d \n", sstatusarg, teststatus);
return sstatusarg;
}

@@ -63,7 +63,8 @@
* */
char *get_testdirectiondesc(enum Tx_DIRECTION testdirection, char *sdirnarg) {
sdirnarg = _txdirectionsarray[testdirection];
- //printf ("--current test direction = %s , for %d\n", sdirnarg, testdirection);
+ // printf ("--current test direction = %s , for %d\n", sdirnarg,
+ // testdirection);
return sdirnarg;
}

@@ -76,7 +77,7 @@
* */
char *get_msgtypedesc(int msgtype, char *smsgtypearg) {
smsgtypearg = _testmsgtypesarray[msgtype];
- //printf ("--current test type = %s , for %d\n", smsgtypearg, msgtype);
+ // printf ("--current test type = %s , for %d\n", smsgtypearg, msgtype);
return smsgtypearg;
}

@@ -86,7 +87,8 @@
* @param smsgformattypearg descriptive string for message body format type
* @return
*/
-char * getmessageformattype(enum MSG_BODY_TYPE bodymsgformat, char *smsgformattypearg) {
+char * getmessageformattype(enum MSG_BODY_TYPE bodymsgformat,
+ char *smsgformattypearg) {
smsgformattypearg = _msgbodyformattype[bodymsgformat];
return smsgformattypearg;
}
=======================================
--- /trunk/src/ndtptestconstants.h Tue Sep 25 06:49:57 2012
+++ /trunk/src/ndtptestconstants.h Thu Nov 15 13:33:44 2012
@@ -4,8 +4,8 @@
*
* */

-#ifndef _JS_NDTPTESTS_H
-#define _JS_NDTPTESTS_H
+#ifndef SRC_NDTPTESTCONSTANTS_H_
+#define SRC_NDTPTESTCONSTANTS_H_

#define TEST_NONE 0
#define TEST_MID (1L << 0)
@@ -15,11 +15,17 @@
#define TEST_STATUS (1L << 4)
#define TEST_META (1L << 5)

-#define TEST_NAME_DESC_SIZE 10 /* will hold "string "middlebox", which is the longest name */
-#define TEST_STATUS_DESC_SIZE 18 /* test status < 18 chars */
-#define TEST_DIRN_DESC_SIZE 20 /* direction is either client_to_server or server_to_client */
-#define MSG_TYPE_DESC_SIZE 15 /* max size for now derived from "TEST_FINALIZE" */
-#define MSG_BODY_FMT_SIZE 10 /* max size for desc "NOT_KNOWN" */
+// will hold "string "middlebox", which is the longest name
+#define TEST_NAME_DESC_SIZE 10
+
+#define TEST_STATUS_DESC_SIZE 18 // test status < 18 chars
+
+// direction is either client_to_server or server_to_client
+#define TEST_DIRN_DESC_SIZE 20
+
+// max size for now derived from "TEST_FINALIZE"
+#define MSG_TYPE_DESC_SIZE 15
+#define MSG_BODY_FMT_SIZE 10 // max size for desc "NOT_KNOWN"

// port numbers
#define PORT "3001"
@@ -27,31 +33,31 @@
#define PORT3 "3003"
#define PORT4 "3003"

-
-// status of tests. Used mainly to log a "textual" explanation using below array
+// status of tests. Used mainly to log a "textual" explanation using below array
enum TEST_STATUS_INT {
- TEST_NOT_STARTED, TEST_STARTED, TEST_INPROGRESS, TEST_INCOMPLETE, TEST_ENDED
+ TEST_NOT_STARTED, TEST_STARTED, TEST_INPROGRESS, TEST_INCOMPLETE, TEST_ENDED
} teststatusint;

-// Test IDs
+// Test IDs
enum TEST_ID {
- NONE, MIDDLEBOX, SFW, C2S, S2C, META
+ NONE, MIDDLEBOX, SFW, C2S, S2C, META
} testid;

// Transmission direction
enum Tx_DIRECTION {
- NO_DIR, C_S, S_C
+ NO_DIR, C_S, S_C
} txdirection;

enum MSG_BODY_TYPE {
- BITFIELD, STRING, NOT_KNOWN
+ BITFIELD, STRING, NOT_KNOWN
} bodyformattype;

char *get_testnamedesc(enum TEST_ID testid, char *stestnamearg);
char *get_teststatusdesc(enum TEST_STATUS_INT teststatus, char *steststatusarg);
char *get_testdirectiondesc(enum Tx_DIRECTION testdirection,
- char *stestdirectionarg);
+ char *stestdirectionarg);
char *get_msgtypedesc(int msgtypearg, char *smsgtypearg);
-char * getmessageformattype(enum MSG_BODY_TYPE bodymsgformat, char *smsgformattypearg) ;
+char *getmessageformattype(enum MSG_BODY_TYPE bodymsgformat,
+ char *smsgformattypearg);

-#endif
+#endif // SRC_NDTPTESTCONSTANTS_H_
=======================================
--- /trunk/src/network.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/network.c Thu Nov 15 13:33:44 2012
@@ -11,8 +11,8 @@
#include <string.h>
#include <unistd.h>

-#include "network.h"
-#include "logging.h"
+#include "./network.h"
+#include "./logging.h"

/**
* Create and bind socket.
@@ -39,14 +39,14 @@
for (ai = fai; ai; ai = ai->ai_next) {
// options provided by user indicate V6
#ifdef AF_INET6
- if (options & OPT_IPV6_ONLY) { // If not an INET6 address, move on
- if(ai->ai_family != AF_INET6)
+ if (options & OPT_IPV6_ONLY) { // If not an INET6 address, move on
+ if (ai->ai_family != AF_INET6)
continue;
}
#endif

- if (options & OPT_IPV4_ONLY) { // options provided by user indicate V4
- if (ai->ai_family != AF_INET) // Not valid Inet address family. move on
+ if (options & OPT_IPV4_ONLY) { // options provided by user indicate V4
+ if (ai->ai_family != AF_INET) // Not valid Inet address family. move on
continue;
}

@@ -69,15 +69,14 @@
// the IPv6 version socket option setup
#if defined(AF_INET6) && defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
if ((ai->ai_family == AF_INET6) && (options & OPT_IPV6_ONLY) &&
- setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&on,sizeof(on)) != 0) {
+ setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) != 0) {
goto failsock;
}
#endif
// end trying to set socket option to reuse local address

// try to bind to address
- if (bind(fd, ai->ai_addr, ai->ai_addrlen) == 0) { // successful
-
+ if (bind(fd, ai->ai_addr, ai->ai_addrlen) == 0) { // successful
// set values in "addr" structure
if (!I2AddrSetSAddr(addr, ai->ai_addr, ai->ai_addrlen)
|| !I2AddrSetProtocol(addr, ai->ai_protocol)
@@ -94,14 +93,15 @@
&tmp_addr_len)) {
return -1;
}
- tmpAddr = I2AddrBySAddr(get_errhandle(),
- (struct sockaddr*) &tmp_addr, tmp_addr_len, 0, 0);
+ tmpAddr = I2AddrBySAddr(
+ get_errhandle(), (struct sockaddr*) &tmp_addr, tmp_addr_len, 0, 0);
I2AddrSetPort(addr, I2AddrPort(tmpAddr));
I2AddrFree(tmpAddr);
}
// save socket file descriptor
if (!I2AddrSetFD(addr, fd, True)) {
- log_println(1, "OpenSocket: Unable to set file descriptor in address record");
+ log_println(1, "OpenSocket: Unable to set file descriptor in address "
+ "record");
return -1;
}
// end setting values in "addr" structure
@@ -109,23 +109,23 @@
break;
}

- // Address is indicated as being in use. Display actual socket options to user and return
+ // Address is indicated as being in use. Display actual socket options to
+ // user and return
if (errno == EADDRINUSE) {
/* RAC debug statemement 10/11/06 */
onSize = sizeof(on);
getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, &onSize);
- log_println(1,
- "bind(%d) failed: Address already in use given as the reason, getsockopt() returned %d",
- fd, on);
+ log_println(1, "bind(%d) failed: Address already in use given as the "
+ "reason, getsockopt() returned %d", fd, on);
return -2;
}

- // If setting socket option failed, print error, and try to close socket file-descriptor
-failsock:
+ // If setting socket option failed, print error, and try to close socket
+ // file-descriptor
+ failsock:
/* RAC debug statemement 10/11/06 */
log_println(1, "failsock: Unable to set socket options for fd=%d", fd);
- while ((close(fd) < 0) && (errno == EINTR))
- ;
+ while ((close(fd) < 0) && (errno == EINTR)) { }
}

// set meta test's address domain family to the one used to create socket
@@ -155,7 +155,8 @@
goto error;
}

- if ((!addr) && !(addr = I2AddrByWildcard(get_errhandle(), SOCK_STREAM, serv))) {
+ if ((!addr) &&
+ !(addr = I2AddrByWildcard(get_errhandle(), SOCK_STREAM, serv))) {
log_println(1, "Unable to create I2Addr record by wildcard.");
goto error;
}
@@ -190,8 +191,8 @@

// now assign buffer sizes passed as arguments
if (buf_size > 0) {
- setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size)); // send buffer
- setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size)); // receive buffer
+ setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size));
+ setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size));
// print values set to help user verify
getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
log_print(5, "Changed buffer sizes: Send buffer set to %d(%d), ",
@@ -200,8 +201,8 @@
log_println(5, "Receive buffer set to %d(%d)", set_size, buf_size);
}

- // now listen on socket for connections, with backlog queue length = NDT_BACKLOG
- if (listen(fd, NDT_BACKLOG) < 0) { // if listen returns value <0, then error
+ // listen on socket for connections, with backlog queue length = NDT_BACKLOG
+ if (listen(fd, NDT_BACKLOG) < 0) { // if listen returns value <0, then error
log_println(1, "listen(%d,%d):%s", fd, NDT_BACKLOG, strerror(errno));
goto error;
}
@@ -253,24 +254,24 @@
}

for (ai = fai; ai; ai = ai->ai_next) {
-
// options provided by user indicate V6
#ifdef AF_INET6
- if (options & OPT_IPV6_ONLY) { // If not an INET6 address, move on
- if(ai->ai_family != AF_INET6)
+ if (options & OPT_IPV6_ONLY) { // If not an INET6 address, move on
+ if (ai->ai_family != AF_INET6)
continue;
}
#endif

// options provided by user indicate V4
if (options & OPT_IPV4_ONLY) {
- if (ai->ai_family != AF_INET) // NOT valid inet address family. Move on.
+ if (ai->ai_family != AF_INET) // NOT valid inet address family. Move on.
continue;
}

// create socket with obtained address domain, socket type and protocol
*sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (*sockfd < 0) { // socket create failed. Abandon further activities using this socket
+ if (*sockfd < 0) {
+ // socket create failed. Abandon further activities using this socket
continue;
}

@@ -285,7 +286,7 @@
for (lai = lfai; lai; lai = lai->ai_next) {
#ifdef AF_INET6
if (options & OPT_IPV6_ONLY) {
- if(lai->ai_family != AF_INET6)
+ if (lai->ai_family != AF_INET6)
continue;
}
#endif
@@ -297,7 +298,7 @@

// bind to local address
if (bind((*sockfd), lai->ai_addr, lai->ai_addrlen) == 0) {
- bindFailed = 0; // bind successful
+ bindFailed = 0; // bind successful
break; /* success */
}
}
@@ -307,7 +308,7 @@
close((*sockfd)); /* ignore this one */
continue;
}
- } // end local address
+ } // end local address

/* Set sock opt code from Marion Nakanson
<
* OHSU Advanced Computing Center
@@ -339,7 +340,6 @@

// Connect to target socket
if (connect(*sockfd, ai->ai_addr, ai->ai_addrlen) == 0) {
-
// save server address values
if (I2AddrSetSAddr(server_addr, ai->ai_addr, ai->ai_addrlen)
&& I2AddrSetSocktype(server_addr, ai->ai_socktype)
@@ -349,8 +349,7 @@
}
// unable to save
log_println(1, "I2Addr functions failed after successful connection");
- while ((close(*sockfd) < 0) && (errno == EINTR))
- ;
+ while ((close(*sockfd) < 0) && (errno == EINTR)) { }
return 1;
}
}
@@ -390,11 +389,11 @@
for (i = 0; i < 5; i++) {
// Write initial data about length and type to socket
rc = writen(ctlSocket, buff, 3);
- if (rc == 3) // write completed
+ if (rc == 3) // write completed
break;
- if (rc == 0) // nothing written yet,
+ if (rc == 0) // nothing written yet,
continue;
- if (rc == -1) // error writing to socket..cannot continue
+ if (rc == -1) // error writing to socket..cannot continue
return -1;
}

@@ -411,7 +410,7 @@
// data writing not complete, continue
if (rc == 0)
continue;
- if (rc == -1) //error writing to socket, cannot continue writing data
+ if (rc == -1) // error writing to socket, cannot continue writing data
return -2;
}
if (i == 5)
@@ -490,9 +489,9 @@
while (sent < amount) {
n = write(fd, ptr + sent, amount - sent);
if (n == -1) {
- if (errno == EINTR) // interrupted, retry writing again
+ if (errno == EINTR) // interrupted, retry writing again
continue;
- if (errno != EAGAIN) { // some genuine socket write error
+ if (errno != EAGAIN) { // some genuine socket write error
log_println(6,
"writen() Error! write(%d) failed with err='%s(%d) pic=%d'",
fd, strerror(errno), errno, getpid());
@@ -500,7 +499,7 @@
}
}
assert(n != 0);
- if (n != -1) { // success writing "n" bytes. Increment total bytes written
+ if (n != -1) { // success writing "n" bytes. Increment total bytes written
sent += n;
}
}
@@ -523,8 +522,8 @@

assert(amount >= 0);

- FD_ZERO(&rfd); // initialize with zeroes
- FD_SET(fd, &rfd); //
+ FD_ZERO(&rfd); // initialize with zeroes
+ FD_SET(fd, &rfd);
sel_tv.tv_sec = 600;
sel_tv.tv_usec = 0;

@@ -535,23 +534,24 @@
* if not, and the 3 second timer goes off, exit out and clean up.
*/
while (received < amount) {
-
// check if fd+1 socket is ready to be read
rc = select(fd + 1, &rfd, NULL, NULL, &sel_tv);
- if (rc == 0) { /* A timeout occurred, nothing to read from socket after 3 seconds */
- log_println(6, "readn() routine timeout occurred, return error signal and kill off child");
+ if (rc == 0) {
+ /* A timeout occurred, nothing to read from socket after 3 seconds */
+ log_println(6, "readn() routine timeout occurred, return error signal "
+ "and kill off child");
return received;
}
if ((rc == -1) && (errno == EINTR)) /* a signal was processed, ignore it */
continue;
n = read(fd, ptr + received, amount - received);
- if (n == -1) { // error
- if (errno == EINTR) // interrupted , try reading again
+ if (n == -1) { // error
+ if (errno == EINTR) // interrupted , try reading again
continue;
- if (errno != EAGAIN) // genuine socket read error, return
+ if (errno != EAGAIN) // genuine socket read error, return
return -errno;
}
- if (n != -1) { // if no errors reading, increment data byte count
+ if (n != -1) { // if no errors reading, increment data byte count
received += n;
}
if (n == 0)
=======================================
--- /trunk/src/network.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/network.h Thu Nov 15 13:33:44 2012
@@ -6,8 +6,8 @@
*

*/

-#ifndef _JS_NETWORK_H
-#define _JS_NETWORK_H
+#ifndef SRC_NETWORK_H_
+#define SRC_NETWORK_H_

#include <I2util/util.h>

@@ -19,7 +19,7 @@

I2Addr CreateListenSocket(I2Addr addr, char* serv, int options, int buf_size);
int CreateConnectSocket(int* sockfd, I2Addr local_addr, I2Addr server_addr,
- int option, int buf_sizes);
+ int option, int buf_sizes);
int send_msg(int ctlSocket, int type, void* msg, int len);
int recv_msg(int ctlSocket, int* type, void* msg, int* len);
int writen(int fd, void* buf, int amount);
@@ -28,4 +28,4 @@
/* web100-util.c routine used in network. */
int KillHung(void);

-#endif
+#endif // SRC_NETWORK_H_
=======================================
--- /trunk/src/protocol.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/protocol.c Thu Nov 15 13:33:44 2012
@@ -5,8 +5,8 @@
*

*/

-#include "protocol.h"
-#include "logging.h"
+#include "./protocol.h"
+#include "./logging.h"

/**
* Check if the received msg type is compatible
@@ -24,12 +24,12 @@
int len) {
// check if expected and received messages are the same
if (expected != received) {
- if (prefix) { // Add prefix to log message
+ if (prefix) { // Add prefix to log message
log_print(0, "%s: ", prefix);
}
- if (received == MSG_ERROR) { // if Error message was actually received,
+ if (received == MSG_ERROR) { // if Error message was actually received,
// then its not an unexpected message exchange
- buff[len] = 0; // terminate string
+ buff[len] = 0; // terminate string
log_println(0, "ERROR MSG: %s", buff);
} else {
// certainly an unexpected message
=======================================
--- /trunk/src/protocol.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/protocol.h Thu Nov 15 13:33:44 2012
@@ -6,11 +6,11 @@
*

*/

-#ifndef _JS_PROTOCOL_H
-#define _JS_PROTOCOL_H
+#ifndef SRC_PROTOCOL_H_
+#define SRC_PROTOCOL_H_

-//new addition after separating out ndtptests header
-#include "ndtptestconstants.h" //protocol validation
+// new addition after separating out ndtptests header
+#include "./ndtptestconstants.h" // protocol validation
// Todo could be made into enumeration
#define COMM_FAILURE 0
#define SRV_QUEUE 1
@@ -49,6 +49,6 @@
#define VIEW_DIFF 0.1

int check_msg_type(char* prefix, int expected, int received, char* buff,
- int len);
+ int len);

-#endif
+#endif // SRC_PROTOCOL_H_
=======================================
--- /trunk/src/runningtest.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/runningtest.c Thu Nov 15 13:33:44 2012
@@ -5,8 +5,8 @@
* Created on: Sep 28, 2011
* Author: kkumar
*/
-#include "ndtptestconstants.h"
-#include "runningtest.h"
+#include "./ndtptestconstants.h"
+#include "./runningtest.h"

static int currentTest = TEST_NONE;
static enum Tx_DIRECTION currentDirection = NONE;
@@ -76,7 +76,6 @@
default:
senddirnstr = get_testdirectiondesc(NO_DIR, currenttestdirn);
recvdirnstr = get_testdirectiondesc(NO_DIR, othertestdirn);
- ;
break;
}
}
@@ -134,9 +133,11 @@
* get descriptive test for status of process
* @return char* descriptive text of the process status
* */
-char *get_procstatusdesc(enum PROCESS_STATUS_INT procstatusarg, char *sprocarg) {
+char *get_procstatusdesc(enum PROCESS_STATUS_INT procstatusarg,
+ char *sprocarg) {
sprocarg = _procstatusarray[procstatusarg];
- //log_println(7,"--current process status = %s for %d\n", sprocarg, procstatusarg);
+ // log_println(7,"--current process status = %s for %d\n", sprocarg,
+ // procstatusarg);
return sprocarg;
}

@@ -148,6 +149,6 @@
* */
char *get_processtypedesc(enum PROCESS_TYPE_INT procidarg, char *snamearg) {
snamearg = _proctypesarray[procidarg];
- //log_println(7,"--current process name = %s for %d\n", snamearg, procidarg);
+ // log_println(7,"--current process name = %s for %d\n", snamearg, procidarg);
return snamearg;
}
=======================================
--- /trunk/src/runningtest.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/runningtest.h Thu Nov 15 13:33:44 2012
@@ -5,18 +5,18 @@
* Author: kkumar
*/

-#ifndef RUNNINGTEST_H_
-#define RUNNINGTEST_H_
+#ifndef SRC_RUNNINGTEST_H_
+#define SRC_RUNNINGTEST_H_

-#define PROCESS_STATUS_DESC_SIZE 17 // suffice to hold status defined below
+#define PROCESS_STATUS_DESC_SIZE 17 // suffice to hold status defined below
// indicates the status of process like the web100srv or web100clt
-//enum PROCESS_STATUS_INT { UNKNOWN, PROCESS_STARTED, PROCESS_ENDED };
+// enum PROCESS_STATUS_INT { UNKNOWN, PROCESS_STARTED, PROCESS_ENDED };
enum PROCESS_STATUS_INT {
- UNKNOWN, PROCESS_STARTED, PROCESS_ENDED
+ UNKNOWN, PROCESS_STARTED, PROCESS_ENDED
};

enum PROCESS_TYPE_INT {
- PROCESS_TYPE, CONNECT_TYPE
+ PROCESS_TYPE, CONNECT_TYPE
};

int getCurrentTest();
@@ -30,4 +30,4 @@
char *get_procstatusdesc(enum PROCESS_STATUS_INT procstatusarg, char *sprocarg);
char *get_processtypedesc(enum PROCESS_TYPE_INT procid, char *snamearg);

-#endif /* RUNNINGTEST_H_ */
+#endif // SRC_RUNNINGTEST_H_
=======================================
--- /trunk/src/strlutils.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/strlutils.c Thu Nov 15 13:33:44 2012
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
+/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */

/*
* Copyright (c) 1998 Todd C. Miller
<>
@@ -41,8 +41,7 @@
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
+ while (*s++) { }
}

return (s - src - 1); /* count does not include NUL */
@@ -56,7 +55,9 @@
* If retval >= siz, truncation occurred.
*/
size_t strlcat(dst, src, siz)
- char *dst;const char *src;size_t siz; {
+ char *dst;
+ const char *src;
+ size_t siz; {
register char *d = dst;
register const char *s = src;
register size_t n = siz;
=======================================
--- /trunk/src/strlutils.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/strlutils.h Thu Nov 15 13:33:44 2012
@@ -16,8 +16,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

-#ifndef strlcpy_H
-#define strlcpy_H
+#ifndef SRC_STRLUTILS_H_
+#define SRC_STRLUTILS_H_

#include <sys/types.h>
#include <string.h>
@@ -31,5 +31,4 @@
strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);

-#endif
-
+#endif // SRC_STRLUTILS_H_
=======================================
--- /trunk/src/test_c2s_clt.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_c2s_clt.c Thu Nov 15 13:33:44 2012
@@ -12,11 +12,11 @@
#include <string.h>
#include <unistd.h>

-#include "clt_tests.h"
-#include "logging.h"
-#include "network.h"
-#include "protocol.h"
-#include "utils.h"
+#include "./clt_tests.h"
+#include "./logging.h"
+#include "./network.h"
+#include "./protocol.h"
+#include "./utils.h"

int pkts, lth;
int sndqueue;
@@ -44,29 +44,29 @@
int test_c2s_clt(int ctlSocket, char tests, char* host, int conn_options,
int buf_size) {
/* char buff[BUFFSIZE+1]; */
- char buff[64 * KILO_BITS]; // message payload.
+ char buff[64 * KILO_BITS]; // message payload.
// note that there is a size variation between server and CLT - do not
// know why this was changed from BUFFZISE, though
// no specific problem is seen due to this

- int msgLen, msgType; // message related data
- int c2sport = atoi(PORT2); // default C2S port
- I2Addr sec_addr = NULL; // server address
- int retcode; // return code
- int one=1; // socket option store
- int i, k; // temporary iterator
- int outSocket; // socket descriptor for the outgoing
connection
- double t, stop_time;// test-time indicators
+ int msgLen, msgType; // message related data
+ int c2sport = atoi(PORT2); // default C2S port
+ I2Addr sec_addr = NULL; // server address
+ int retcode; // return code
+ int one = 1; // socket option store
+ int i, k; // temporary iterator
+ int outSocket; // socket descriptor for the outgoing connection
+ double t, stop_time; // test-time indicators
// variables used for protocol validation logs
enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
enum TEST_ID testids = C2S;


- if (tests & TEST_C2S) { // C2S test has to be performed
+ if (tests & TEST_C2S) { // C2S test has to be performed
struct sigaction new, old;
log_println(1, " <-- C2S throughput test -->");
setCurrentTest(TEST_C2S);
- //protocol logs
+ // protocol logs
teststatuses = TEST_STARTED;
protolog_status(getpid(), testids, teststatuses, ctlSocket);

@@ -79,7 +79,8 @@
log_println(0, "Protocol error - missed prepare message!");
return 1;
}
- if (check_msg_type("C2S throughput test", TEST_PREPARE, msgType, buff, msgLen)) {
+ if (check_msg_type("C2S throughput test", TEST_PREPARE, msgType, buff,
+ msgLen)) {
return 2;
}
if (msgLen <= 0) {
@@ -101,10 +102,11 @@
log_println(0, "Unable to resolve server address: %s", strerror(errno));
return -3;
}
- I2AddrSetPort(sec_addr, c2sport); //set port value
+ I2AddrSetPort(sec_addr, c2sport); // set port value

// connect to server and set socket options
- if ((retcode = CreateConnectSocket(&outSocket, NULL, sec_addr, conn_options, buf_size))) {
+ if ((retcode = CreateConnectSocket(&outSocket, NULL, sec_addr, conn_options,
+ buf_size))) {
log_println(0, "Connect() for client to server failed", strerror(errno));
return -11;
}
@@ -118,7 +120,8 @@
log_println(0, "Protocol error - missed start message!");
return 1;
}
- if (check_msg_type("C2S throughput test", TEST_START, msgType, buff, msgLen)) {
+ if (check_msg_type("C2S throughput test", TEST_START, msgType, buff,
+ msgLen)) {
return 2;
}

@@ -129,10 +132,10 @@
// ....Fill buffer upto NDTConstants.PREDEFNED_BUFFER_SIZE packets
pkts = 0;
k = 0;
- for (i=0; i<(64*KILO_BITS); i++) { // again buffer sizes differ. Since the actual
- // transmitted byte count is timed, it does'nt appear that it is
- // causing specific problems.
- while (!isprint(k&0x7f))
+ for (i = 0; i < (64*KILO_BITS); i++) { // again buffer sizes differ.
+ // Since the actual transmitted byte count is timed, it doesn't appear
+ // that it is causing specific problems.
+ while (!isprint(k & 0x7f))
k++;
buff[i] = (k++ % 0x7f);
}
@@ -151,7 +154,7 @@
pkts++;
}while (secs() < stop_time);
sigaction(SIGPIPE, &old, NULL);
- sndqueue = sndq_len(outSocket); //get send-queue length
+ sndqueue = sndq_len(outSocket); // get send-queue length

// get actual duration for which data was sent to the server
t = secs() - t;
@@ -159,7 +162,8 @@

// Calculate C2S throughput in kbps
spdout = ((BITS_8_FLOAT * pkts * lth) / KILO) / t;
- //log_println(6," ---C->S CLT speed=%0.0f, pkts= %d, lth=%d, time=%d", spdout, pkts, lth, t);
+ // log_println(6," ---C->S CLT speed=%0.0f, pkts= %d, lth=%d, time=%d",
+ // spdout, pkts, lth, t);


// The client has stopped streaming data, and the server is now
@@ -171,11 +175,12 @@
log_println(0, "Protocol error - missed text message!");
return 1;
}
- if (check_msg_type("C2S throughput test", TEST_MSG, msgType, buff, msgLen)) {
+ if (check_msg_type("C2S throughput test", TEST_MSG, msgType, buff,
+ msgLen)) {
// other message types at this juncture indicate error
return 2;
}
- if (msgLen <= 0) { // message payload size cannot be negative!
Error.
+ if (msgLen <= 0) { // message payload size cannot be negative! Error.
log_println(0, "Improper message");
return 3;
}
@@ -197,13 +202,14 @@
log_println(0, "Protocol error - missed finalize message!");
return 1;
}
- if (check_msg_type("C2S throughput test", TEST_FINALIZE, msgType, buff, msgLen)) {
+ if (check_msg_type("C2S throughput test", TEST_FINALIZE, msgType, buff,
+ msgLen)) {
return 2;
}
log_println(1, " <------------------------->");
- //log protocol validation logs
+ // log protocol validation logs
teststatuses = TEST_ENDED;
- protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
setCurrentTest(TEST_NONE);
}
return 0;
=======================================
--- /trunk/src/test_c2s_srv.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_c2s_srv.c Thu Nov 15 13:33:44 2012
@@ -7,21 +7,22 @@
* Author:

*/

-#include <syslog.h>
+#include <syslog.h>
#include <pthread.h>
#include <sys/times.h>
-#include "tests_srv.h"
-#include "strlutils.h"
-#include "ndtptestconstants.h"
-#include "utils.h"
-#include "testoptions.h"
-#include "runningtest.h"
-#include "logging.h"
-#include "protocol.h"
-#include "network.h"
-#include "mrange.h"
+#include "./tests_srv.h"
+#include "./strlutils.h"
+#include "./ndtptestconstants.h"
+#include "./utils.h"
+#include "./testoptions.h"
+#include "./runningtest.h"
+#include "./logging.h"
+#include "./protocol.h"
+#include "./network.h"
+#include "./mrange.h"

-int mon_pipe1[2]; // used to store file descriptors of pipes created for ndttrace for C2S tests
+// used to store file descriptors of pipes created for ndttrace for C2S tests
+int mon_pipe1[2];


/**
@@ -64,24 +65,24 @@
int conn_options, double* c2sspd, int set_buff, int window,
int autotune, char* device, Options* options, int record_reverse,
int count_vars, char spds[4][256], int* spd_index) {
- int recvsfd; // receiver socket file descriptor
- pid_t c2s_childpid = 0; // child process pids
- int msgretvalue, tmpbytecount; // used during the "read"/"write" process
- int i, j; // used as loop iterators
+ int recvsfd; // receiver socket file descriptor
+ pid_t c2s_childpid = 0; // child process pids
+ int msgretvalue, tmpbytecount; // used during the "read"/"write" process
+ int i, j; // used as loop iterators

struct sockaddr_storage cli_addr;

socklen_t clilen;
- char tmpstr[256]; // string array used for all sorts of temp storage purposes
- double tmptime; // time indicator
- double bytes_read = 0; // number of bytes read during the throughput tests
- struct timeval sel_tv; // time
- fd_set rfd; // receive file descriptor
- char buff[BUFFSIZE + 1]; // message "payload" buffer
- PortPair pair; // socket ports
- I2Addr c2ssrv_addr = NULL; // c2s test's server address
- //I2Addr src_addr=NULL; // c2s test source address
- char listenc2sport[10]; // listening port
+ char tmpstr[256]; // string array used for all sorts of temp storage purposes
+ double tmptime; // time indicator
+ double bytes_read = 0; // number of bytes read during the throughput tests
+ struct timeval sel_tv; // time
+ fd_set rfd; // receive file descriptor
+ char buff[BUFFSIZE + 1]; // message "payload" buffer
+ PortPair pair; // socket ports
+ I2Addr c2ssrv_addr = NULL; // c2s test's server address
+ // I2Addr src_addr=NULL; // c2s test source address
+ char listenc2sport[10]; // listening port
pthread_t workerThreadId;

// web_100 related variables
@@ -108,30 +109,32 @@
testOptions->child0);
strlcpy(listenc2sport, PORT2, sizeof(listenc2sport));

- //log protocol validation logs
+ // log protocol validation logs
teststatuses = TEST_STARTED;
protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);

// Determine port to be used. Compute based on options set earlier
// by reading from config file, or use default port2 (3002).
if (testOptions->c2ssockport) {
- snprintf(listenc2sport, sizeof(listenc2sport), "%d", testOptions->c2ssockport);
+ snprintf(listenc2sport, sizeof(listenc2sport), "%d",
+ testOptions->c2ssockport);
} else if (testOptions->mainport) {
- snprintf(listenc2sport, sizeof(listenc2sport), "%d", testOptions->mainport + 1);
+ snprintf(listenc2sport, sizeof(listenc2sport), "%d",
+ testOptions->mainport + 1);
}

if (testOptions->multiple) {
strlcpy(listenc2sport, "0", sizeof(listenc2sport));
}

- // attempt to bind to a new port and obtain address structure with details of listening port
+ // attempt to bind to a new port and obtain address structure with details
+ // of listening port
while (c2ssrv_addr == NULL) {
c2ssrv_addr = CreateListenSocket(
NULL,
(testOptions->multiple ?
mrange_next(listenc2sport, sizeof(listenc2sport)) : listenc2sport),
- conn_options, 0)
- ;
+ conn_options, 0);
if (strcmp(listenc2sport, "0") == 0) {
log_println(0, "WARNING: ephemeral port number was bound");
break;
@@ -153,7 +156,8 @@
return -1;
}

- // get socket FD and the ephemeral port number that client will connect to run tests
+ // get socket FD and the ephemeral port number that client will connect to
+ // run tests
testOptions->c2ssockfd = I2AddrFD(c2ssrv_addr);
testOptions->c2ssockport = I2AddrPort(c2ssrv_addr);
log_println(1, " -- port: %d", testOptions->c2ssockport);
@@ -171,9 +175,12 @@
testOptions->child0);
snprintf(buff, sizeof(buff), "%d", testOptions->c2ssockport);

- // send TEST_PREPARE message with ephemeral port detail, indicating start of tests
- if ((msgretvalue = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff))) < 0)
+ // send TEST_PREPARE message with ephemeral port detail, indicating start
+ // of tests
+ if ((msgretvalue = send_msg(ctlsockfd, TEST_PREPARE, buff,
+ strlen(buff))) < 0) {
return msgretvalue;
+ }

// Wait on listening socket and read data once ready.
// Retry 5 times, waiting for activity on the socket
@@ -188,18 +195,19 @@
for (j = 0; j < RETRY_COUNT; j++) {
msgretvalue = select((testOptions->c2ssockfd) + 1, &rfd, NULL, NULL,
&sel_tv);
- if ((msgretvalue == -1) && (errno == EINTR)) // socket interrupted. continue waiting for activity on socket
+ // socket interrupted. continue waiting for activity on socket
+ if ((msgretvalue == -1) && (errno == EINTR))
continue;
- if (msgretvalue == 0) // timeout
+ if (msgretvalue == 0) // timeout
return -SOCKET_CONNECT_TIMEOUT;
- if (msgretvalue < 0) // other socket errors. exit
+ if (msgretvalue < 0) // other socket errors. exit
return -errno;
- if (j == (RETRY_COUNT - 1)) // retry exceeded. exit
+ if (j == (RETRY_COUNT - 1)) // retry exceeded. exit
return -RETRY_EXCEEDED_WAITING_CONNECT;
-recfd:
+ recfd:

- // If a valid connection request is received, client has connected. Proceed.
- // Note the new socket fd - recvsfd- used in the throughput test
+ // If a valid connection request is received, client has connected.
+ // Proceed. Note the new socket fd - recvsfd- used in the throughput test
recvsfd = accept(testOptions->c2ssockfd,
(struct sockaddr *) &cli_addr, &clilen);
if (recvsfd > 0) {
@@ -213,7 +221,8 @@
procstatusenum, recvsfd);
break;
}
- if ((recvsfd == -1) && (errno == EINTR)) { // socket interrupted, wait some more
+ // socket interrupted, wait some more
+ if ((recvsfd == -1) && (errno == EINTR)) {
log_println(
6,
"Child %d interrupted while waiting for accept() to complete",
@@ -224,10 +233,10 @@
6,
"------- C2S connection setup for %d returned because (%d)",
testOptions->child0, errno);
- if (recvsfd < 0) { // other socket errors, quit
+ if (recvsfd < 0) { // other socket errors, quit
return -errno;
}
- if (j == (RETRY_COUNT - 1)) { // retry exceeded, quit
+ if (j == (RETRY_COUNT - 1)) { // retry exceeded, quit
log_println(
6,
"c2s child %d, uable to open connection, return from test",
@@ -246,7 +255,8 @@
// Get web100 connection. Used to collect web100 variable statistics
conn = web100_connection_from_socket(agent, recvsfd);

- // set up packet tracing. Collected data is used for bottleneck link calculations
+ // set up packet tracing. Collected data is used for bottleneck link
+ // calculations
if (getuid() == 0) {
/*
pipe(mon_pipe1);
@@ -267,7 +277,8 @@
5,
"C2S test Child %d thinks pipe() returned fd0=%d, fd1=%d",
testOptions->child0, mon_pipe1[0], mon_pipe1[1]);
- log_println(2, "C2S test calling init_pkttrace() with pd=%p", &cli_addr);
+ log_println(2, "C2S test calling init_pkttrace() with pd=%p",
+ &cli_addr);
init_pkttrace(src_addr, (struct sockaddr *) &cli_addr, clilen,
mon_pipe1, device, &pair, "c2s", options->compress);
exit(0); /* Packet trace finished, terminate gracefully */
@@ -283,8 +294,7 @@
}
if (strlen(tmpstr) > 5)
memcpy(meta.c2s_ndttrace, tmpstr, strlen(tmpstr));
- //name of nettrace file passed back from pcap child
-
+ // name of nettrace file passed back from pcap child
log_println(3, "--tracefile after packet_trace %s",
meta.c2s_ndttrace);
}
@@ -295,22 +305,24 @@
// experimental code, delete when finished
setCwndlimit(conn, group, agent, options);

- // Create C->S snaplog directories, and perform some initialization based on options
-
+ // Create C->S snaplog directories, and perform some initialization based on
+ // options
create_client_logdir((struct sockaddr *) &cli_addr, clilen,
- options->c2s_logname, sizeof(options->c2s_logname), namesuffix,
+ options->c2s_logname, sizeof(options->c2s_logname),
+ namesuffix,
sizeof(namesuffix));
sleep(2);

// send empty TEST_START indicating start of the test
send_msg(ctlsockfd, TEST_START, "", 0);
- /* alarm(30); *//* reset alarm() again, this 10 sec test should finish before this signal
- * is generated. */
+ /* alarm(30); */ // reset alarm() again, this 10 sec test should finish
+ // before this signal is generated.

// If snaplog recording is enabled, update meta file to indicate the same
- // and proceed to get snapshot and log it.
- // This block is needed here since the meta file stores names without the full directory
- // but fopen needs full path. Else, it could have gone into the "start_snap_worker" method
+ // and proceed to get snapshot and log it.
+ // This block is needed here since the meta file stores names without the
+ // full directory but fopen needs full path. Else, it could have gone into
+ // the "start_snap_worker" method
if (options->snaplog) {
memcpy(meta.c2s_snaplog, namesuffix, strlen(namesuffix));
/*start_snap_worker(&snapArgs, agent, options->snaplog, &workerLoop,
@@ -318,10 +330,10 @@
conn, group); */
}
start_snap_worker(&snapArgs, agent, NULL, options->snaplog, &workerThreadId,
- meta.c2s_snaplog, options->c2s_logname, conn,
group);
+ meta.c2s_snaplog, options->c2s_logname, conn, group);
// Wait on listening socket and read data once ready.
tmptime = secs();
- sel_tv.tv_sec = 11; // time out after 11 seconds
+ sel_tv.tv_sec = 11; // time out after 11 seconds
sel_tv.tv_usec = 0;
FD_ZERO(&rfd);
FD_SET(recvsfd, &rfd);
@@ -331,23 +343,26 @@
// socket interrupted. Continue waiting for activity on socket
continue;
}
- if (msgretvalue > 0) { // read from socket
+ if (msgretvalue > 0) { // read from socket
tmpbytecount = read(recvsfd, buff, sizeof(buff));
- if ((tmpbytecount == -1) && (errno == EINTR)) // read interrupted,continue waiting
+ // read interrupted, continue waiting
+ if ((tmpbytecount == -1) && (errno == EINTR))
continue;
- if (tmpbytecount == 0) // all data has been read
+ if (tmpbytecount == 0) // all data has been read
break;
- bytes_read += tmpbytecount; // data byte count has to be increased
+ bytes_read += tmpbytecount; // data byte count has to be increased
continue;
}
break;
}

tmptime = secs() - tmptime;
- // throughput in kilo bits per sec = (transmitted_byte_count * 8) / (time_duration)*(1000)
+ // throughput in kilo bits per sec =
+ // (transmitted_byte_count * 8) / (time_duration)*(1000)
*c2sspd = (8.e-3 * bytes_read) / tmptime;

- // c->s throuput value calculated and assigned ! Release resources, conclude snap writing.
+ // c->s throuput value calculated and assigned ! Release resources, conclude
+ // snap writing.
stop_snap_worker(&workerThreadId, options->snaplog, &snapArgs);

// send the server calculated value of C->S throughput as result to client
@@ -357,7 +372,8 @@
snprintf(buff, sizeof(buff), "%0.0f", *c2sspd);
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));

- // get receiver side Web100 stats and write them to the log file. close sockets
+ // get receiver side Web100 stats and write them to the log file. close
+ // sockets
if (record_reverse == 1)
web100_get_data_recv(recvsfd, agent, conn, count_vars);

@@ -385,9 +401,8 @@
continue;
if (((msgretvalue == -1) && (errno != EINTR))
|| (msgretvalue == 0)) {
- log_println(4,
- "Failed to read pkt-pair data from C2S flow, retcode=%d, reason=%d",
- msgretvalue, errno);
+ log_println(4, "Failed to read pkt-pair data from C2S flow, "
+ "retcode=%d, reason=%d", msgretvalue, errno);
snprintf(spds[(*spd_index)++],
sizeof(spds[*spd_index]),
" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
@@ -401,12 +416,13 @@
* RAC 2/8/10
*/
if (msgretvalue > 0) {
- if ((msgretvalue = read(mon_pipe1[0], spds[*spd_index], sizeof(spds[*spd_index])))
- < 0)
+ if ((msgretvalue = read(mon_pipe1[0], spds[*spd_index],
+ sizeof(spds[*spd_index]))) < 0) {
snprintf(
spds[*spd_index],
sizeof(spds[*spd_index]),
" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+ }
log_println(1, "%d bytes read '%s' from C2S monitor pipe",
msgretvalue, spds[*spd_index]);
(*spd_index)++;
@@ -416,7 +432,6 @@
sel_tv.tv_usec = 100000;
continue;
}
-
}
}

@@ -430,13 +445,12 @@

// log end of C->S test
log_println(1, " <----------- %d -------------->", testOptions->child0);
- //protocol logs
+ // protocol logs
teststatuses = TEST_ENDED;
protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);

- //set current test status and free address
+ // set current test status and free address
setCurrentTest(TEST_NONE);
-
}

return 0;
=======================================
--- /trunk/src/test_meta.h Mon Oct 29 10:56:28 2012
+++ /trunk/src/test_meta.h Thu Nov 15 13:33:44 2012
@@ -5,8 +5,8 @@
*

*/

-#ifndef _JS_TEST_META_H
-#define _JS_TEST_META_H
+#ifndef SRC_TEST_META_H_
+#define SRC_TEST_META_H_

#define META_CLIENT_OS "client.os.name"
#define META_BROWSER_OS "client.browser.name"
@@ -18,4 +18,4 @@

int test_meta_clt(int ctlSocket, char tests, char* host, int conn_options);

-#endif
+#endif // SRC_TEST_META_H_
=======================================
--- /trunk/src/test_meta_clt.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_meta_clt.c Thu Nov 15 13:33:44 2012
@@ -14,11 +14,11 @@
#include <string.h>
#include <unistd.h>

-#include "test_meta.h"
-#include "logging.h"
-#include "network.h"
-#include "protocol.h"
-#include "utils.h"
+#include "./test_meta.h"
+#include "./logging.h"
+#include "./network.h"
+#include "./protocol.h"
+#include "./utils.h"

int pkts, lth;
int sndqueue;
@@ -42,14 +42,14 @@
int msgLen, msgType;
FILE * fp;

- //Protocol validation variables
+ // Protocol validation variables
enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
enum TEST_ID testids = META;

- if (tests & TEST_META) { // perform META tests
+ if (tests & TEST_META) { // perform META tests
log_println(1, " <-- META test -->");
setCurrentTest(TEST_META);
- //protocol logs
+ // protocol logs
teststatuses = TEST_STARTED;
protolog_status(getpid(), testids, teststatuses, ctlSocket);
msgLen = sizeof(buff);
@@ -75,9 +75,9 @@
}

// As a response to the Server's TEST_START message, client responds
- // ..with TEST_MSG. These messages may be used, as below, to send configuration data
- // ...name-value pairs. Note that there are length constraints to keys- values: 64/256
- // ....characters respectively
+ // with TEST_MSG. These messages may be used, as below, to send
+ // configuration data name-value pairs. Note that there are length
+ // constraints to keys- values: 64/256 characters respectively

printf("sending meta information to server . . . . . ");
fflush(stdout);
@@ -104,7 +104,8 @@
} else {
fscanf(fp, "%s", tmpBuff);
fclose(fp);
- snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_KERNEL_VERSION, tmpBuff);
+ snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_KERNEL_VERSION,
+ tmpBuff);
send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
}

@@ -131,7 +132,7 @@
log_println(1, " <------------------------->");
// log protocol validation logs
teststatuses = TEST_ENDED;
- protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
setCurrentTest(TEST_NONE);
}
return 0;
=======================================
--- /trunk/src/test_meta_srv.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_meta_srv.c Thu Nov 15 13:33:44 2012
@@ -12,12 +12,12 @@
#include <string.h>
#include <unistd.h>

-#include "test_meta.h"
-#include "logging.h"
-#include "network.h"
-#include "protocol.h"
-#include "utils.h"
-#include "testoptions.h"
+#include "./test_meta.h"
+#include "./logging.h"
+#include "./network.h"
+#include "./protocol.h"
+#include "./utils.h"
+#include "./testoptions.h"

/**
* Performs the META test.
@@ -56,11 +56,11 @@

// log protocol validation details
teststatuses = TEST_STARTED;
- protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
+ protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);

// first message exchanged is am empty TEST_PREPARE message
j = send_msg(ctlsockfd, TEST_PREPARE, "", 0);
- if (j == -1 || j == -2) { // Cannot write message headers/data
+ if (j == -1 || j == -2) { // Cannot write message headers/data
log_println(6, "META Error!, Test start message not sent!");
return j;
}
@@ -77,21 +77,24 @@
if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
// message reading error
log_println(0, "Protocol error!");
- snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+ snprintf(buff, sizeof(buff),
+ "Server (META test): Invalid meta data received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return 1;
}
if (check_msg_type("META test", TEST_MSG, msgType, buff, msgLen)) {
// expected a TEST_MSG only
log_println(0, "Fault, unexpected message received!");
- snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+ snprintf(buff, sizeof(buff),
+ "Server (META test): Invalid meta data received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return 2;
}
if (msgLen < 0) {
// meta data should be present at this stage
log_println(0, "Improper message");
- snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+ snprintf(buff, sizeof(buff),
+ "Server (META test): Invalid meta data received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return 3;
}
@@ -104,24 +107,27 @@

buff[msgLen] = 0;
value = index(buff, ':');
- if (value == NULL) { // key-value separates by ":"
+ if (value == NULL) { // key-value separates by ":"
log_println(0, "Improper message");
- snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+ snprintf(buff, sizeof(buff), "Server (META test): "
+ "Invalid meta data received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return 4;
}
*value = 0;
value++;

- // get the recommended set of data expected: client os name , client browser name,
- //why not if else-if for the whole set? TODO
+ // get the recommended set of data expected: client os name,
+ // client browser name,
+ // why not if else-if for the whole set? TODO
if (strcmp(META_CLIENT_OS, buff) == 0) {
snprintf(meta.client_os, sizeof(meta.client_os), "%s", value);
/*continue;*/
}

if (strcmp(META_CLIENT_APPLICATION, buff) == 0) {
- snprintf(meta.client_application, sizeof(meta.client_application), "%s", value);
+ snprintf(meta.client_application, sizeof(meta.client_application),
+ "%s", value);
/*continue;*/
}

@@ -144,18 +150,18 @@
snprintf(new_entry->key, sizeof(new_entry->key), "%s", buff);
snprintf(new_entry->value, sizeof(new_entry->value), "%s", value);
}
- new_entry->next = NULL; // ensure meta list ends here
+ new_entry->next = NULL; // ensure meta list ends here

// Finalize test by sending appropriate message, and setting status
if (send_msg(ctlsockfd, TEST_FINALIZE, "", 0) < 0) {
log_println(6, "META test - failed to send finalize message");
}

- //log end of test and conclude
+ // log end of test and conclude
log_println(1, " <-------------------------->");

- teststatuses = TEST_ENDED; // protocol log section
- protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
+ teststatuses = TEST_ENDED; // protocol log section
+ protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);

setCurrentTest(TEST_NONE);
}
=======================================
--- /trunk/src/test_mid_clt.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_mid_clt.c Thu Nov 15 13:33:44 2012
@@ -10,12 +10,12 @@
#include <unistd.h>
#include <string.h>

-#include "clt_tests.h"
-#include "logging.h"
-#include "network.h"
-#include "protocol.h"
-#include "utils.h"
-#include "strlutils.h"
+#include "./clt_tests.h"
+#include "./logging.h"
+#include "./network.h"
+#include "./protocol.h"
+#include "./utils.h"
+#include "./strlutils.h"

/**
* Perform the client part of the middleBox testing. The middlebox test
@@ -61,10 +61,10 @@
enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
enum TEST_ID testids = MIDDLEBOX;

- if (tests & TEST_MID) { // middlebox test has to be performed
+ if (tests & TEST_MID) { // middlebox test has to be performed
log_println(1, " <-- Middlebox test -->");
setCurrentTest(TEST_MID);
- //protocol logs
+ // protocol logs
teststatuses = TEST_STARTED;
protolog_status(getpid(), testids, teststatuses, ctlSocket);

@@ -81,14 +81,16 @@
return 2;
}

- // The server is expected to send a message with a valid payload that contains
- // .. the port number that server wants client to bind to for this test
+ // The server is expected to send a message with a valid payload that
+ // contains the port number that server wants client to bind to for this
+ // test
if (msgLen <= 0) {
log_println(0, "Improper message");
return 3;
}
buff[msgLen] = 0;
- if (check_int(buff, &midport)) { // obtained message does not contain integer port#
+ if (check_int(buff, &midport)) { // obtained message does not contain
+ // integer port#
log_println(0, "Invalid port number");
return 4;
}
@@ -101,7 +103,8 @@
}
I2AddrSetPort(sec_addr, midport);

- if (get_debuglvl() > 4) { //debug to check if correct port was set in addr struct
+ // debug to check if correct port was set in addr struct
+ if (get_debuglvl() > 4) {
char tmpbuff[200];
size_t tmpBufLen = 199;
memset(tmpbuff, 0, 200);
@@ -110,19 +113,21 @@
}

// connect to server using port obtained above
- if ((retcode = CreateConnectSocket(&in2Socket, NULL, sec_addr, conn_options, buf_size))) {
+ if ((retcode = CreateConnectSocket(&in2Socket, NULL, sec_addr,
+ conn_options, buf_size))) {
log_println(0, "Connect() for middlebox failed: %s", strerror(errno));
return -10;
}

- // start reading throughput test data from server using the connection created above
+ // start reading throughput test data from server using the connection
+ // created above
printf("Checking for Middleboxes . . . . . . . . . . . . . . . . . . ");
fflush(stdout);
testresult_str[0] = '\0';
bytes = 0;
t = secs() + 5.0; // set timer for 5 seconds, and read for 5 seconds
- sel_tv.tv_sec = 6; // Time out the socket after 6.5 seconds
- sel_tv.tv_usec = 5; // 500?
+ sel_tv.tv_sec = 6; // Time out the socket after 6.5 seconds
+ sel_tv.tv_usec = 5; // 500?
FD_ZERO(&rfd);
FD_SET(in2Socket, &rfd);
for (;;) {
@@ -151,14 +156,16 @@
// calculate throughput in Kbps
spdin = ((BITS_8_FLOAT * bytes) / KILO) / t;

- // Test is complete. Now, get results from server (includes CurrentMSS, WinScaleSent, WinScaleRcvd..).
+ // Test is complete. Now, get results from server (includes CurrentMSS,
+ // WinScaleSent, WinScaleRcvd..).
// The results are sent from server in the form of a TEST_MSG object
msgLen = sizeof(buff);
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed text message!");
return 1;
}
- if (check_msg_type(MIDBOX_TEST_LOG " results", TEST_MSG, msgType, buff, msgLen)) {
+ if (check_msg_type(MIDBOX_TEST_LOG " results", TEST_MSG, msgType, buff,
+ msgLen)) {
return 2;
}

@@ -188,7 +195,7 @@
log_println(1, " <-------------------->");
// log protocol test ending
teststatuses = TEST_ENDED;
- protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
setCurrentTest(TEST_NONE);
}
return 0;
=======================================
--- /trunk/src/test_mid_srv.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_mid_srv.c Thu Nov 15 13:33:44 2012
@@ -14,16 +14,16 @@
#include <sys/times.h>
#include <assert.h>

-#include "tests_srv.h"
-#include "strlutils.h"
-#include "ndtptestconstants.h"
-#include "utils.h"
-#include "testoptions.h"
-#include "runningtest.h"
-#include "logging.h"
-#include "protocol.h"
-#include "network.h"
-#include "mrange.h"
+#include "./tests_srv.h"
+#include "./strlutils.h"
+#include "./ndtptestconstants.h"
+#include "./utils.h"
+#include "./testoptions.h"
+#include "./runningtest.h"
+#include "./logging.h"
+#include "./protocol.h"
+#include "./network.h"
+#include "./mrange.h"

/**
* Perform the Middlebox test.
@@ -54,21 +54,22 @@
int maxseg = ETHERNET_MTU_SIZE;
/* int maxseg=1456, largewin=16*1024*1024; */
/* int seg_size, win_size; */
- int midsfd; // socket file-descriptor, used in mid-box throughput test from S->C
- int j; // temporary integer store
- int msgretvalue; // return value from socket read/writes
+ int midsfd; // socket file-descriptor, used in mid-box throughput test from
+ // S->C
+ int j; // temporary integer store
+ int msgretvalue; // return value from socket read/writes
struct sockaddr_storage cli_addr;
/* socklen_t optlen, clilen; */
socklen_t clilen;
- char buff[BUFFSIZE + 1]; // buf used for message payload
- I2Addr midsrv_addr = NULL; // server address
- char listenmidport[10]; // listener socket for middlebox tests
+ char buff[BUFFSIZE + 1]; // buf used for message payload
+ I2Addr midsrv_addr = NULL; // server address
+ char listenmidport[10]; // listener socket for middlebox tests
int msgType;
int msgLen;
web100_connection* conn;
- char tmpstr[256]; // temporary string storage
- struct timeval sel_tv; // time
- fd_set rfd; // receiver file descriptor
+ char tmpstr[256]; // temporary string storage
+ struct timeval sel_tv; // time
+ fd_set rfd; // receiver file descriptor

// variables used for protocol validation logging
enum TEST_ID thistestId = NONE;
@@ -81,8 +82,7 @@
assert(options);
assert(s2c_throughput_mid);

- if (options->midopt) { // middlebox tests need to be run.
-
+ if (options->midopt) { // middlebox tests need to be run.
// Start with readying up (initializing)
setCurrentTest(TEST_MID);
log_println(1, " <-- %d - Middlebox test -->", options->child0);
@@ -94,17 +94,19 @@

// determine port to be used. Compute based on options set earlier
// by reading from config file, or use default port3 (3003),
- //strcpy(listenmidport, PORT3);
+ // strcpy(listenmidport, PORT3);
strlcpy(listenmidport, PORT3, sizeof(listenmidport));

if (options->midsockport) {
- snprintf(listenmidport, sizeof(listenmidport), "%d", options->midsockport);
+ snprintf(listenmidport, sizeof(listenmidport), "%d",
+ options->midsockport);
} else if (options->mainport) {
- snprintf(listenmidport, sizeof(listenmidport), "%d", options->mainport + 2);
+ snprintf(listenmidport, sizeof(listenmidport), "%d",
+ options->mainport + 2);
}

if (options->multiple) {
- //strcpy(listenmidport, "0");
+ // strcpy(listenmidport, "0");
strlcpy(listenmidport, "0", sizeof(listenmidport));
}

@@ -117,15 +119,16 @@
*/

while (midsrv_addr == NULL) {
-
- // attempt to bind to a new port and obtain address structure with details of listening port
+ // attempt to bind to a new port and obtain address structure with
+ // details of listening port

midsrv_addr =
CreateListenSocket(
NULL,
- (options->multiple ?
- mrange_next(listenmidport, sizeof(listenmidport)) : listenmidport), conn_options, 0)
- ;
+ options->multiple ?
+ mrange_next(listenmidport, sizeof(listenmidport)) :
+ listenmidport,
+ conn_options, 0);
if (midsrv_addr == NULL) {
/*
log_println(5, " Calling KillHung() because midsrv_address failed to bind");
@@ -137,7 +140,8 @@
log_println(0, "WARNING: ephemeral port number was bound");
break;
}
- if (options->multiple == 0) { // simultaneous tests from multiple clients not allowed, quit now
+ if (options->multiple == 0) {
+ // simultaneous tests from multiple clients not allowed, quit now
break;
}
}
@@ -186,17 +190,19 @@
for (j = 0; j < RETRY_COUNT; j++) {
msgretvalue = select((options->midsockfd) + 1, &rfd, NULL, NULL,
&sel_tv);
- if ((msgretvalue == -1) && (errno == EINTR)) // socket interruption. continue waiting for activity on socket
+ // socket interruption. continue waiting for activity on socket
+ if ((msgretvalue == -1) && (errno == EINTR))
continue;
- if (msgretvalue == 0) // timeout
+ if (msgretvalue == 0) // timeout
return SOCKET_CONNECT_TIMEOUT;
- if (msgretvalue < 0) // other socket errors, exit
+ if (msgretvalue < 0) // other socket errors, exit
return -errno;
- if (j == 4) // retry exceeded. Quit
+ if (j == 4) // retry exceeded. Quit
return RETRY_EXCEEDED_WAITING_CONNECT;

-midfd:
- // if a valid connection request is received, client has connected. Proceed.
+ midfd:
+ // if a valid connection request is received, client has connected.
+ // Proceed.
// Note the new socket fd used in the throughput test is this (midsfd)
if ((midsfd = accept(options->midsockfd,
(struct sockaddr *) &cli_addr, &clilen)) > 0) {
@@ -207,8 +213,8 @@
procstatusenum, midsfd);
break;
}
-
- if ((midsfd == -1) && (errno == EINTR)) // socket interrupted, wait some more
+ // socket interrupted, wait some more
+ if ((midsfd == -1) && (errno == EINTR))
goto midfd;

snprintf(tmpstr,
@@ -248,7 +254,8 @@
// Expect client to send throughput as calculated at its end

msgLen = sizeof(buff);
- if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) { // message reception error
+ // message reception error
+ if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error!");
snprintf(
buff,
@@ -257,7 +264,8 @@
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return 1;
}
- if (check_msg_type("Middlebox test", TEST_MSG, msgType, buff, msgLen)) { // only TEST_MSG type valid
+ if (check_msg_type("Middlebox test", TEST_MSG, msgType, buff,
+ msgLen)) { // only TEST_MSG type valid
snprintf(
buff,
sizeof(buff),
@@ -265,7 +273,7 @@
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return 2;
}
- if (msgLen <= 0) { // received message's length has to be a valid one
+ if (msgLen <= 0) { // received message's length has to be a valid one
log_println(0, "Improper message");
snprintf(
buff,
@@ -281,7 +289,8 @@
log_println(4, "CWND limited throughput = %0.0f kbps (%s)",
*s2c_throughput_mid, buff);

- // finalize the midbox test ; disabling socket used for throughput test and closing out both sockets
+ // finalize the midbox test ; disabling socket used for throughput test and
+ // closing out both sockets
shutdown(midsfd, SHUT_WR);
close(midsfd);
close(options->midsockfd);
@@ -290,8 +299,8 @@

// log end of test into protocol doc, just to delimit.
teststatusnow = TEST_ENDED;
- //protolog_status(1, options->child0, thistestId, teststatusnow);
- protolog_status(options->child0, thistestId, teststatusnow,ctlsockfd);
+ // protolog_status(1, options->child0, thistestId, teststatusnow);
+ protolog_status(options->child0, thistestId, teststatusnow, ctlsockfd);

setCurrentTest(TEST_NONE);
/* I2AddrFree(midsrv_addr); */
=======================================
--- /trunk/src/test_results_clt.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_results_clt.c Thu Nov 15 13:33:44 2012
@@ -9,10 +9,10 @@
#include <string.h>
#include <stdio.h>

-#include "logging.h"
-#include "utils.h"
-#include "clt_tests.h"
-#include "test_results_clt.h"
+#include "./logging.h"
+#include "./utils.h"
+#include "./clt_tests.h"
+#include "./test_results_clt.h"

#ifndef VIEW_DIFF
#define VIEW_DIFF 0.1
@@ -84,19 +84,24 @@
break;

case DUPLEX_SWITCH_FULL_HOST_HALF :
- printf("Alarm: Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+ printf("Alarm: Duplex Mismatch condition detected. Switch=Full and "
+ "Host=Half\n");
break;
case DUPLEX_SWITCH_FULL_HOST_HALF_POSS:
- printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+ printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Full "
+ "and Host=Half\n");
break;
case DUPLEX_SWITCH_HALF_HOST_FULL:
- printf("Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+ printf("Alarm: Duplex Mismatch condition detected. Switch=Half and "
+ "Host=Full\n");
break;
case DUPLEX_SWITCH_HALF_HOST_FULL_POSS:
- printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+ printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Half "
+ "and Host=Full\n");
break;
case DUPLEX_SWITCH_HALF_HOST_FULL_WARN:
- printf("Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+ printf("Warning: Possible Duplex Mismatch condition detected. "
+ "Switch=Half and Host=Full\n");
break;
}
}
@@ -113,10 +118,10 @@
* @param max_RwinRcvd
*/
void print_recommend_buffersize(double rwin, double rttsec, double avgrtt,
- double mylink, int max_RwinRcvd){
+ double mylink, int max_RwinRcvd) {
int j = 0;
- log_print(3, "Is larger buffer recommended? rwin*2/rttsec (%0.4f) < mylink (%0.4f) ",
- ((rwin*2)/rttsec), mylink);
+ log_print(3, "Is larger buffer recommended? rwin*2/rttsec (%0.4f) < mylink "
+ "(%0.4f) ", ((rwin*2)/rttsec), mylink);
log_println(3, "AND j (%0.4f) > MaxRwinRcvd (%d)",
(float)((mylink * avgrtt)*1000)/8, max_RwinRcvd);
if (((rwin*2)/rttsec) < mylink) {
@@ -154,11 +159,13 @@
* @param spdout C->S throughput as calculated by the Client during the C->S test
* @param sndqueue length of send queue of the C->S throughput test
*/
-void check_C2Spacketqueuing(double c2sthruput, double spdout, int sndqueue, int pktcount, int buflength) {
+void check_C2Spacketqueuing(double c2sthruput, double spdout, int sndqueue,
+ int pktcount, int buflength) {
if (c2sthruput < (spdout * (1.0 - VIEW_DIFF))) {
printf("Information [C2S]: Packet queuing detected: %0.2f%% ",
100 * (spdout - c2sthruput) / spdout);
- if (sndqueue > (0.8 * pktcount * buflength * (spdout - c2sthruput) / spdout)) {
+ if (sndqueue >
+ (0.8 * pktcount * buflength * (spdout - c2sthruput) / spdout)) {
printf("(local buffers)\n");
} else {
printf("(remote buffers)\n");
@@ -175,11 +182,13 @@
* @param sndqueue length of send queue of the S->C throughput test
* @param sbytecount total-sent-byte-count in the S->C throughput test
*/
-void check_S2Cpacketqueuing(double s2cthroughput, double spdin, int srvsndqueue, int sbytecount) {
+void check_S2Cpacketqueuing(double s2cthroughput, double spdin,
+ int srvsndqueue, int sbytecount) {
if (spdin < (s2cthroughput * (1.0 - VIEW_DIFF))) {
printf("Information [S2C]: Packet queuing detected: %0.2f%% ",
100 * (s2cthroughput - spdin) / s2cthroughput);
- if (srvsndqueue > (0.8 * sbytecount * (s2cthroughput - spdin) / s2cthroughput)) {
+ if (srvsndqueue >
+ (0.8 * sbytecount * (s2cthroughput - spdin) / s2cthroughput)) {
printf("(local buffers)\n");
} else {
printf("(remote buffers)\n");
@@ -208,8 +217,8 @@
* @param totaltesttime Total test time
*/
void print_packetloss_statistics(int PktsRetrans, int DupAcksIn, int SACKsRcvd,
- double ooorder, int Timeouts, double waitsec , double totaltesttime) {
-
+ double ooorder, int Timeouts, double waitsec,
+ double totaltesttime) {
if (PktsRetrans > 0) {
printf("There were %d packets retransmitted", PktsRetrans);
printf(", %d duplicate acks received", DupAcksIn);
@@ -233,7 +242,6 @@
} else {
printf("No packet loss was observed.\n");
}
-
}


@@ -251,28 +259,27 @@
* @param max_rwinrcvd MaxRwinRcvd value
*/

-void print_limitedtime_ratio(double rwintime, double rwin, double sendtime, double swin, double cwndtime,
- double rttsec, double mylinkspeed, int sndbuf, int max_rwinrcvd) {
-
+void print_limitedtime_ratio(double rwintime, double rwin, double sendtime,
+ double swin, double cwndtime, double rttsec,
+ double mylinkspeed, int sndbuf, int max_rwinrcvd) {
if (rwintime > .015) {
printf("This connection is receiver limited %0.2f%% of the time.\n",
rwintime * 100);
if ((2 * (rwin / rttsec)) < mylinkspeed)
- printf(" Increasing the current receive buffer (%0.2f KB) will improve performance\n",
- (float) max_rwinrcvd / KILO_BITS);
+ printf(" Increasing the current receive buffer (%0.2f KB) will improve "
+ "performance\n", (float) max_rwinrcvd / KILO_BITS);
}
if (sendtime > .015) {
printf("This connection is sender limited %0.2f%% of the time.\n",
sendtime * 100);
if ((2 * (swin / rttsec)) < mylinkspeed)
- printf(" Increasing the current send buffer (%0.2f KB) will improve performance\n",
- (float) sndbuf / KILO_BITS);
+ printf(" Increasing the current send buffer (%0.2f KB) will improve "
+ "performance\n", (float) sndbuf / KILO_BITS);
}
if (cwndtime > .005) {
printf("This connection is network limited %0.2f%% of the time.\n",
cwndtime * 100);
}
-
}

/**
@@ -305,8 +312,7 @@
* @param is_nagleenabled
*/

-void print_Nagle_RFC896(int is_nagleenabled)
-{
+void print_Nagle_RFC896(int is_nagleenabled) {
printf("RFC 896 Nagle Algorithm: ");
if (is_nagleenabled == 0)
printf("OFF\n");
@@ -318,14 +324,12 @@
* Print if Explicit congestion notification to IP is on - RFC 3168 related
* @param is_ECNenabled
*/
-void print_congestion_RFC3168(int is_ECNenabled)
-{
+void print_congestion_RFC3168(int is_ECNenabled) {
printf("RFC 3168 Explicit Congestion Notification: ");
if (is_ECNenabled == 0)
printf("OFF\n");
else
printf("ON\n");
-
}

/**
@@ -333,8 +337,7 @@
*
* @param is_timestampenabled
*/
-void print_timestamping_RFC1323(int is_timestampenabled)
-{
+void print_timestamping_RFC1323(int is_timestampenabled) {
printf("RFC 1323 Time Stamping: ");
if (is_timestampenabled == 0)
printf("OFF\n");
@@ -348,7 +351,8 @@
* @param winscale_rcvd value of the received window scale option
* @param winscale_sent value of the transmitted window scale option
*/
-void print_windowscaling(int max_rwinrcvd, int winscale_rcvd, int winscale_sent) {
+void print_windowscaling(int max_rwinrcvd, int winscale_rcvd,
+ int winscale_sent) {
printf("RFC 1323 Window Scaling: ");
if (max_rwinrcvd < 65535)
winscale_rcvd = 0;
@@ -373,22 +377,24 @@
* @param estimate Estimated theoretical throughput
*/
void print_throughputlimits(int max_rwinrcvd, int rcvwinscale, int *sndbuf,
- double s_win, double r_win, double c_win, double rttsec, double estimate) {
+ double s_win, double r_win, double c_win,
+ double rttsec, double estimate) {
int tempsendbuf = *sndbuf;
if ((rcvwinscale == 0) && (tempsendbuf > 65535))
tempsendbuf = 65535;

printf("The theoretical network limit is %0.2f Mbps\n", estimate);

- printf("The NDT server has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
- (float) tempsendbuf / KILO_BITS, (float) s_win / rttsec);
+ printf("The NDT server has a %0.0f KByte buffer which limits the throughput "
+ "to %0.2f Mbps\n", (float) tempsendbuf / KILO_BITS,
+ (float) s_win / rttsec);

- printf("Your PC/Workstation has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
- (float) max_rwinrcvd / KILO_BITS, (float) r_win / rttsec);
+ printf("Your PC/Workstation has a %0.0f KByte buffer which limits the "
+ "throughput to %0.2f Mbps\n", (float) max_rwinrcvd / KILO_BITS,
+ (float) r_win / rttsec);

printf("The network based flow control limits the throughput to %0.2f Mbps\n",
(float) c_win / rttsec);
-
}


@@ -402,14 +408,14 @@
* @param s2c_linkspeed_ack Data link speed as detected by client acknowledgments
*/
void print_linkspeed_dataacks(int isC2S_enabled, int c2s_linkspeed_data,
- int c2s_linkspeed_ack, int s2c_linkspeed_data, int s2c_linkspeed_ack) {
+ int c2s_linkspeed_ack, int s2c_linkspeed_data,
+ int s2c_linkspeed_ack) {
if (isC2S_enabled) {
- printf("\nClient Data reports link is '%3d', Client Acks report link is '%3d'\n",
- c2s_linkspeed_data, c2s_linkspeed_ack);
+ printf("\nClient Data reports link is '%3d', Client Acks report link is "
+ "'%3d'\n", c2s_linkspeed_data, c2s_linkspeed_ack);
}
- printf("Server Data reports link is '%3d', Server Acks report link is '%3d'\n",
- s2c_linkspeed_data, s2c_linkspeed_ack);
-
+ printf("Server Data reports link is '%3d', Server Acks report link is "
+ "'%3d'\n", s2c_linkspeed_data, s2c_linkspeed_ack);
}

/**
@@ -421,12 +427,11 @@
* @param ccip Client side client IP address string
*/
void check_NAT(char *ssip, char *csip, char *scip, char *ccip) {
-
// If server and client both see similar server IP addresses,
// no NAT happening
- if (strcmp(ssip, csip) == 0)
+ if (strcmp(ssip, csip) == 0) {
printf("Server IP addresses are preserved End-to-End\n");
- else {
+ } else {
printf("Information: Network Address Translation (NAT) box is ");
printf("modifying the Server's IP address\n");
printf("\tServer says [%s] but Client says [ %s]\n", ssip, csip);
@@ -434,14 +439,13 @@

// If server and client both see similar client IP addresses,
// no NAT happening
- if (strcmp(scip, ccip) == 0)
+ if (strcmp(scip, ccip) == 0) {
printf("Client IP addresses are preserved End-to-End\n");
- else {
+ } else {
printf("Information: Network Address Translation (NAT) box is ");
printf("modifying the Client's IP address\n");
printf("\tServer says [%s] but Client says [ %s]\n", scip, ccip);
}
-
}

/**
@@ -460,7 +464,6 @@
if (*mssvalue == 1456)
printf("Packet size is preserved End-to-End\n");
else
- printf("Information: Network Middlebox is modifying MSS variable (changed to %d)\n",
- *mssvalue);
-
+ printf("Information: Network Middlebox is modifying MSS variable "
+ "(changed to %d)\n", *mssvalue);
}
=======================================
--- /trunk/src/test_results_clt.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/test_results_clt.h Thu Nov 15 13:33:44 2012
@@ -5,8 +5,8 @@
* Author: kkumar
*/

-#ifndef TEST_RESULTS_CLT_H_
-#define TEST_RESULTS_CLT_H_
+#ifndef SRC_TEST_RESULTS_CLT_H_
+#define SRC_TEST_RESULTS_CLT_H_

// determine linkspeed based on link speed indicator
double get_linkspeed(int c2s_linkspeed_ind, int half_duplex_ind);
@@ -22,7 +22,7 @@

// Calculate and display recommended buffer sizes
void print_recommend_buffersize(double rwin, double rttsec, double avgrtt,
- double mylink, int max_RwinRcvd);
+ double mylink, int max_RwinRcvd);

// Check if faulty hardware was detected, and print results
void check_badcable(int is_bad_cable);
@@ -31,19 +31,23 @@
void check_congestion(int is_congested);

// Check if packet queuing is a problem at the C->S end.
-void check_C2Spacketqueuing(double c2sthruput, double spdout, int sndqueue, int pktcount, int buflength);
+void check_C2Spacketqueuing(double c2sthruput, double spdout, int sndqueue,
+ int pktcount, int buflength);

// Deduce if packet queuing is a problem at the S->C end from values collected
// .. during the S2C tests.
-void check_S2Cpacketqueuing(double s2cthroughput, double spdin, int srvsndqueue, int sbytecount);
+void check_S2Cpacketqueuing(double s2cthroughput, double spdin, int srvsndqueue,
+ int sbytecount);

// Print suggestions based on packet loss/retransmissions details obtained
void print_packetloss_statistics(int PktsRetrans, int DupAcksIn, int SACKsRcvd,
- double ooorder, int Timeouts, double waitsec , double
totaltesttime);
+ double ooorder, int Timeouts, double waitsec,
+ double totaltesttime);

// Print details about being receiver, sender or congestion window limited.
-void print_limitedtime_ratio(double rwintime, double rwin, double sendtime, double swin, double cwndtime,
- double rttsec, double mylinkspeed, int sndbuf, int
max_rwinrcvd) ;
+void print_limitedtime_ratio(double rwintime, double rwin, double sendtime,
+ double swin, double cwndtime, double rttsec,
+ double mylinkspeed, int sndbuf, int max_rwinrcvd);

// Check if excessive packet loss is affecting performance
void print_packetloss_excess(double spd, double loss);
@@ -63,15 +67,16 @@
// Print window scaling based data
void print_windowscaling(int MaxRwinRcvd, int WinScaleRcvd, int WinScaleSent);

-//Print details of throughput limits(thresholds) imposed by
-// the send, receive or congestion window values
-void print_throughputlimits(int max_rwinrcvd, int RcvWinScale,
- int *sndbuf, double s_win, double r_win, double c_win, double
rttsec,
- double estimate);
+// Print details of throughput limits(thresholds) imposed by the send, receive
+// or congestion window values
+void print_throughputlimits(int max_rwinrcvd, int RcvWinScale, int *sndbuf,
+ double s_win, double r_win, double c_win,
+ double rttsec, double estimate);

// Print details of link speed as seen by data and ack speed indicators
void print_linkspeed_dataacks(int isC2S_enabled, int c2s_linkspeed_data,
- int c2s_linkspeed_ack, int s2c_linkspeed_data, int
s2c_linkspeed_ack) ;
+ int c2s_linkspeed_ack, int s2c_linkspeed_data,
+ int s2c_linkspeed_ack);

// Check if a Network Address translation box is modifying IP addresses
// of server or client
@@ -79,4 +84,4 @@

// Check packet size preservation
void check_MSS_modification(int is_timestampenabled, int *mssvalue);
-#endif /* TEST_RESULTS_CLT_H_ */
+#endif // SRC_TEST_RESULTS_CLT_H_
=======================================
--- /trunk/src/test_s2c_clt.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_s2c_clt.c Thu Nov 15 13:33:44 2012
@@ -10,12 +10,12 @@
#include <stdlib.h>
#include <string.h>

-#include "clt_tests.h"
-#include "logging.h"
-#include "network.h"
-#include "protocol.h"
-#include "utils.h"
-#include "strlutils.h"
+#include "./clt_tests.h"
+#include "./logging.h"
+#include "./network.h"
+#include "./protocol.h"
+#include "./utils.h"
+#include "./strlutils.h"

int ssndqueue, sbytes;
double spdin, s2cspd;
@@ -45,7 +45,7 @@
int msgLen, msgType;
int s2cport = atoi(PORT3);
I2Addr sec_addr = NULL;
- int inlth, retcode, one=1, set_size;
+ int inlth, retcode, one = 1, set_size;
int inSocket;
socklen_t optlen;
uint32_t bytes;
@@ -60,12 +60,12 @@

if (tests & TEST_S2C) {
setCurrentTest(TEST_S2C);
- //protocol logs
+ // protocol logs
teststatuses = TEST_STARTED;
protolog_status(getpid(), testids, teststatuses, ctlSocket);

- // First message expected from the server is a TEST_PREPARE. Any other message
- // ...type is unexpected at this point.
+ // First message expected from the server is a TEST_PREPARE. Any other
+ // message type is unexpected at this point.
log_println(1, " <-- S2C throughput test -->");
msgLen = sizeof(buff);
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
@@ -75,8 +75,8 @@
if (check_msg_type(S2C_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
return 2;
}
- // This TEST_PREPARE message is expected to have the port number as message body.
- // Check if this is a valid integral port.
+ // This TEST_PREPARE message is expected to have the port number as message
+ // body. Check if this is a valid integral port.
if (msgLen <= 0) {
log_println(0, "Improper message");
return 3;
@@ -100,10 +100,11 @@
log_println(0, "Unable to resolve server address: %s", strerror(errno));
return -3;
}
- I2AddrSetPort(sec_addr, s2cport); //set port to value obtained from server
+ I2AddrSetPort(sec_addr, s2cport); // set port to value obtained from server

// Connect to the server; set socket options
- if ((retcode = CreateConnectSocket(&inSocket, NULL, sec_addr, conn_options, buf_size))) {
+ if ((retcode = CreateConnectSocket(&inSocket, NULL, sec_addr, conn_options,
+ buf_size))) {
log_println(0, "Connect() for Server to Client failed", strerror(errno));
return -15;
}
@@ -164,21 +165,23 @@
break;
}

- // get actual time for which data was received, and calculate throughput based on it.
+ // get actual time for which data was received, and calculate throughput
+ // based on it.
t = secs() - t + 15.0;
- spdin = ((BITS_8_FLOAT * bytes) / KILO) / t; //kbps
+ spdin = ((BITS_8_FLOAT * bytes) / KILO) / t; // kbps

- //log_println(0,"S->C: Received %d bytes in %0.2f secs: Spdin= %f", bytes, t, spdin);
+ // log_println(0,"S->C: Received %d bytes in %0.2f secs: Spdin= %f", bytes,
+ // t, spdin);

- // Server sends calculated throughput value, unsent data amount in the socket queue
- // and overall number of sent bytes in a TEST_MSG
+ // Server sends calculated throughput value, unsent data amount in the
+ // socket queue and overall number of sent bytes in a TEST_MSG
msgLen = sizeof(buff);
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed text message!");
return 1;
}
if (check_msg_type(S2C_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
- return 2; // no other message type expected
+ return 2; // no other message type expected
}
// Is message of valid length, and does it have all the data expected?
if (msgLen <= 0) {
@@ -197,14 +200,14 @@
log_println(0, "S2C: Improper message");
return 4;
}
- ssndqueue = atoi(ptr); // get amount of unsent data in queue
+ ssndqueue = atoi(ptr); // get amount of unsent data in queue
ptr = strtok(NULL, " ");
if (ptr == NULL) {
log_println(0, "S2C: Improper message");
return 4;
}
- sbytes = atoi(ptr); // finally get total-sent-byte-count
- //log_println(0,"S->C received throughput: %f",s2cspd);
+ sbytes = atoi(ptr); // finally get total-sent-byte-count
+ // log_println(0,"S->C received throughput: %f",s2cspd);
// log results in a convenient units format
if (spdin < 1000)
printf("%0.2f kb/s\n", spdin);
@@ -222,7 +225,7 @@
result_srv[0] = '\0';
for (;;) {
msgLen = sizeof(buff);
- memset(buff,0,msgLen); // reset buff and msgLen
+ memset(buff, 0, msgLen); // reset buff and msgLen

// get web100 variables
if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
@@ -240,14 +243,15 @@
return 2;
}

- strlcat(result_srv, buff, 2 * BUFFSIZE); // hardcoded size of array from main tests
+ // hardcoded size of array from main tests
+ strlcat(result_srv, buff, 2 * BUFFSIZE);
}
log_println(6, "result_srv = '%s', of len %d", result_srv, msgLen);
log_println(1, " <------------------------->");

- //log protocol validation logs
+ // log protocol validation logs
teststatuses = TEST_ENDED;
- protolog_status(getpid(), testids, teststatuses,ctlSocket);
+ protolog_status(getpid(), testids, teststatuses, ctlSocket);
setCurrentTest(TEST_NONE);
}

=======================================
--- /trunk/src/test_s2c_srv.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_s2c_srv.c Thu Nov 15 13:33:44 2012
@@ -11,21 +11,22 @@
#include <pthread.h>
#include <sys/times.h>
#include <ctype.h>
-#include "tests_srv.h"
-#include "strlutils.h"
-#include "ndtptestconstants.h"
-#include "utils.h"
-#include "testoptions.h"
-#include "runningtest.h"
-#include "logging.h"
-#include "protocol.h"
-#include "network.h"
-#include "mrange.h"
+#include "./tests_srv.h"
+#include "./strlutils.h"
+#include "./ndtptestconstants.h"
+#include "./utils.h"
+#include "./testoptions.h"
+#include "./runningtest.h"
+#include "./logging.h"
+#include "./protocol.h"
+#include "./network.h"
+#include "./mrange.h"

extern pthread_mutex_t mainmutex;
extern pthread_cond_t maincond;

-int mon_pipe2[2]; // used to store file descriptors of pipes created for ndttrace for C2S tests
+// used to store file descriptors of pipes created for ndttrace for C2S tests
+int mon_pipe2[2];

/**
* Perform the S2C Throughput test. This throughput test tests the achievable
@@ -73,26 +74,25 @@
int conn_options, double* s2cspd, int set_buff, int window,
int autotune, char* device, Options* options, char spds[4][256],
int* spd_index, int count_vars, CwndPeaks* peaks) {
-
- int ret; // ctrl protocol read/write return status
+ int ret; // ctrl protocol read/write return status
int j, k, n;
- int xmitsfd; // transmit (i.e server) socket fd
- pid_t s2c_childpid = 0; // s2c_childpid
+ int xmitsfd; // transmit (i.e server) socket fd
+ pid_t s2c_childpid = 0; // s2c_childpid

- char tmpstr[256]; // string array used for temp storage of many char*
+ char tmpstr[256]; // string array used for temp storage of many char*
struct sockaddr_storage cli_addr;

socklen_t clilen;
- double bytes_written; // bytes written in the throughput test
- double tx_duration; // total time for which data was txed
- double tmptime; // temporary time store
- double x2cspd; // s->c test throughput
- struct timeval sel_tv; // time
- fd_set rfd; // receive file descriptor
- char buff[BUFFSIZE + 1]; // message payload buffer
- int bufctrlattempts = 0; // number of buffer control attempts
- int i; // temporary var used for iterators etc
- PortPair pair; // socket ports
+ double bytes_written; // bytes written in the throughput test
+ double tx_duration; // total time for which data was txed
+ double tmptime; // temporary time store
+ double x2cspd; // s->c test throughput
+ struct timeval sel_tv; // time
+ fd_set rfd; // receive file descriptor
+ char buff[BUFFSIZE + 1]; // message payload buffer
+ int bufctrlattempts = 0; // number of buffer control attempts
+ int i; // temporary var used for iterators etc
+ PortPair pair; // socket ports
I2Addr s2csrv_addr = NULL;
I2Addr src_addr = NULL;
char listens2cport[10];
@@ -113,7 +113,7 @@
web100_var* var;
pthread_t workerThreadId;
int nextseqtosend = 0, lastunackedseq = 0;
- int drainingqueuecount = 0, bufctlrnewdata = 0; // sent data attempt queue, Draining Queue.
+ int drainingqueuecount = 0, bufctlrnewdata = 0;

// variables used for protocol validation logs
enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
@@ -135,29 +135,33 @@
log_println(1, " <-- %d - S2C throughput test -->",
testOptions->child0);

- //protocol logs
+ // protocol logs
teststatuses = TEST_STARTED;
protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);

strlcpy(listens2cport, PORT4, sizeof(listens2cport));

if (testOptions->s2csockport) {
- snprintf(listens2cport, sizeof(listens2cport), "%d", testOptions->s2csockport);
+ snprintf(listens2cport, sizeof(listens2cport), "%d",
+ testOptions->s2csockport);
} else if (testOptions->mainport) {
- snprintf(listens2cport, sizeof(listens2cport), "%d", testOptions->mainport + 2);
+ snprintf(listens2cport, sizeof(listens2cport), "%d",
+ testOptions->mainport + 2);
}

if (testOptions->multiple) {
strlcpy(listens2cport, "0", sizeof(listens2cport));
}

- // attempt to bind to a new port and obtain address structure with details of listening port
+ // attempt to bind to a new port and obtain address structure with details
+ // of listening port
while (s2csrv_addr == NULL) {
- s2csrv_addr = CreateListenSocket(NULL,
- (testOptions->multiple ?
- mrange_next(listens2cport, sizeof(listens2cport)) :
- listens2cport),
- conn_options, 0);
+ s2csrv_addr = CreateListenSocket(
+ NULL,
+ testOptions->multiple ?
+ mrange_next(listens2cport, sizeof(listens2cport)) :
+ listens2cport,
+ conn_options, 0);
if (s2csrv_addr == NULL) {
/*
log_println(1, " Calling KillHung() because s2csrv_address failed to bind");
@@ -187,7 +191,8 @@
return -1;
}

- // get socket FD and the ephemeral port number that client will connect to run tests
+ // get socket FD and the ephemeral port number that client will connect to
+ // run tests
testOptions->s2csockfd = I2AddrFD(s2csrv_addr);
testOptions->s2csockport = I2AddrPort(s2csrv_addr);
log_println(1, " -- s2c %d port: %d", testOptions->child0,
@@ -195,7 +200,8 @@
pair.port1 = -1;
pair.port2 = testOptions->s2csockport;

- // Data received from speed-chk. Send TEST_PREPARE "GO" signal with port number
+ // Data received from speed-chk. Send TEST_PREPARE "GO" signal with port
+ // number
snprintf(buff, sizeof(buff), "%d", testOptions->s2csockport);
j = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff));
if (j == -1) {
@@ -203,7 +209,7 @@
testOptions->child0);
return j;
}
- if (j == -2) { // could not write message data
+ if (j == -2) { // could not write message data
log_println(6, "S2C %d Error!, server port [%s] not sent!",
testOptions->child0, buff);
return j;
@@ -219,7 +225,7 @@
clilen = sizeof(cli_addr);
FD_ZERO(&rfd);
FD_SET(testOptions->c2ssockfd, &rfd);
- sel_tv.tv_sec = 5; // wait for 5 secs
+ sel_tv.tv_sec = 5; // wait for 5 secs
sel_tv.tv_usec = 0;
for (j = 0; j < RETRY_COUNT; j++) {
ret = select((testOptions->s2csockfd) + 1, &rfd, NULL, NULL,
@@ -227,13 +233,14 @@
if ((ret == -1) && (errno == EINTR))
continue;
if (ret == 0)
- return SOCKET_CONNECT_TIMEOUT; // timeout
+ return SOCKET_CONNECT_TIMEOUT; // timeout
if (ret < 0)
- return -errno; // other socket errors. exit
+ return -errno; // other socket errors. exit
if (j == 4)
- return RETRY_EXCEEDED_WAITING_CONNECT; // retry exceeded. exit
+ return RETRY_EXCEEDED_WAITING_CONNECT; // retry exceeded. exit

- // If a valid connection request is received, client has connected. Proceed.
+ // If a valid connection request is received, client has connected.
+ // Proceed.
// Note the new socket fd - xmitfd - used in the throughput test
ximfd: xmitsfd = accept(testOptions->s2csockfd,
(struct sockaddr *) &cli_addr, &clilen);
@@ -246,7 +253,8 @@
procstatusenum, xmitsfd);
break;
}
- if ((xmitsfd == -1) && (errno == EINTR)) { // socket interrupted, wait some more
+ // socket interrupted, wait some more
+ if ((xmitsfd == -1) && (errno == EINTR)) {
log_println(
6,
"Child %d interrupted while waiting for accept() to complete",
@@ -257,9 +265,9 @@
6,
"------- S2C connection setup for %d returned because (%d)",
testOptions->child0, errno);
- if (xmitsfd < 0) // other socket errors, quit
+ if (xmitsfd < 0) // other socket errors, quit
return -errno;
- if (++j == 4) { // retry exceeded, quit
+ if (++j == 4) { // retry exceeded, quit
log_println(
6,
"s2c child %d, unable to open connection, return from test",
@@ -270,7 +278,8 @@
src_addr = I2AddrByLocalSockFD(get_errhandle(), xmitsfd, 0);
conn = web100_connection_from_socket(agent, xmitsfd);

- // set up packet capture. The data collected is used for bottleneck link calculations
+ // set up packet capture. The data collected is used for bottleneck link
+ // calculations
if (xmitsfd > 0) {
log_println(6, "S2C child %d, ready to fork()",
testOptions->child0);
@@ -291,7 +300,8 @@
5,
"S2C test Child thinks pipe() returned fd0=%d, fd1=%d",
mon_pipe2[0], mon_pipe2[1]);
- /* log_println(2, "S2C test calling init_pkttrace() with pd=0x%x", (int) &cli_addr); */
+ // log_println(2, "S2C test calling init_pkttrace() with pd=0x%x",
+ // (int) &cli_addr);
init_pkttrace(src_addr, (struct sockaddr *) &cli_addr,
clilen, mon_pipe2, device, &pair, "s2c",
options->compress);
@@ -300,17 +310,18 @@
exit(0); /* Packet trace finished, terminate gracefully */
}
memset(tmpstr, 0, 256);
- for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
+ for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
ret = read(mon_pipe2[0], tmpstr, 128);
- if ((ret == -1) && (errno == EINTR)) // socket interrupted, try reading again
+ // socket interrupted, try reading again
+ if ((ret == -1) && (errno == EINTR))
continue;
break;
}

if (strlen(tmpstr) > 5)
memcpy(meta.s2c_ndttrace, tmpstr, strlen(tmpstr));
- // name of nettrace file passed back from pcap child copied into meta structure
-
+ // name of nettrace file passed back from pcap child copied into meta
+ // structure
}

/* experimental code, delete when finished */
@@ -354,7 +365,8 @@
sigaction(SIGALRM, &new, &old);

// capture current values (i.e take snap shot) of web_100 variables
- // Write snap logs if option is enabled. update meta log to point to this snaplog
+ // Write snap logs if option is enabled. update meta log to point to
+ // this snaplog

// If snaplog option is enabled, save snaplog details in meta file
if (options->snaplog) {
@@ -369,17 +381,19 @@
conn, group);

/* alarm(20); */
- tmptime = secs(); // current time
- tx_duration = tmptime + 10.0; // set timeout to 10 s in future
+ tmptime = secs(); // current time
+ tx_duration = tmptime + 10.0; // set timeout to 10 s in future

log_println(6, "S2C child %d beginning test", testOptions->child0);

while (secs() < tx_duration) {
- bufctrlattempts++; // Increment total attempts at sending-> buffer control
- if (options->avoidSndBlockUp) { // Do not block send buffers
+ // Increment total attempts at sending-> buffer control
+ bufctrlattempts++;
+ if (options->avoidSndBlockUp) { // Do not block send buffers
pthread_mutex_lock(&mainmutex);

- // get details of next sequence # to be sent and fetch value from snap file
+ // get details of next sequence # to be sent and fetch value from
+ // snap file
web100_agent_find_var_and_group(agent, "SndNxt", &group,
&var);
web100_snap_read(var, snapArgs.snap, tmpstr);
@@ -395,11 +409,13 @@
tmpstr));
pthread_mutex_unlock(&mainmutex);

- // Temporarily stop sending data if you sense that the buffer is overwhelmed
+ // Temporarily stop sending data if you sense that the buffer is
+ // overwhelmed
// This is calculated by checking if (8192 * 4) <
- // ((Next Sequence Number To Be Sent) - (Oldest Unacknowledged Sequence Number) - 1)
- // Increment draining queue value
+ // ((Next Sequence Number To Be Sent) -
+ // (Oldest Unacknowledged Sequence Number) - 1)
if (is_buffer_clogged(nextseqtosend, lastunackedseq)) {
+ // Increment draining queue value
drainingqueuecount++;
continue;
}
@@ -407,16 +423,17 @@

// attempt to write random data into the client socket
n = write(xmitsfd, buff, RECLTH);
- if ((n == -1) && (errno == EINTR)) // socket interrupted, continue attempting to write
+ // socket interrupted, continue attempting to write
+ if ((n == -1) && (errno == EINTR))
continue;
if (n < 0)
- break; // all data written. Exit
+ break; // all data written. Exit
bytes_written += n;

if (options->avoidSndBlockUp) {
- bufctlrnewdata++; // increment "sent data" queue
+ bufctlrnewdata++; // increment "sent data" queue
}
- } // Completed end of trying to transmit data for the goodput test
+ } // Completed end of trying to transmit data for the goodput test
/* alarm(10); */
sigaction(SIGALRM, &old, NULL);
sndqueue = sndq_len(xmitsfd);
@@ -428,7 +445,8 @@
// get actual time duration during which data was transmitted
tx_duration = secs() - tmptime;

- // Throughput in kbps = (no of bits sent * 8) / (1000 * time data was sent)
+ // Throughput in kbps =
+ // (no of bits sent * 8) / (1000 * time data was sent)
x2cspd = (8.e-3 * bytes_written) / tx_duration;

// Release semaphore, and close snaplog file. finalize other data
@@ -438,7 +456,8 @@
memset(buff, 0, sizeof(buff));

// Send throughput, unsent byte count, total sent byte count to client
- snprintf(buff, sizeof(buff), "%0.0f %d %0.0f", x2cspd, sndqueue, bytes_written);
+ snprintf(buff, sizeof(buff), "%0.0f %d %0.0f", x2cspd, sndqueue,
+ bytes_written);
if (send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff)) < 0)
log_println(6,
"S2C test - failed to send test message to pid=%d",
@@ -451,7 +470,8 @@
(int) bytes_written, tx_duration);
log_println(
1,
- "Buffer control counters Total = %d, new data = %d, Draining Queue = %d",
+ "Buffer control counters Total = %d, new data = %d, "
+ "Draining Queue = %d",
bufctrlattempts, bufctlrnewdata, drainingqueuecount);

/* Next send speed-chk a flag to retrieve the data it collected.
@@ -474,13 +494,15 @@
if ((ret == -1) && (errno == EINTR)) {
log_println(
6,
- "Interrupt received while waiting for s2c select90 to finish, continuing");
+ "Interrupt received while waiting for s2c select90 to finish, "
+ "continuing");
continue;
}
if (((ret == -1) && (errno != EINTR)) || (ret == 0)) {
log_println(
4,
- "Failed to read pkt-pair data from S2C flow, retcode=%d, reason=%d, EINTR=%d",
+ "Failed to read pkt-pair data from S2C flow, retcode=%d, "
+ "reason=%d, EINTR=%d",
ret, errno, EINTR);
snprintf(
spds[(*spd_index)++],
@@ -518,15 +540,17 @@

log_println(1, "%6.0f kbps inbound pid-%d", x2cspd, s2c_childpid);
}
-
- /* alarm(30); *//* reset alarm() again, this 10 sec test should finish before this signal
+ /* reset alarm() again, this 10 sec test should finish before this signal
* is generated. */
+ /* alarm(30); */
// Get web100 variables from snapshot taken earlier and send to client
log_println(6, "S2C-Send web100 data vars to client pid=%d",
s2c_childpid);
- ret = web100_get_data(tsnap, ctlsockfd, agent, count_vars); //send web100 data to client
+ // send web100 data to client
+ ret = web100_get_data(tsnap, ctlsockfd, agent, count_vars);
web100_snapshot_free(tsnap);
- ret = web100_get_data(rsnap, ctlsockfd, agent, count_vars); //send tuning-related web100 data collected to client
+ // send tuning-related web100 data collected to client
+ ret = web100_get_data(rsnap, ctlsockfd, agent, count_vars);
web100_snapshot_free(rsnap);

// If sending web100 variables above failed, indicate to client
@@ -537,8 +561,9 @@
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
}

- // Wait for message from client. Client sends its calculated throughput value
- log_println(6,"S2CSPD reception starts");
+ // Wait for message from client. Client sends its calculated throughput
+ // value
+ log_println(6, "S2CSPD reception starts");
msgLen = sizeof(buff);
if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error!");
@@ -568,7 +593,7 @@
return -3;
}
buff[msgLen] = 0;
- *s2cspd = atoi(buff); // save Throughput value as seen by client
+ *s2cspd = atoi(buff); // save Throughput value as seen by client
log_println(6, "S2CSPD from client %f", *s2cspd);
// Final activities of ending tests. Close sockets, file descriptors,
// send finalise message to client
@@ -584,12 +609,11 @@

// log end of test (generic and protocol logs)
log_println(0, " <------------ %d ------------->", testOptions->child0);
- //log protocol validation logs
+ // log protocol validation logs
teststatuses = TEST_ENDED;
- protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
+ protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);

setCurrentTest(TEST_NONE);
-
}
return 0;
}
=======================================
--- /trunk/src/test_sfw.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/test_sfw.h Thu Nov 15 13:33:44 2012
@@ -6,8 +6,8 @@
*

*/

-#ifndef _JS_TEST_SFW_H
-#define _JS_TEST_SFW_H
+#ifndef SRC_TEST_SFW_H_
+#define SRC_TEST_SFW_H_

#define SFW_NOTTESTED 0
#define SFW_NOFIREWALL 1
@@ -21,4 +21,4 @@
int test_sfw_clt(int ctlsockfd, char tests, char* host, int conn_options);
int results_sfw(char tests, char* host);

-#endif
+#endif // SRC_TEST_SFW_H_
=======================================
--- /trunk/src/test_sfw_clt.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_sfw_clt.c Thu Nov 15 13:33:44 2012
@@ -13,11 +13,11 @@
#include <string.h>
#include <signal.h>

-#include "test_sfw.h"
-#include "logging.h"
-#include "protocol.h"
-#include "network.h"
-#include "utils.h"
+#include "./test_sfw.h"
+#include "./logging.h"
+#include "./protocol.h"
+#include "./network.h"
+#include "./utils.h"

static int c2s_result = SFW_NOTTESTED;
static int s2c_result = SFW_NOTTESTED;
@@ -25,7 +25,6 @@
static int sfwsockfd;
static I2Addr sfwcli_addr = NULL;

-
/**
* Print the appropriate message when the SIGALRM is caught.
* @param signo signal number (shuld be SIGALRM)
@@ -70,19 +69,20 @@
sel_tv.tv_sec = testTime;
sel_tv.tv_usec = 0;
switch (select(sfwsockfd+1, &fds, NULL, NULL, &sel_tv)) {
- case -1: // If Socket error, status of firewall is unknown
+ case -1: // If Socket error, status of firewall is unknown
log_println(0, "Simple firewall test: select exited with error");
I2AddrFree(sfwcli_addr);
return NULL;
- case 0: // timeout, indicates that firewall is a possibility
- log_println(1, "Simple firewall test: CLT: no connection for %d seconds", testTime);
+ case 0: // timeout, indicates that firewall is a possibility
+ log_println(1, "Simple firewall test: CLT: no connection for %d seconds",
+ testTime);
s2c_result = SFW_POSSIBLE;
I2AddrFree(sfwcli_addr);
return NULL;
}

- // Get message sent by server. If message reception is erroneous, firewall status
- // .. cannot be determined
+ // Get message sent by server. If message reception is erroneous, firewall
+ // status cannot be determined
srvlen = sizeof(srv_addr);
sockfd = accept(sfwsockfd, (struct sockaddr *) &srv_addr, &srvlen);

@@ -90,8 +90,8 @@
if (sockfd > 0) {
procstatusenum = PROCESS_STARTED;
proctypeenum = CONNECT_TYPE;
- protolog_procstatus(getpid(), testids , proctypeenum,
- procstatusenum, sockfd );
+ protolog_procstatus(getpid(), testids , proctypeenum, procstatusenum,
+ sockfd);
}

msgLen = sizeof(buff);
@@ -104,7 +104,7 @@
}

// The server is expected to send a TEST_MSG type of packet. Any other message
- // .. type is unexpected at this point and leaves firewall status indeterminate.
+ // type is unexpected at this point and leaves firewall status indeterminate.
if (check_msg_type(SFW_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
s2c_result = SFW_UNKNOWN;
close(sockfd);
@@ -166,7 +166,8 @@
*
*/
int test_sfw_clt(int ctlsockfd, char tests, char* host, int conn_options) {
- char buff[BUFFSIZE + 1];int msgLen, msgType;
+ char buff[BUFFSIZE + 1];
+ int msgLen, msgType;
int sfwport, sfwsock, sfwsockport;
I2Addr sfwsrv_addr = NULL;
struct sigaction new, old;
@@ -177,10 +178,10 @@
enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
enum TEST_ID testids = SFW;

- if (tests & TEST_SFW) { // SFW test is to be performed
+ if (tests & TEST_SFW) { // SFW test is to be performed
log_println(1, " <-- Simple firewall test -->");
setCurrentTest(TEST_SFW);
- //protocol logs
+ // protocol logs
teststatuses = TEST_STARTED;
protolog_status(getpid(), testids, teststatuses, ctlsockfd);

@@ -221,7 +222,7 @@
log_println(0, "SFW: Improper message");
return 5;
}
- if (check_int(ptr, &testTime)) { // get test time
+ if (check_int(ptr, &testTime)) { // get test time
log_println(0, "Invalid waiting time");
return 4;
}
@@ -233,10 +234,12 @@
}
I2AddrSetPort(sfwsrv_addr, sfwport);

- // create a listening socket, and if successful, send this socket number to server
+ // create a listening socket, and if successful, send this socket number to
+ // server
sfwcli_addr = CreateListenSocket(NULL, "0", conn_options, 0);
if (sfwcli_addr == NULL) {
- log_println(0, "Client (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
+ log_println(0, "Client (Simple firewall test): "
+ "CreateListenSocket failed: %s", strerror(errno));
return -1;
}
sfwsockfd = I2AddrFD(sfwcli_addr);
@@ -270,7 +273,8 @@
// Now, run Test from client for the C->S direction SFW test
// ..trying to connect to ephemeral port number sent by server

- if (CreateConnectSocket(&sfwsock, NULL, sfwsrv_addr, conn_options, 0) == 0) {
+ if (CreateConnectSocket(&sfwsock, NULL, sfwsrv_addr,
+ conn_options, 0) == 0) {
send_msg(sfwsock, TEST_MSG, SFW_PREDEFINED_TEST_MSG, 20);
}
alarm(0);
@@ -290,12 +294,13 @@

// The test results are sent as a numeric encoding the test results.

- if (msgLen <= 0) { // test results have valid length
+ if (msgLen <= 0) { // test results have valid length
log_println(0, "Improper message");
return 3;
}
buff[msgLen] = 0;
- if (check_int(buff, &c2s_result)) { // test result has to be a valid integer
+ if (check_int(buff, &c2s_result)) {
+ // test result has to be a valid integer
log_println(0, "Invalid test result");
return 4;
}
@@ -305,7 +310,8 @@

printf("Done\n");

- // The last message expected from the server is an empty TEST_FINALIZE message.
+ // The last message expected from the server is an empty TEST_FINALIZE
+ // message.
msgLen = sizeof(buff);
if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
log_println(0, "Protocol error - missed finalize message!");
@@ -317,7 +323,7 @@
log_println(1, " <-------------------------->");
// log protocol validation test ending
teststatuses = TEST_ENDED;
- protolog_status(getpid(), testids, teststatuses,ctlsockfd);
+ protolog_status(getpid(), testids, teststatuses, ctlsockfd);
setCurrentTest(TEST_NONE);
}
return 0;
@@ -331,7 +337,7 @@
*/

int results_sfw(char tests, char* host) {
- if (tests & TEST_SFW) { // SFW test has been selected to be run
+ if (tests & TEST_SFW) { // SFW test has been selected to be run
// Print C->S direction's results
switch (c2s_result) {
case SFW_NOFIREWALL:
=======================================
--- /trunk/src/test_sfw_srv.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/test_sfw_srv.c Thu Nov 15 13:33:44 2012
@@ -9,14 +9,14 @@
#include <assert.h>
#include <pthread.h>

-#include "test_sfw.h"
-#include "logging.h"
-#include "protocol.h"
-#include "network.h"
-#include "utils.h"
-#include "testoptions.h"
-#include "runningtest.h"
-#include "strlutils.h"
+#include "./test_sfw.h"
+#include "./logging.h"
+#include "./protocol.h"
+#include "./network.h"
+#include "./utils.h"
+#include "./testoptions.h"
+#include "./runningtest.h"
+#include "./strlutils.h"

static pthread_mutex_t mainmutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t maincond = PTHREAD_COND_INITIALIZER;
@@ -122,7 +122,8 @@

int test_sfw_srv(int ctlsockfd, web100_agent* agent, TestOptions* options,
int conn_options) {
- char buff[BUFFSIZE + 1];I2Addr sfwsrv_addr = NULL;
+ char buff[BUFFSIZE + 1];
+ I2Addr sfwsrv_addr = NULL;
int sfwsockfd, sfwsockport, sockfd, sfwport;
struct sockaddr_storage cli_addr;
socklen_t clilen;
@@ -150,13 +151,15 @@
log_println(1, " <-- %d - Simple firewall test -->", options->child0);
thistestId = SFW;
teststatusnow = TEST_STARTED;
- protolog_status(options->child0, thistestId, teststatusnow,ctlsockfd);
+ protolog_status(options->child0, thistestId, teststatusnow, ctlsockfd);

// bind to a new port and obtain address structure with details of port etc
sfwsrv_addr = CreateListenSocket(NULL, "0", conn_options, 0);
if (sfwsrv_addr == NULL) {
- log_println(0, "Server (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
- snprintf(buff, sizeof(buff), "Server (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
+ log_println(0, "Server (Simple firewall test): "
+ "CreateListenSocket failed: %s", strerror(errno));
+ snprintf(buff, sizeof(buff), "Server (Simple firewall test): "
+ "CreateListenSocket failed: %s", strerror(errno));
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
return -1;
}
@@ -168,13 +171,14 @@

cn = web100_connection_from_socket(agent, ctlsockfd);
if (cn) {
-
// Get remote end's address
web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
web100_raw_read(var, cn, buff);
memset(hostname, 0, 256);
- //strncpy(hostname, web100_value_to_text(web100_get_var_type(var), buff), 255);
- strlcpy(hostname, web100_value_to_text(web100_get_var_type(var), buff), sizeof(hostname));
+ // strncpy(hostname, web100_value_to_text(web100_get_var_type(var), buff),
+ // 255);
+ strlcpy(hostname, web100_value_to_text(web100_get_var_type(var), buff),
+ sizeof(hostname));

// Determine test time in seconds.
// test-time = max(round trip time, timeout) > 3 ? 3 : 1
@@ -192,10 +196,10 @@
testTime = 3;
else
testTime = 1;
- }
- else {
+ } else {
log_println(0, "Simple firewall test: Cannot find connection");
- snprintf(buff, sizeof(buff), "Server (Simple firewall test): Cannot find connection");
+ snprintf(buff, sizeof(buff), "Server (Simple firewall test): "
+ "Cannot find connection");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
I2AddrFree(sfwsrv_addr);
return -1;
@@ -211,23 +215,28 @@
// Listen for TEST_MSG from client's port number sent as data.
// Any other type of message is unexpected at this juncture.
msgLen = sizeof(buff);
- if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) { // message reception error
+ if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+ // message reception error
log_println(0, "Protocol error!");
- snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+ snprintf(buff, sizeof(buff), "Server (Simple firewall test): "
+ "Invalid port number received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
I2AddrFree(sfwsrv_addr);
return 1;
}
- if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff, msgLen)) {
+ if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff,
+ msgLen)) {
log_println(0, "Fault, unexpected message received!");
- snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+ snprintf(buff, sizeof(buff), "Server (Simple firewall test): "
+ "Invalid port number received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
I2AddrFree(sfwsrv_addr);
return 2;
}
- if (msgLen <= 0) { // message reception has error
+ if (msgLen <= 0) { // message reception has error
log_println(0, "Improper message");
- snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+ snprintf(buff, sizeof(buff), "Server (Simple firewall test): "
+ "Invalid port number received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
I2AddrFree(sfwsrv_addr);
return 3;
@@ -236,18 +245,22 @@
// under any error condition, but the log messages indicate the difference

buff[msgLen] = 0;
- if (check_int(buff, &sfwport)) { // message data is not number, thus no port info received
+ if (check_int(buff, &sfwport)) {
+ // message data is not number, thus no port info received
log_println(0, "Invalid port number");
- snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+ snprintf(buff, sizeof(buff), "Server (Simple firewall test): "
+ "Invalid port number received");
send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
I2AddrFree(sfwsrv_addr);
return 4;
}

// Get node, port(if present) and other details of client end.
- // If not able to resolve it, the test cannot proceed to the "throughput" stage
+ // If not able to resolve it, the test cannot proceed to the "throughput"
+ // stage
if ((sfwcli_addr = I2AddrByNode(get_errhandle(), hostname)) == NULL) {
- log_println(0, "Unable to resolve server address"); //todo, this is the client address we cannot resolve?
+ // todo, this is the client address we cannot resolve?
+ log_println(0, "Unable to resolve server address");
send_msg(ctlsockfd, TEST_FINALIZE, "", 0);

// log end
@@ -276,7 +289,7 @@
// indicates error , and finalizes the test at this point.

switch (select(sfwsockfd+1, &fds, NULL, NULL, &sel_tv)) {
- case -1: // If SOCKET_ERROR - status of firewall unknown
+ case -1: // If SOCKET_ERROR - status of firewall unknown
log_println(0, "Simple firewall test: select exited with error");
snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
@@ -284,8 +297,9 @@
I2AddrFree(sfwsrv_addr);
I2AddrFree(sfwcli_addr);
return 1;
- case 0:// Time expiration. SFW possible in C->S side
- log_println(0, "Simple firewall test: no connection for %d seconds", testTime);
+ case 0: // Time expiration. SFW possible in C->S side
+ log_println(0, "Simple firewall test: no connection for %d seconds",
+ testTime);
snprintf(buff, sizeof(buff), "%d", SFW_POSSIBLE);
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
finalize_sfw(ctlsockfd);
@@ -301,10 +315,12 @@
sockfd = accept(sfwsockfd, (struct sockaddr *) &cli_addr, &clilen);
// protocol validation log to indicate client tried connecting
procstatusenum = PROCESS_STARTED;
- protolog_procstatus(options->child0, thistestId, proctypeenum, procstatusenum, sockfd);
+ protolog_procstatus(options->child0, thistestId, proctypeenum,
+ procstatusenum, sockfd);

msgLen = sizeof(buff);
- if (recv_msg(sockfd, &msgType, buff, &msgLen)) { // message received in error
+ if (recv_msg(sockfd, &msgType, buff, &msgLen)) {
+ // message received in error
log_println(0, "Simple firewall test: unrecognized message");
snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
@@ -314,7 +330,8 @@
I2AddrFree(sfwcli_addr);
return 1;
}
- if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff, msgLen)) {
+ if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff,
+ msgLen)) {
// unexpected message type received
snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
@@ -324,7 +341,8 @@
I2AddrFree(sfwcli_addr);
return 1;
}
- if (msgLen != SFW_TEST_DEFAULT_LEN) { // Expecting default 20 byte long "Simple firewall test" message
+ if (msgLen != SFW_TEST_DEFAULT_LEN) {
+ // Expecting default 20 byte long "Simple firewall test" message
log_println(0, "Simple firewall test: Improper message");
snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
=======================================
--- /trunk/src/testoptions.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/testoptions.c Thu Nov 15 13:33:44 2012
@@ -7,26 +7,26 @@

#include <assert.h>
#include <string.h>
-//#include <ctype.h>
+// #include <ctype.h>
#include <pthread.h>

-#include "testoptions.h"
-#include "network.h"
-#include "mrange.h"
-#include "logging.h"
-#include "utils.h"
-#include "protocol.h"
-#include "I2util/util.h"
-#include "runningtest.h"
-#include "strlutils.h"
+#include "./testoptions.h"
+#include "./network.h"
+#include "./mrange.h"
+#include "./logging.h"
+#include "./utils.h"
+#include "./protocol.h"
+#include "./I2util/util.h"
+#include "./runningtest.h"
+#include "./strlutils.h"


// Worker thread characteristics used to record snaplog and Cwnd peaks
typedef struct workerArgs {
- SnapArgs* snapArgs; // snapArgs struct pointer
- web100_agent* agent; // web_100 agent pointer
- CwndPeaks* peaks; // data indicating Cwnd values
- int writeSnap; // enable writing snaplog
+ SnapArgs* snapArgs; // snapArgs struct pointer
+ web100_agent* agent; // web_100 agent pointer
+ CwndPeaks* peaks; // data indicating Cwnd values
+ int writeSnap; // enable writing snaplog
} WorkerArgs;

int workerLoop = 0;
@@ -45,7 +45,8 @@
* @param snap Web100 snapshot structure
*/

-void findCwndPeaks(web100_agent* agent, CwndPeaks* peaks, web100_snapshot* snap) {
+void findCwndPeaks(web100_agent* agent, CwndPeaks* peaks,
+ web100_snapshot* snap) {
web100_group* group;
web100_var* var;
int CurCwnd;
@@ -73,7 +74,8 @@
peaks->amount += 1;
}
decreasing = 1;
- } else if (CurCwnd > prevCWNDval) { // current congestion window size
previous value,
+ // current congestion window size > previous value,
+ } else if (CurCwnd > prevCWNDval) {
// not decreasing.
if ((peaks->min == -1) || (prevCWNDval < peaks->min)) {
peaks->min = prevCWNDval;
@@ -154,7 +156,8 @@
* @param buff test suite description
* @param test_id id of the test
*/
-void add_test_to_suite(int* first, char * buff, size_t buff_strlen, int test_id) {
+void add_test_to_suite(int* first, char * buff, size_t buff_strlen,
+ int test_id) {
char tmpbuff[16];
if (*first) {
*first = 0;
@@ -181,13 +184,14 @@
*
*/

-int initialize_tests(int ctlsockfd, TestOptions* options, char * buff, size_t buff_strlen) {
+int initialize_tests(int ctlsockfd, TestOptions* options, char * buff,
+ size_t buff_strlen) {
unsigned char useropt = 0;
int msgType;
int msgLen = 1;
int first = 1;
- //char remhostarr[256], protologlocalarr[256];
- //char *remhost_ptr = get_remotehost();
+ // char remhostarr[256], protologlocalarr[256];
+ // char *remhost_ptr = get_remotehost();

assert(ctlsockfd != -1);
assert(options);
@@ -214,7 +218,7 @@
"Client connect received from :IP %s to some server on socket %d",
get_remotehost(), ctlsockfd);

- //set_protologfile(get_remotehost(), protologlocalarr);
+ // set_protologfile(get_remotehost(), protologlocalarr);

if (!(useropt
& (TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW | TEST_STATUS
@@ -254,9 +258,10 @@
* @param web100_connection connection pointer
* @param web100_group group web100_group pointer
*/
-void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg, CwndPeaks* peaks,
- char snaplogenabled, pthread_t *wrkrthreadidarg,
- char *metafilevariablename, char *metafilename, web100_connection* conn,
+void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg,
+ CwndPeaks* peaks, char snaplogenabled,
+ pthread_t *wrkrthreadidarg, char *metafilevariablename,
+ char *metafilename, web100_connection* conn,
web100_group* group) {
FILE *fplocal;

@@ -270,8 +275,7 @@
snaparg->snap = web100_snapshot_alloc(group, conn);

if (snaplogenabled) {
-
- //memcpy(metafilevariablename, metafilename, strlen(metafilename));
+ // memcpy(metafilevariablename, metafilename, strlen(metafilename));
// The above could have been here, except for a caveat: metafile stores
// just the file name, but full filename is needed to open the log file

@@ -312,7 +316,8 @@
* @param snaplogenabled boolean indication whether snap logging is enabled
* @param snapArgs_ptr pointer to a snapArgs object
* */
-void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled, SnapArgs* snapArgs_ptr) {
+void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled,
+ SnapArgs* snapArgs_ptr) {
if (*workerThreadId) {
pthread_mutex_lock(&mainmutex);
workerLoop = 0;
@@ -325,7 +330,6 @@
}

web100_snapshot_free(snapArgs_ptr->snap);
-
}

/**
@@ -344,17 +348,16 @@
* */

void start_packet_trace(int socketfdarg, int socketfdarg2, pid_t *childpid,
- int *imonarg, struct sockaddr *cliaddrarg, socklen_t clilenarg,
- char* device, PortPair* pairarg, const char* testindicatorarg,
- int iscompressionenabled, char *copylocationarg) {
-
+ int *imonarg, struct sockaddr *cliaddrarg,
+ socklen_t clilenarg, char* device, PortPair* pairarg,
+ const char* testindicatorarg, int iscompressionenabled,
+ char *copylocationarg) {
char tmpstr[256];
int i, readretval;

I2Addr src_addr = I2AddrByLocalSockFD(get_errhandle(), socketfdarg, 0);

if ((*childpid = fork()) == 0) {
-
close(socketfdarg2);
close(socketfdarg);
log_println(0, "%s test Child thinks pipe() returned fd0=%d, fd1=%d",
@@ -363,17 +366,19 @@
init_pkttrace(src_addr, cliaddrarg, clilenarg, imonarg, device,
pairarg, testindicatorarg, iscompressionenabled);

- exit(0); // Packet trace finished, terminate gracefully
+ exit(0); // Packet trace finished, terminate gracefully
}
memset(tmpstr, 0, 256);
- for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
+ for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
readretval = read(imonarg[0], tmpstr, 128);
- if ((readretval == -1) && (errno == EINTR)) // socket interrupted, try reading again
+ if ((readretval == -1) && (errno == EINTR))
+ // socket interrupted, try reading again
continue;
break;
}

- // name of nettrace file passed back from pcap child copied into meta structure
+ // name of nettrace file passed back from pcap child copied into meta
+ // structure
if (strlen(tmpstr) > 5) {
memcpy(copylocationarg, tmpstr, strlen(tmpstr));
log_println(8, "**start pkt trace, memcopied dir name %s", tmpstr);
@@ -381,7 +386,6 @@

// free this address now.
I2AddrFree(src_addr);
-
}

/**
@@ -394,7 +398,7 @@
int i;

for (i = 0; i < RETRY_COUNT; i++) {
- //retval = write(mon_pipe1[1], "c", 1);
+ // retval = write(mon_pipe1[1], "c", 1);
retval = write(monpipe_arr[1], "c", 1);
if (retval == 1)
break;
@@ -403,7 +407,6 @@
}
close(monpipe_arr[0]);
close(monpipe_arr[1]);
-
}

/**
@@ -414,7 +417,6 @@
* */
void setCwndlimit(web100_connection* connarg, web100_group* grouparg,
web100_agent* agentarg, Options* optionsarg) {
-
web100_var *LimRwin, *yar;
u_int32_t limrwin_val;
char yuff[32];
@@ -442,7 +444,6 @@
web100_raw_write(LimRwin, connarg, &limrwin_val);
log_println(1, " --- Done");
}
-
}
}

=======================================
--- /trunk/src/testoptions.h Mon Nov 5 10:30:55 2012
+++ /trunk/src/testoptions.h Thu Nov 15 13:33:44 2012
@@ -6,11 +6,10 @@
*

*/

-#ifndef _JS_TESTOPTIONS_H
-#define _JS_TESTOPTIONS_H
+#ifndef SRC_TESTOPTIONS_H_
+#define SRC_TESTOPTIONS_H_

-#include "web100srv.h"
-
+#include "./web100srv.h"

#define LISTENER_SOCKET_CREATE_FAILED -1
#define SOCKET_CONNECT_TIMEOUT -100
@@ -20,65 +19,68 @@


typedef struct testoptions {
- int multiple; // multiples tests enabled
- int mainport; // main port used for test
+ int multiple; // multiples tests enabled
+ int mainport; // main port used for test

- int midopt; // middlebox test to be perfomed?
- int midsockfd; // socket file desc for middlebox test
- int midsockport; // port used for middlebox test
+ int midopt; // middlebox test to be perfomed?
+ int midsockfd; // socket file desc for middlebox test
+ int midsockport; // port used for middlebox test

- int c2sopt; // C2S test to be perfomed?
- int c2ssockfd; // socket fd for C2S test
- int c2ssockport; // port used for C2S test
+ int c2sopt; // C2S test to be perfomed?
+ int c2ssockfd; // socket fd for C2S test
+ int c2ssockport; // port used for C2S test

- int s2copt; // S2C test to be perfomed?
- int s2csockfd; // socket fd for S2C test
- int s2csockport; // port used for S2C test
+ int s2copt; // S2C test to be perfomed?
+ int s2csockfd; // socket fd for S2C test
+ int s2csockport; // port used for S2C test

- // child pids
- pid_t child0;
- pid_t child1;
- pid_t child2;
+ // child pids
+ pid_t child0;
+ pid_t child1;
+ pid_t child2;

- int sfwopt; // Is firewall test to be performed?
- int State; // seems unused currently
+ int sfwopt; // Is firewall test to be performed?
+ int State; // seems unused currently

- int metaopt; // meta test to be perfomed?
+ int metaopt; // meta test to be perfomed?
} TestOptions;

// Snap log characteristics
typedef struct snapArgs {
- web100_snapshot* snap; // web_100 snapshot indicator
- web100_log* log; // web_100 log
- int delay; // periodicity, in ms, of collecting snap
+ web100_snapshot* snap; // web_100 snapshot indicator
+ web100_log* log; // web_100 log
+ int delay; // periodicity, in ms, of collecting snap
} SnapArgs;

int wait_sig;

int initialize_tests(int ctlsockfd, TestOptions* testOptions,
- char * test_suite, size_t test_suite_strlen);
+ char* test_suite, size_t test_suite_strlen);

void catch_s2c_alrm(int signo);

int test_sfw_srv(int ctlsockfd, web100_agent* agent, TestOptions* options,
- int conn_options);
+ int conn_options);
int test_meta_srv(int ctlsockfd, web100_agent* agent, TestOptions* options,
- int conn_options);
+ int conn_options);

int getCurrentTest();
void setCurrentTest(int testId);

-//void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg,
-void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg, CwndPeaks* peaks,
- char snaplogenabled, pthread_t *wrkrthreadidarg,
- char *metafilevariablename, char *metafilename, web100_connection* conn,
- web100_group* group);
+// void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg,
+void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg,
+ CwndPeaks* peaks, char snaplogenabled,
+ pthread_t *wrkrthreadidarg, char *metafilevariablename,
+ char *metafilename, web100_connection* conn,
+ web100_group* group);

-void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled, SnapArgs* snapArgs_ptr);
+void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled,
+ SnapArgs* snapArgs_ptr);

void setCwndlimit(web100_connection* connarg, web100_group* grouparg,
- web100_agent* agentarg, Options* optionsarg);
+ web100_agent* agentarg, Options* optionsarg);

int is_buffer_clogged(int nextseqtosend, int lastunackedseq);
void stop_packet_trace(int *monpipe_arr);
-#endif
+
+#endif // SRC_TESTOPTIONS_H_
=======================================
--- /trunk/src/tests_srv.h Tue Sep 25 06:49:57 2012
+++ /trunk/src/tests_srv.h Thu Nov 15 13:33:44 2012
@@ -6,24 +6,24 @@
* Oct 2011
*/

-#ifndef _JS_TESTS_SRV
-#define _JS_TESTS_SRV
+#ifndef SRC_TESTS_SRV_H_
+#define SRC_TESTS_SRV_H_

-#include "testoptions.h"
+#include "./testoptions.h"

int test_c2s(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
- int conn_options, double* c2sspd, int set_buff, int window,
- int autotune, char* device, Options* options, int record_reverse,
- int count_vars, char spds[4][256], int* spd_index);
+ int conn_options, double* c2sspd, int set_buff, int window,
+ int autotune, char* device, Options* options, int record_reverse,
+ int count_vars, char spds[4][256], int* spd_index);

// S2C test
int test_s2c(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
- int conn_options, double* s2cspd, int set_buff, int window,
- int autotune, char* device, Options* options, char
spds[4][256],
- int* spd_index, int count_vars, CwndPeaks* peaks);
+ int conn_options, double* s2cspd, int set_buff, int window,
+ int autotune, char* device, Options* options, char spds[4][256],
+ int* spd_index, int count_vars, CwndPeaks* peaks);

// the middlebox test
int test_mid(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
- int conn_options, double* s2c2spd);
+ int conn_options, double* s2c2spd);

-#endif
+#endif // SRC_TESTS_SRV_H_
=======================================
--- /trunk/src/tr-mkmap.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/tr-mkmap.c Thu Nov 15 13:33:44 2012
@@ -37,10 +37,10 @@
#include <netdb.h>
#include <getopt.h>

-#include "tr-tree.h"
-#include "usage.h"
-#include "logging.h"
-#include "strlutils.h"
+#include "./tr-tree.h"
+#include "./usage.h"
+#include "./logging.h"
+#include "./strlutils.h"

struct tr_tree *tr_root, *tr_cur;
char* DefaultTree = NULL;
@@ -57,9 +57,9 @@
'p' }, { "debug", 0, 0, 'd' }, { "version", 0, 0, 'v' }, { "dflttree",
1, 0, 301 },
#ifdef AF_INET6
- { "dflttree6", 1, 0, 302},
- { "ipv4", 0, 0, '4'},
- { "ipv6", 0, 0, '6'},
+ { "dflttree6", 1, 0, 302},
+ { "ipv4", 0, 0, '4'},
+ { "ipv6", 0, 0, '6'},
#endif
{ 0, 0, 0, 0 } };

@@ -90,9 +90,7 @@
}
}
#ifdef AF_INET6
- void
-build_tree6(struct tr_tree6 *tmp, struct tr_tree6 *new)
-{
+void build_tree6(struct tr_tree6 *tmp, struct tr_tree6 *new) {
if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) == 0) {
return;
}
@@ -100,8 +98,7 @@
if (tmp->left == NULL) {
tmp->left = new;
return;
- }
- else {
+ } else {
build_tree6(tmp->left, new);
return;
}
@@ -110,8 +107,7 @@
if (tmp->right == NULL) {
tmp->right = new;
return;
- }
- else {
+ } else {
build_tree6(tmp->right, new);
return;
}
@@ -166,9 +162,7 @@
return (ip_addr);
}
#ifdef AF_INET6
- int
-get_addr6(uint32_t dst_addr[4], char *tmpbuff)
-{
+int get_addr6(uint32_t dst_addr[4], char *tmpbuff) {
char *tmpstr;
int i;
struct sockaddr_in6 address;
@@ -203,8 +197,7 @@
tmpstr = strchr(tmpbuff, '(');
tmpstr++;
tmpbuff = strtok(tmpstr, ")");
- }
- else {
+ } else {
tmpstr = strchr(tmpbuff, ':');
while (tmpstr[0] != ' ') {
if (tmpstr == tmpbuff)
@@ -242,9 +235,7 @@
compare_tree(tmp->right, ip_addr);
}
#ifdef AF_INET6
- void
-compare_tree6(struct tr_tree6 *tmp, uint32_t ip_addr[4])
-{
+void compare_tree6(struct tr_tree6 *tmp, uint32_t ip_addr[4]) {
if (memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) == 0) {
found_node = 1;
tr_cur6 = tmp;
@@ -255,10 +246,12 @@
tr_cur6 = tmp;
return;
}
- if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) > 0) && (found_node == 0)) {
+ if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) > 0) &&
+ (found_node == 0)) {
compare_tree6(tmp->left, ip_addr);
}
- if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) < 0) && (found_node == 0)) {
+ if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) < 0) &&
+ (found_node == 0)) {
compare_tree6(tmp->right, ip_addr);
}
}
@@ -283,12 +276,10 @@
}
}
#ifdef AF_INET6
- void
-save_tree6(struct tr_tree6 *cur, FILE *fp)
-{
+void save_tree6(struct tr_tree6 *cur, FILE *fp) {
int i;

- for (i=0; i<cur->branches; i++) {
+ for (i = 0; i < cur->branches; i++) {
if (i == 0)
fwrite(cur, sizeof(struct tr_tree6), 1, fp);
save_tree6(&*cur->branch[i], fp);
@@ -310,9 +301,9 @@
for (i = 0; i < tmp->branches; i++) {
new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
memset(&*new, 0, sizeof(struct tr_tree));
- if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0) {
return;
- else {
+ } else {
for (j = 0; j < 25; j++)
new->branch[j] = NULL;
}
@@ -324,26 +315,24 @@
}
}
#ifdef AF_INET6
- void
-restore_tree26(struct tr_tree6 *tmp, FILE *fp)
-{
+void restore_tree26(struct tr_tree6 *tmp, FILE *fp) {
struct tr_tree6 *new;
int i, j;

- for (i=0; i<tmp->branches; i++) {
+ for (i = 0; i < tmp->branches; i++) {
new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
memset(&*new, 0, sizeof(struct tr_tree6));
- if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0) {
return;
- else {
- for (j=0; j<25; j++)
+ } else {
+ for (j = 0; j < 25; j++)
new->branch[j] = NULL;
}
tmp->branch[i] = new;
if (new->branches == 0) {
continue;
}
- restore_tree6( &*tmp->branch[i], fp);
+ restore_tree6(&*tmp->branch[i], fp);
}
}
#endif
@@ -355,12 +344,12 @@
static int i;
int j;

- if (i == 0)
+ if (i == 0) {
printf(
"Root node is [%u.%u.%u.%u]\n",
(cur->ip_addr & 0xff), ((cur->ip_addr >> 8) & 0xff),
((cur->ip_addr >> 16) & 0xff), (cur->ip_addr >> 24));
- else {
+ } else {
printf("Leaf %d node [%u.%u.%u.%u]\n", i,
(cur->ip_addr & 0xff), ((cur->ip_addr >> 8) &0xff),
((cur->ip_addr >> 16) & 0xff), ((cur->ip_addr >> 24) & 0xff));
@@ -372,9 +361,7 @@
}
}
#ifdef AF_INET6
- void
-print_tree6(struct tr_tree6 *cur)
-{
+void print_tree6(struct tr_tree6 *cur) {
static int i;
int j;
char nodename[200];
@@ -383,12 +370,11 @@
if (i == 0) {
inet_ntop(AF_INET6, cur->ip_addr, nodename, nnlen);
printf("Root node is [%s]\n", nodename);
- }
- else {
+ } else {
inet_ntop(AF_INET6, cur->ip_addr, nodename, nnlen);
printf("Leaf %d node [%s]\n", i, nodename);
}
- for (j=0; j<cur->branches; j++) {
+ for (j = 0; j < cur->branches; j++) {
i++;
print_tree6(&*cur->branch[j]);
i--;
@@ -475,9 +461,7 @@
fclose(fp);
}
#ifdef AF_INET6
- void
-build6(char* inputfile)
-{
+void build6(char* inputfile) {
struct tr_tree6 *root, *current, *new;
int i;
uint32_t ip_addr[4];
@@ -496,7 +480,7 @@

if (fp == NULL) {
printf("Error: Default tree6 input file '%s' missing!\n", inputfile);
- exit (-5);
+ exit(-5);
}
while ((fgets(buff, 256, fp)) != NULL) {
tmpbuff = strtok(buff, "\n");
@@ -508,7 +492,7 @@
new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
if (new == NULL) {
printf("Error: malloc failed, out of memory\n");
- exit (-10);
+ exit(-10);
}
memset(&*new, 0, sizeof(struct tr_tree6));
memcpy(new->ip_addr, ip_addr, sizeof(new->ip_addr));
@@ -518,14 +502,15 @@

if (root == NULL) {
root = new;
- }
- else {
- if ((current == root) && (memcmp(current->ip_addr, new->ip_addr, sizeof(new->ip_addr)) == 0)) {
+ } else {
+ if ((current == root) && (memcmp(current->ip_addr, new->ip_addr,
+ sizeof(new->ip_addr)) == 0)) {
free(new);
continue;
}
- for (i=0; i<current->branches; i++) {
- if (memcmp(current->branch[i]->ip_addr, new->ip_addr, sizeof(new->ip_addr)) == 0) {
+ for (i = 0; i < current->branches; i++) {
+ if (memcmp(current->branch[i]->ip_addr, new->ip_addr,
+ sizeof(new->ip_addr)) == 0) {
current = current->branch[i];
free(new);
new = NULL;
@@ -546,8 +531,9 @@
}
fp = fopen(DefaultTree6, "wb");
if (fp == NULL) {
- printf("Error: Can't write default tree6 '%s', exiting save_tree()\n", DefaultTree6);
- exit (-15);
+ printf("Error: Can't write default tree6 '%s', exiting save_tree()\n",
+ DefaultTree6);
+ exit(-15);
}
print_tree6(&*root);
printf("Finished printing default tree6 '%s'\n", DefaultTree6);
@@ -578,9 +564,9 @@
}
new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
memset(&*new, 0, sizeof(struct tr_tree));
- if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0) {
return;
- else {
+ } else {
for (i = 0; i < 25; i++)
new->branch[i] = NULL;
}
@@ -605,17 +591,16 @@
(IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
i++;
-
}

ip_addr = find_compare(IPlist, --i);

hp = gethostbyaddr((char *) &ip_addr, 4, AF_INET);
if (hp == NULL)
- //strncpy(c_name, "Unknown Host", 13);
+ // strncpy(c_name, "Unknown Host", 13);
strlcpy(c_name, "Unknown Host", sizeof(c_name));
else
- //strncpy(c_name, hp->h_name, strlen(hp->h_name));
+ // strncpy(c_name, hp->h_name, strlen(hp->h_name));
strlcpy(c_name, hp->h_name, sizeof(c_name));

if (found_node == 1) {
@@ -634,24 +619,20 @@
hp = (struct hostent *) gethostbyaddr((char *) &current->ip_addr, 4,
AF_INET);
if (hp == NULL)
- //strncpy(h_name, "Unknown Host", 13);
+ // strncpy(h_name, "Unknown Host", 13);
strlcpy(h_name, "Unknown Host", sizeof(h_name));
else
- //strncpy(h_name, hp->h_name, strlen(hp->h_name));
+ // strncpy(h_name, hp->h_name, strlen(hp->h_name));
strlcpy(h_name, hp->h_name, sizeof(h_name));

- printf(
- "\tThe eNDT server %s [%u.%u.%u.%u] is closest to host %s [%u.%u.%u.%u]\n",
- h_name,
- (current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
- ((current->ip_addr >> 16) & 0xff), (current->ip_addr >> 24),
- c_name, (ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
- ((ip_addr >> 16) & 0xff), (ip_addr >> 24));
+ printf("\tThe eNDT server %s [%u.%u.%u.%u] is closest to host %s "
+ "[%u.%u.%u.%u]\n", h_name, (current->ip_addr & 0xff),
+ ((current->ip_addr >> 8) & 0xff), ((current->ip_addr >> 16) & 0xff),
+ (current->ip_addr >> 24), c_name, (ip_addr & 0xff),
+ ((ip_addr >> 8) & 0xff), ((ip_addr >> 16) & 0xff), (ip_addr >> 24));
}
#ifdef AF_INET6
- void
-compare6(char* cmp_ip)
-{
+void compare6(char* cmp_ip) {
struct tr_tree6 *root, *current, *new;
int i;
uint32_t ip_addr[4], IPlist[64][4];
@@ -667,15 +648,16 @@
printf("\nComparing traceroute (IPv6)\n\n");
fp = fopen(DefaultTree6, "rb");
if (fp == NULL) {
- printf("Error: Can't read default tree6 '%s', exiting restore_tree()\n", DefaultTree6);
- exit (-15);
+ printf("Error: Can't read default tree6 '%s', exiting restore_tree()\n",
+ DefaultTree6);
+ exit(-15);
}
new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
memset(&*new, 0, sizeof(struct tr_tree6));
- if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0) {
return;
- else {
- for (i=0; i<25; i++)
+ } else {
+ for (i = 0; i < 25; i++)
new->branch[i] = NULL;
}
if (root == NULL) {
@@ -686,7 +668,7 @@
fp = fopen(cmp_ip, "r");
if (fp == NULL) {
printf("Error: Can't read comparison file '%s', exiting main()\n", cmp_ip);
- exit (-17);
+ exit(-17);
}
found_node = 0;
current = root;
@@ -718,7 +700,7 @@
return;
}
printf("Leaf Node found!\n");
- for (i=0; i<current->branches; i++) {
+ for (i = 0; i < current->branches; i++) {
if (current->branch[i]->branches == 0) {
current = current->branch[i];
break;
@@ -757,9 +739,9 @@
}
new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
memset(&*new, 0, sizeof(struct tr_tree));
- if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0) {
return;
- else {
+ } else {
for (i = 0; i < 25; i++)
new->branch[i] = NULL;
}
@@ -771,9 +753,7 @@
print_tree(&*root);
}
#ifdef AF_INET6
- void
-print6()
-{
+void print6() {
struct tr_tree6 *root = NULL, *new;
int i;
FILE *fp;
@@ -781,15 +761,16 @@
printf("\nPrinting Default Tree (IPv6)\n\n");
fp = fopen(DefaultTree6, "rb");
if (fp == NULL) {
- printf("Error: No default tree6 '%s' found, exiting compare6\n", DefaultTree6);
+ printf("Error: No default tree6 '%s' found, exiting compare6\n",
+ DefaultTree6);
return;
}
new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
memset(&*new, 0, sizeof(struct tr_tree6));
- if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0) {
return;
- else {
- for (i=0; i<25; i++)
+ } else {
+ for (i = 0; i < 25; i++)
new->branch[i] = NULL;
}
if (root == NULL) {
=======================================
--- /trunk/src/tr-tree.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/tr-tree.c Thu Nov 15 13:33:44 2012
@@ -32,8 +32,8 @@
#include <sys/socket.h>
#include <netdb.h>

-#include "tr-tree.h"
-#include "logging.h"
+#include "./tr-tree.h"
+#include "./logging.h"

struct tr_tree *tr_root, *tr_cur;
int found_node;
@@ -49,9 +49,9 @@
for (i = 0; i < tmp->branches; i++) {
new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
memset(&*new, 0, sizeof(struct tr_tree));
- if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0) {
return;
- else {
+ } else {
for (j = 0; j < 25; j++)
new->branch[j] = NULL;
}
@@ -64,7 +64,6 @@
}

u_int32_t find_compare(u_int32_t IPlist[], int cnt) {
-
struct tr_tree *root, *current, *new;
int i, j, k;
uint32_t srv_addr;
@@ -83,9 +82,9 @@
}
new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
memset(&*new, 0, sizeof(struct tr_tree));
- if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0) {
return 0;
- else {
+ } else {
for (i = 0; i < 25; i++)
new->branch[i] = NULL;
}
@@ -107,11 +106,11 @@
((current->ip_addr >> 16) & 0xff), (current->ip_addr >> 24));
if (current->ip_addr == IPlist[i])
continue;
- for (j=0; j<current->branches; j++) {
+ for (j = 0; j < current->branches; j++) {
log_print(5, "Comparing map node [%u.%u.%u.%u] ",
(current->branch[j]->ip_addr & 0xff),
((current->branch[j]->ip_addr >> 8) & 0xff),
- ((current->branch[j]->ip_addr >> 16) & 0xff),
+ ((current->branch[j]->ip_addr >> 16) & 0xff),
(current->branch[j]->ip_addr >> 24));
log_println(5, "to client node [%u.%u.%u.%u], cnt = %d",
(IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
@@ -120,7 +119,7 @@
if (current->branch[j]->ip_addr == IPlist[i]) {
current = current->branch[j];
found_node = 0;
- for (k=0; k<current->branches; k++) {
+ for (k = 0; k <current->branches; k++) {
if (current->branch[k]->branches == 0) {
srv_addr = current->branch[k]->ip_addr;
log_println(5, "srv_addr set to [%u.%u.%u.%u]",
@@ -135,7 +134,7 @@
}
if (found_node == -1)
break;
- }
+ }

if (current->ip_addr == IPlist[cnt]) {
srv_addr = IPlist[cnt];
@@ -148,9 +147,9 @@
log_println(6, "Broke out of compare loop, setting current pointer");
if (current->branches == 1) {
current = current->branch[0];
- if (current->branches == 0)
+ if (current->branches == 0) {
found_node = 2;
- else {
+ } else {
found_node = 4;
current = root;
}
=======================================
--- /trunk/src/tr-tree.h Mon Nov 5 10:30:55 2012
+++ /trunk/src/tr-tree.h Thu Nov 15 13:33:44 2012
@@ -6,18 +6,18 @@
*

*/

-#ifndef _JS_TR_TREE_H
-#define _JS_TR_TREE_H
+#ifndef SRC_TR_TREE_H_
+#define SRC_TR_TREE_H_

#define HOSTNAME_STRLEN 256

struct tr_tree {
- uint32_t ip_addr; /* IP addr of current node */
- int branches;
- char hostname[HOSTNAME_STRLEN]; /* Hostname placeholder */
- struct tr_tree *branch[25]; /* pointer to child */
- struct tr_tree *left; /* pointer to child */
- struct tr_tree *right; /* pointer to child */
+ uint32_t ip_addr; /* IP addr of current node */
+ int branches;
+ char hostname[HOSTNAME_STRLEN]; /* Hostname placeholder */
+ struct tr_tree *branch[25]; /* pointer to child */
+ struct tr_tree *left; /* pointer to child */
+ struct tr_tree *right; /* pointer to child */
};

#define DFLT_TREE "Default.tree" /* file containing default tree */
@@ -28,19 +28,20 @@
#ifdef AF_INET6

struct tr_tree6 {
- uint32_t ip_addr[4]; /* IP addr of the current node */
- int branches;
- char hostname[HOSTNAME_STRLEN]; /* Hostname placeholder */
- struct tr_tree6 *branch[25]; /* pointer to child */
- struct tr_tree6 *left; /* pointer to child */
- struct tr_tree6 *right; /* pointer to child */
+ uint32_t ip_addr[4]; /* IP addr of the current node */
+ int branches;
+ char hostname[HOSTNAME_STRLEN]; /* Hostname placeholder */
+ struct tr_tree6 *branch[25]; /* pointer to child */
+ struct tr_tree6 *left; /* pointer to child */
+ struct tr_tree6 *right; /* pointer to child */
};

-#define DFLT_TREE6 "Default.tree6" /* file containing default tree for IPv6 nodes */
+// file containing default tree for IPv6 nodes
+#define DFLT_TREE6 "Default.tree6"

void restore_tree6(struct tr_tree6 *tmp, FILE *fp);
int find_compare6(u_int32_t IPnode[4], u_int32_t IP6list[][4], int cnt);

#endif

-#endif
+#endif // SRC_TR_TREE_H_
=======================================
--- /trunk/src/tr-tree6.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/tr-tree6.c Thu Nov 15 13:33:44 2012
@@ -35,8 +35,8 @@
#include <netdb.h>
#include <arpa/inet.h>

-#include "tr-tree.h"
-#include "logging.h"
+#include "./tr-tree.h"
+#include "./logging.h"

#ifdef AF_INET6

@@ -47,33 +47,28 @@
/* Restore the default tree, stored by the save tree routine above.
* Once restored, the comparison can take place.
*/
- void
-restore_tree6(struct tr_tree6 *tmp, FILE *fp)
-{
+void restore_tree6(struct tr_tree6 *tmp, FILE *fp) {
struct tr_tree6 *new;
int i, j;

- for (i=0; i<tmp->branches; i++) {
+ for (i = 0; i < tmp->branches; i++) {
new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
memset(&*new, 0, sizeof(struct tr_tree6));
- if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0) {
return;
- else {
- for (j=0; j<25; j++)
+ } else {
+ for (j = 0; j < 25; j++)
new->branch[j] = NULL;
}
tmp->branch[i] = new;
if (new->branches == 0) {
continue;
}
- restore_tree6( &*tmp->branch[i], fp);
+ restore_tree6(&*tmp->branch[i], fp);
}
}

- int
-find_compare6(u_int32_t IPnode[4], u_int32_t IP6list[][4], int cnt)
-{
-
+int find_compare6(u_int32_t IPnode[4], u_int32_t IP6list[][4], int cnt) {
struct tr_tree6 *root, *current, *new;
int i, j, k, fnode = 0;
char h_name[256], c_name[256];
@@ -92,10 +87,10 @@
}
new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
memset(&*new, 0, sizeof(struct tr_tree6));
- if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+ if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0) {
return 0;
- else {
- for (i=0; i<25; i++)
+ } else {
+ for (i = 0; i < 25; i++)
new->branch[i] = NULL;
}
if (root == NULL) {
@@ -106,7 +101,7 @@
found_node = 0;
current = root;
log_println(6, "route to client contains %d hops", cnt);
- for (i=0; i<=cnt; i++) {
+ for (i = 0; i <= cnt; i++) {
if (get_debuglvl() > 5) {
memset(nodename, 0, 200);
nnlen = 199;
@@ -120,11 +115,12 @@
if (memcmp(IP6list[i], current->ip_addr, sizeof(current->ip_addr)) == 0) {
continue;
}
- for (j=0; j<current->branches; j++) {
+ for (j = 0; j < current->branches; j++) {
if (get_debuglvl() > 4) {
memset(nodename, 0, 200);
nnlen = 199;
- inet_ntop(AF_INET6, (void *) current->branch[j]->ip_addr, nodename, nnlen);
+ inet_ntop(AF_INET6, (void *) current->branch[j]->ip_addr, nodename,
+ nnlen);
log_print(5, "Comparing map node [%s] ", nodename);
memset(nodename, 0, 200);
nnlen = 199;
@@ -132,10 +128,11 @@
log_println(5, "to client node [%s], cnt = %d", nodename, i);
}

- if (memcmp(current->branch[j]->ip_addr, IP6list[i], sizeof(IP6list[i])) == 0) {
+ if (memcmp(current->branch[j]->ip_addr, IP6list[i],
+ sizeof(IP6list[i])) == 0) {
current = current->branch[j];
found_node = 0;
- for (k=0; k<current->branches; k++) {
+ for (k = 0; k < current->branches; k++) {
if (current->branch[k]->branches == 0) {
memcpy(IPnode, current->branch[k]->ip_addr, 16);
if (get_debuglvl() > 4) {
@@ -169,14 +166,13 @@
log_println(6, "Broke out of compare loop, setting current pointer");
if (current->branches == 1) {
current = current->branch[0];
- if (current->branches == 0)
+ if (current->branches == 0) {
found_node = 2;
- else {
+ } else {
found_node = 4;
current = root;
}
- }
- else {
+ } else {
found_node = 3;
current = root;
}
@@ -193,7 +189,8 @@
memset(nodename, 0, 200);
nnlen = 199;
inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
- log_println(5, "Router %s [%s] is last common router in the path!", c_name, nodename);
+ log_println(5, "Router %s [%s] is last common router in the path!",
+ c_name, nodename);
}
return 1;
}
=======================================
--- /trunk/src/troute.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/troute.c Thu Nov 15 13:33:44 2012
@@ -47,18 +47,6 @@
* SUCH DAMAGE.
*/

-#if 0
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)troute.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#endif
-
#include <sys/param.h>
#include <sys/time.h>
#include <sys/file.h>
@@ -79,7 +67,7 @@
#include <netdb.h>
#include <stdio.h>

-#include "logging.h"
+#include "./logging.h"

#define MAXPACKET 65535 /* max ip packet size */
#ifndef MAXHOSTNAMELEN
@@ -249,7 +237,8 @@
}

int wait_for_reply(sock, from)
- int sock;struct sockaddr_in *from; {
+ int sock;
+ struct sockaddr_in *from; {
fd_set fds;
struct timeval wait;
int cc = 0;
@@ -316,7 +305,10 @@
}

int packet_ok(buf, cc, from, seq)
- u_char *buf;int cc;struct sockaddr_in *from;int seq; {
+ u_char *buf;
+ int cc;
+ struct sockaddr_in *from;
+ int seq; {
register struct icmp *icp;
u_char type, code;
int hlen;
@@ -334,7 +326,8 @@
#else
icp = (struct icmp *)buf;
#endif /* ARCHAIC */
- type = icp->icmp_type; code = icp->icmp_code;
+ type = icp->icmp_type;
+ code = icp->icmp_code;
if ((type == ICMP_TIMXCEED && code == ICMP_TIMXCEED_INTRANS) ||
type == ICMP_UNREACH) {
struct ip *hip;
@@ -398,7 +391,7 @@
* Subtract 2 timeval structs: out = out - in.
* Out is assumed to be >= in.
*/
-void tvsub (out, in)
+void tvsub(out, in)
register struct timeval *out, *in; {
if ((out->tv_usec -= in->tv_usec) < 0) {
out->tv_sec--;
=======================================
--- /trunk/src/troute.h Fri Aug 18 03:16:24 2006
+++ /trunk/src/troute.h Thu Nov 15 13:33:44 2012
@@ -5,10 +5,10 @@
*

*/

-#ifndef _JS_TROUTE_H
-#define _JS_TROUTE_H
+#ifndef SRC_TROUTE_H_
+#define SRC_TROUTE_H_

void find_route(u_int32_t destIP, u_int32_t IPlist[], int max_ttl);
void find_route6(char* dst, u_int32_t IPlist[][4], int max_ttl);

-#endif
+#endif // SRC_TROUTE_H_
=======================================
--- /trunk/src/troute6.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/troute6.c Thu Nov 15 13:33:44 2012
@@ -68,8 +68,8 @@
#if 0
#ifndef lint
char copyright[] =
-"@(#) Copyright (c) 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+"@(#) Copyright (c) 1990, 1993\n"
+ "The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#endif

@@ -273,7 +273,7 @@
#include <string.h>
#include <unistd.h>

-#include "logging.h"
+#include "./logging.h"

#define MAXPACKET 65535
#ifndef MAXHOSTNAMELEN
@@ -292,34 +292,34 @@
#define Fprintf (void)fprintf
#define Printf (void)printf

- /* taken from linux/ipv6.h */
+/* taken from linux/ipv6.h */

- /*
- * IPv6 fixed header
- *
- * BEWARE, it is incorrect. The first 4 bits of flow_lbl
- * are glued to priority now, forming "class".
- */
+/*
+* IPv6 fixed header
+*
+* BEWARE, it is incorrect. The first 4 bits of flow_lbl
+* are glued to priority now, forming "class".
+*/

- struct ipv6hdr {
+struct ipv6hdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
- __extension__ __u8 priority:4,
- version:4;
+ __extension__ __u8 priority:4,
+ version:4;
#elif defined(__BIG_ENDIAN_BITFIELD)
- __extension__ __u8 version:4,
- priority:4;
+ __extension__ __u8 version:4,
+ priority:4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
- __extension__ __u8 flow_lbl[3];
+ __extension__ __u8 flow_lbl[3];

- __extension__ __u16 payload_len;
- __extension__ __u8 nexthdr;
- __extension__ __u8 hop_limit;
+ __extension__ __u16 payload_len;
+ __extension__ __u8 nexthdr;
+ __extension__ __u8 hop_limit;

- struct in6_addr saddr;
- struct in6_addr daddr;
- };
+ struct in6_addr saddr;
+ struct in6_addr daddr;
+};

/* --- */

@@ -329,8 +329,8 @@
int packet_ok6(u_char *buf, int cc, struct sockaddr_in6 *from, int seq,
struct timeval *);
void send_probe6(int seq, int ttl);
-double deltaT (struct timeval *, struct timeval *);
-void tvsub (struct timeval *, struct timeval *);
+double deltaT(struct timeval *, struct timeval *);
+void tvsub(struct timeval *, struct timeval *);
void usage(void);

int icmp_sock; /* receive (icmp) socket file descriptor */
@@ -353,8 +353,7 @@
int waittime6 = 5; /* time to wait for response (in seconds) */
int nflag; /* print addresses numerically */

-struct pkt_format
-{
+struct pkt_format {
__u32 ident;
__u32 seq;
struct timeval tv;
@@ -363,9 +362,7 @@
char *sendbuff;
int datalen = sizeof(struct pkt_format);

- void
-find_route6(char* dst, u_int32_t IPlist[][4], int max_ttl)
-{
+void find_route6(char* dst, u_int32_t IPlist[][4], int max_ttl) {
extern char *optarg;
extern int optind;
struct hostent *hp;
@@ -455,11 +452,14 @@
return;
}
if (device) {
- if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)+1) == -1)
+ if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device,
+ strlen(device)+1) == -1) {
perror("WARNING: interface is ignored");
+ }
}
firsthop.sin6_port = htons(1025);
- if (connect(probe_fd, (struct sockaddr*)&firsthop, sizeof(firsthop)) == -1) {
+ if (connect(probe_fd, (struct sockaddr*)&firsthop,
+ sizeof(firsthop)) == -1) {
perror("connect");
return;
}
@@ -473,24 +473,23 @@
} else {
(void) bzero((char *)&saddr, sizeof(saddr));
saddr.sin6_family = AF_INET6;
- if (inet_pton(AF_INET6, source6, &saddr.sin6_addr) < 0)
- {
+ if (inet_pton(AF_INET6, source6, &saddr.sin6_addr) < 0) {
Printf("traceroute: unknown addr %s\n", source6);
return;
}
}

if (bind(sndsock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
- perror ("traceroute: bind sending socket");
+ perror("traceroute: bind sending socket");
return;
}
if (bind(icmp_sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
- perror ("traceroute: bind icmp6 socket");
+ perror("traceroute: bind icmp6 socket");
return;
}

for (ttl = 1; ttl <= max_ttl; ++ttl) {
- struct in6_addr lastaddr = { { {0,}}};
+ struct in6_addr lastaddr = { { {0, }}};
int got_there = 0;
int unreachable = 0;

@@ -521,7 +520,7 @@
inet_ntop(AF_INET6, &from.sin6_addr, tmp, sizeof(tmp));
log_println(5, "Probe %d resulted in reply from [%s]", probe, tmp);
}
- switch(i - 1) {
+ switch (i - 1) {
case ICMPV6_PORT_UNREACH:
++got_there;
break;
@@ -541,8 +540,9 @@
break;
}
break;
- } else
+ } else {
reset_timer = 0;
+ }
}
if (cc <= 0)
Printf(" *");
@@ -562,7 +562,7 @@
fd_set fds;
static struct timeval wait;
int cc = 0;
- socklen_t fromlen = sizeof (*from);
+ socklen_t fromlen = sizeof(*from);

FD_ZERO(&fds);
FD_SET(sock, &fds);
@@ -584,15 +584,14 @@
}

if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) {
- cc=recvfrom(icmp_sock, (char *)packet, sizeof(packet), 0,
- (struct sockaddr *)from, &fromlen);
+ cc = recvfrom(icmp_sock, (char *)packet, sizeof(packet), 0,
+ (struct sockaddr *)from, &fromlen);
}

return(cc);
}

-void send_probe6(int seq, int ttl)
-{
+void send_probe6(int seq, int ttl) {
struct pkt_format *pkt = (struct pkt_format *) sendbuff;
int i;

@@ -601,8 +600,7 @@
gettimeofday(&pkt->tv, &tz);

i = setsockopt(sndsock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
- if (i < 0)
- {
+ if (i < 0) {
perror("setsockopt");
return;
}
@@ -610,10 +608,10 @@
do {
i = sendto(sndsock, sendbuff, datalen, 0,
(struct sockaddr *)&whereto, sizeof(whereto));
- }while (i<0 && errno == ECONNREFUSED);
+ } while (i < 0 && errno == ECONNREFUSED);

if (i < 0 || i != datalen) {
- if (i<0)
+ if (i < 0)
perror("sendto");
}
}
@@ -621,8 +619,7 @@
/*
* Convert an ICMP "type" field to a printable string.
*/
-char * pr_type(unsigned char t)
-{
+char * pr_type(unsigned char t) {
static char *ttab1[] = {
"Error",
"Destination Unreachable",
@@ -639,14 +636,12 @@
"Membership Reduction",
};

- if (t < 5)
- {
+ if (t < 5) {
return (ttab1[t]);
}

unsigned char newt = t - 128;
- if (newt < 5)
- {
+ if (newt < 5) {
return (ttab2[newt]);
}

@@ -654,8 +649,7 @@
}

int packet_ok6(u_char *buf, int cc, struct sockaddr_in6 *from, int seq,
- struct timeval *tv)
-{
+ struct timeval *tv) {
struct icmp6hdr *icp;
u_char type, code;

@@ -665,8 +659,7 @@
code = icp->icmp6_code;

if ((type == ICMPV6_TIME_EXCEED && code == ICMPV6_EXC_HOPLIMIT) ||
- type == ICMPV6_DEST_UNREACH)
- {
+ type == ICMPV6_DEST_UNREACH) {
struct ipv6hdr *hip;
struct udphdr *up;
int nexthdr;
@@ -679,20 +672,17 @@
nexthdr = *(unsigned char*)up;
up++;
}
- if (nexthdr == IPPROTO_UDP)
- {
+ if (nexthdr == IPPROTO_UDP) {
struct pkt_format *pkt;

pkt = (struct pkt_format *) (up + 1);

if (ntohl(pkt->ident) == ident &&
- ntohl(pkt->seq) == seq)
- {
+ ntohl(pkt->seq) == seq) {
*tv = pkt->tv;
return (type == ICMPV6_TIME_EXCEED? -1 : code+1);
}
}
-
}

if (verbose) {
=======================================
--- /trunk/src/usage.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/usage.c Thu Nov 15 13:33:44 2012
@@ -36,59 +36,37 @@
assert(info != NULL);
printf("\n%s\n\n\n", info);
printf(" Basic options:\n\n");
- printf(
- " -a, --adminview - generate administrator view html page\n");
+ printf(" -a, --adminview - generate administrator view html page\n");
printf(" -d, --debug - print additional diagnostic messages\n");
- printf(
- " Note: add multiple d's (-ddd) for more details\n");
+ printf(" Note: add multiple d's (-ddd) for more details\n");
printf(" -h, --help - print help message (this message)\n");
printf(" -m, --multiple - select single or multi-test mode\n");
printf(" -o, --old - use old Duplex Mismatch heuristic\n");
- printf(
- " -q, --disable-queue - disable FIFO queuing of client requests\n");
- printf(
- " -r, --record - record client to server Web100 variables\n");
- printf(
- " -s, --syslog - use the syslog() to log some information\n");
+ printf(" -q, --disable-queue - disable FIFO queuing of client requests\n");
+ printf(" -r, --record - record client to server Web100 variables\n");
+ printf(" -s, --syslog - use the syslog() to log some information\n");
printf(" -t, --tcpdump - write tcpdump formatted file to disk\n");
printf(" -v, --version - print version number\n");
- printf(
- " -x, --max_clients - maximum numbers of clients permited in FIFO queue (default=50)\n");
- printf(
- " -z, --gzip - disable compression of tcptrace, snaplog, and cputime files\n\n");
+ printf(" -x, --max_clients - maximum numbers of clients permited in FIFO queue (default=50)\n");
+ printf(" -z, --gzip - disable compression of tcptrace, snaplog, and cputime files\n\n");
printf(" Configuration:\n\n");
- printf(
- " -c, --config #filename - specify the name of the file with configuration\n");
- printf(
- " -b, --buffer #size - set TCP send/recv buffers to user value\n");
- printf(
- " -f, --file variable_FN - specify alternate 'web100_variables' file\n");
- printf(
- " -i, --interface device - specify network interface (libpcap device)\n");
- printf(
- " -l, --log Log_FN - specify alternate 'web100srv.log' file\n");
- printf(
- " -u, --protolog_dir DIR - specify the base directory for protocol validation logs \n");
+ printf(" -c, --config #filename - specify the name of the file with configuration\n");
+ printf(" -b, --buffer #size - set TCP send/recv buffers to user value\n");
+ printf(" -f, --file variable_FN - specify alternate 'web100_variables' file\n");
+ printf(" -i, --interface device - specify network interface (libpcap device)\n");
+ printf(" -l, --log Log_FN - specify alternate 'web100srv.log' file\n");
+ printf(" -u, --protolog_dir DIR - specify the base directory for protocol validation logs \n");
printf(" --enableprotolog - enable protocol logging \n");
- printf(
- " -p, --port #port - specify primary port number (default 3001)\n");
- printf(
- " --midport #port - specify Middlebox test port number (default 3003)\n");
- printf(
- " --c2sport #port - specify C2S throughput test port number (default 3002)\n");
- printf(
- " --s2cport #port - specify S2C throughput test port number (default 3003)\n");
- printf(
- " -T, --refresh #time - specify the refresh time of the admin page\n");
- printf(
- " --mrange #range - set the port range used in multi-test mode\n");
+ printf(" -p, --port #port - specify primary port number (default 3001)\n");
+ printf(" --midport #port - specify Middlebox test port number (default 3003)\n");
+ printf(" --c2sport #port - specify C2S throughput test port number (default 3002)\n");
+ printf(" --s2cport #port - specify S2C throughput test port number (default 3003)\n");
+ printf(" -T, --refresh #time - specify the refresh time of the admin page\n");
+ printf(" --mrange #range - set the port range used in multi-test mode\n");
printf(" Note: this enables multi-test mode\n");
- printf(
- " -A, --adminfile #FN - specify alternate filename for Admin web page\n");
- printf(
- " Note: this doesn't enable 'adminview'\n");
- printf(
- " -L, --log_dir DIR - specify the base directory for snaplog and tcpdump files\n");
+ printf(" -A, --adminfile #FN - specify alternate filename for Admin web page\n");
+ printf(" Note: this doesn't enable 'adminview'\n");
+ printf(" -L, --log_dir DIR - specify the base directory for snaplog and tcpdump files\n");
printf(" (default %s/serverdata)\n", BASEDIR);
printf(" -S, --logfacility #F - specify syslog facility name\n");
printf(" Note: this doesn't enable 'syslog'\n\n");
@@ -131,12 +109,10 @@
printf(" -n, --name #name - specify name of the server\n");
printf(" -p, --port #port - specify port server is listening on\n");
printf(" -d, --debug - Increase debug level details\n");
- printf(
- " Note: add multiple d's (-ddd) for more details\n");
+ printf(" Note: add multiple d's (-ddd) for more details\n");
printf(" -h, --help - print this help message\n");
printf(" -l, --msglvl - increase message level details\n");
- printf(
- " --web100variables - print the information about each Web100 variable\n");
+ printf(" --web100variables - print the information about each Web100 variable\n");
printf(" -v, --version - print version number\n\n");
printf(" Configuration:\n\n");
printf(" -b, --buffer #size - set send/receive buffer to value\n");
@@ -165,13 +141,11 @@
printf("\n%s\n\n\n", info);
printf(" Basic options:\n\n");
printf(" -d, --debug - increment debugging mode\n");
- printf(
- " Note: add multiple d's (-ddd) for more details\n");
+ printf(" Note: add multiple d's (-ddd) for more details\n");
printf(" -h, --help - print this help message\n");
printf(" -F, --federated - operate in Federated mode\n");
printf(" -f, --file FN - add the file to the allowed list\n");
- printf(
- " -s, --syslog - use the syslog() to log some information\n");
+ printf(" -s, --syslog - use the syslog() to log some information\n");
printf(" -v, --version - print version number\n\n");
printf(" Configuration:\n\n");
printf(" -l, --alog alog_FN - specify the access log filename\n");
@@ -179,12 +153,9 @@
printf(" -b, --basedir path - set the basedir for the documents\n");
printf(" -S, --logfacility #F - specify syslog facility name\n");
printf(" Note: this doesn't enable 'syslog'\n");
- printf(
- " -p, --port #port - specify the port number (default is 7123)\n");
- printf(
- " -t, --ttl #amount - specify maximum number of hops in path (default is 10)\n");
- printf(
- " --dflttree fn - specify alternate 'Default.tree' file\n");
+ printf(" -p, --port #port - specify the port number (default is 7123)\n");
+ printf(" -t, --ttl #amount - specify maximum number of hops in path (default is 10)\n");
+ printf(" --dflttree fn - specify alternate 'Default.tree' file\n");
#ifdef AF_INET6
printf(" --dflttree6 fn - specify alternate 'Default.tree6' file\n\n");
printf(" IP family:\n\n");
@@ -207,8 +178,7 @@
printf("\n%s\n\n\n", info);
printf(" Basic options:\n\n");
printf(" -d, --debug - increment debugging mode\n");
- printf(
- " Note: add multiple d's (-ddd) for more details\n");
+ printf(" Note: add multiple d's (-ddd) for more details\n");
printf(" -n, --nodns - disable resolving DNS names\n");
printf(" -h, --help - print this help message\n");
printf(" -l, --log log_FN - specify the file with the logs\n");
@@ -228,19 +198,15 @@
printf(" Basic options:\n\n");
printf(" -b, --build - build a new default tree\n");
printf(" -c, --compare fn - compare new traceroute to tree\n");
- printf(
- " Note: -b and -c are mutually exclusive\n");
+ printf(" Note: -b and -c are mutually exclusive\n");
printf(" -f, --file fn - specify the name of the input file\n");
printf(" -h, --help - print this help message\n");
- printf(
- " -p, --print - [default] print out the current traceroute map\n");
+ printf(" -p, --print - [default] print out the current traceroute map\n");
printf(" -d, --debug - increment debugging mode\n");
- printf(
- " Note: add multiple d's (-ddd) for more details\n");
+ printf(" Note: add multiple d's (-ddd) for more details\n");
printf(" -v, --version - print version number\n\n");
printf(" Configuration:\n\n");
- printf(
- " --dflttree fn - specify alternate 'Default.tree' file\n");
+ printf(" --dflttree fn - specify alternate 'Default.tree' file\n");
#ifdef AF_INET6
printf(" --dflttree6 fn - specify alternate 'Default.tree6' file\n\n");
printf(" IP family:\n\n");
@@ -262,20 +228,14 @@
assert(info != NULL);
printf("\n%s\n\n\n", info);
printf(" Basic options:\n\n");
- printf(
- " -c, --count #amount - specify how many packets will be viewed\n");
+ printf(" -c, --count #amount - specify how many packets will be viewed\n");
printf(" -d, --debug - increment debugging mode\n");
- printf(
- " Note: add multiple d's (-ddd) for more details\n");
- printf(
- " -f, --file fn - specify the name of the file to offline trace\n");
+ printf(" Note: add multiple d's (-ddd) for more details\n");
+ printf(" -f, --file fn - specify the name of the file to offline trace\n");
printf(" -h, --help - print this help message\n");
- printf(
- " -i, --interface device - specify network interface (libpcap device)\n");
- printf(
- " --c2sport #port - specify C2S throughput test port number (default 3002)\n");
- printf(
- " --s2cport #port - specify S2C throughput test port number (default 3003)\n");
+ printf(" -i, --interface device - specify network interface (libpcap device)\n");
+ printf(" --c2sport #port - specify C2S throughput test port number (default 3002)\n");
+ printf(" --s2cport #port - specify S2C throughput test port number (default 3003)\n");
printf(" -v, --version - print version number\n\n");

exit(0);
@@ -293,12 +253,9 @@
printf("Usage: %s [options] filelist\n", argv0);
printf("This program generates xplot graphs from Web100 variables\n\n");
printf(" Basic options:\n\n");
- printf(
- " -b, --both - generate plot of both CurCwnd and CurRwinRcvd\n");
- printf(
- " -m, --multi varlist - a comma separated list of Web100 vars to plot\n");
- printf(
- " -t, --text - print variable values instead of generating plots\n");
+ printf(" -b, --both - generate plot of both CurCwnd and CurRwinRcvd\n");
+ printf(" -m, --multi varlist - a comma separated list of Web100 vars to plot\n");
+ printf(" -t, --text - print variable values instead of generating plots\n");
printf(" -C, --CurCwnd - generate CurCwnd plot\n");
printf(" -R, --CurRwinRcvd - generate CurRwinRcvd plot\n");
printf(" -S, --throughput - generate throughput plot\n");
=======================================
--- /trunk/src/usage.h Sun Aug 19 03:26:07 2007
+++ /trunk/src/usage.h Thu Nov 15 13:33:44 2012
@@ -6,8 +6,8 @@
*

*/

-#ifndef _JS_USAGE_H
-#define _JS_USAGE_H
+#ifndef SRC_USAGE_H_
+#define SRC_USAGE_H_

void short_usage(char* prog, char* info);
void srv_long_usage(char* info);
@@ -18,4 +18,4 @@
void vt_long_usage(char* info);
void genplot_long_usage(char* info, char* argv0);

-#endif
+#endif // SRC_USAGE_H_
=======================================
--- /trunk/src/utils.c Thu Nov 15 13:33:19 2012
+++ /trunk/src/utils.c Thu Nov 15 13:33:44 2012
@@ -20,8 +20,8 @@
#include <sys/ioctl.h>
#include <errno.h>

-#include "utils.h"
-#include "strlutils.h"
+#include "./utils.h"
+#include "./strlutils.h"

/**
* Check if the string is a valid int number.
@@ -188,11 +188,11 @@
}
if (!is_whitespace) {
output_buf[j] = line[i];
- j++ ;
+ j++;
}
}
- output_buf[j] = '\0'; // null terminate
- //log_println(8,"Received=%s; len=%d; dest=%d; MSG=%s\n", line, line_size,
- // strlen(output_buf), output_buf);
+ output_buf[j] = '\0'; // null terminate
+ // log_println(8,"Received=%s; len=%d; dest=%d; MSG=%s\n", line, line_size,
+ // strlen(output_buf), output_buf);
return j - 1;
}
=======================================
--- /trunk/src/utils.h Mon Apr 30 13:46:39 2012
+++ /trunk/src/utils.h Thu Nov 15 13:33:44 2012
@@ -6,8 +6,8 @@
*

*/

-#ifndef _JS_UTILS_H
-#define _JS_UTILS_H
+#ifndef SRC_UTILS_H_
+#define SRC_UTILS_H_

int check_int(char* text, int* number);
int check_rint(char* text, int* number, int minVal, int maxVal);
@@ -17,9 +17,7 @@
int sndq_len(int fd);
void mysleep(double time);
int trim(char *line, int line_size,
- char * output_buf, int output_buf_size);
-
-#endif
+ char * output_buf, int output_buf_size);

// Numbers 1 and 65535 are used in mrange.c for determining "valid" ranges
// While the methods could be used for any "range" comparison,
@@ -64,8 +62,8 @@
#define POSSIBLE_BAD_CABLE 1

// generic system wide constants
-#define RETRY_COUNT 5 // retry counts
-//#define BUFFSIZE 8192 // Buffer size
+#define RETRY_COUNT 5 // retry counts
+// #define BUFFSIZE 8192 // Buffer size

// middlebox test default MSS
// Cleaner to move this to clt_tests.h if not for the name of "clt_tests.h".
@@ -91,4 +89,4 @@
#define DATA_RATE_10G_ETHERNET 9
#define DATA_RATE_RETRANSMISSIONS 10

-
+#endif // SRC_UTILS_H_
=======================================
***Additional files exist in this changeset.***


  • [ndt-dev] [ndt] r790 committed - Updated to google style., ndt, 11/15/2012

Archive powered by MHonArc 2.6.16.

Top of Page