ndt-dev - [ndt-dev] [ndt] r1048 committed - Merge branch Issue143 to solve Issue 143
Subject: NDT-DEV email list created
List archive
- From:
- To:
- Subject: [ndt-dev] [ndt] r1048 committed - Merge branch Issue143 to solve Issue 143
- Date: Tue, 15 Apr 2014 22:51:40 +0000
Revision: 1048
Author:
Date: Tue Apr 15 22:51:33 2014 UTC
Log: Merge branch Issue143 to solve Issue 143
http://code.google.com/p/ndt/source/detail?r=1048
Modified:
/trunk
/trunk/flash-client/src/Handshake.as
/trunk/flash-client/src/MessageType.as
/trunk/src/protocol.h
/trunk/src/test_s2c_srv.c
/trunk/src/testoptions.c
/trunk/src/testoptions.h
/trunk/src/web100srv.c
=======================================
--- /trunk/flash-client/src/Handshake.as Fri Feb 21 07:41:20 2014 UTC
+++ /trunk/flash-client/src/Handshake.as Tue Apr 15 22:51:33 2014 UTC
@@ -52,8 +52,12 @@
public function run():void {
var msgBody:ByteArray = new ByteArray();
+ var clientVersion:String = NDTConstants.CLIENT_VERSION;
+
msgBody.writeByte(_testsRequestByClient);
- _msg = new Message(MessageType.MSG_LOGIN, msgBody);
+ msgBody.writeMultiByte(clientVersion, "us-ascii");
+
+ _msg = new Message(MessageType.MSG_EXTENDED_LOGIN, msgBody);
if (!_msg.sendMessage(_ctlSocket)) {
failHandshake();
}
=======================================
--- /trunk/flash-client/src/MessageType.as Sun Feb 2 19:14:17 2014 UTC
+++ /trunk/flash-client/src/MessageType.as Tue Apr 15 22:51:33 2014 UTC
@@ -31,6 +31,7 @@
public static const MSG_RESULTS:int = 8;
public static const MSG_LOGOUT:int = 9;
public static const MSG_WAITING:int = 10;
+ public static const MSG_EXTENDED_LOGIN:int = 11;
}
}
=======================================
--- /trunk/src/protocol.h Fri Feb 21 16:32:03 2014 UTC
+++ /trunk/src/protocol.h Tue Apr 15 22:51:33 2014 UTC
@@ -23,6 +23,9 @@
#define MSG_RESULTS 8
#define MSG_LOGOUT 9
#define MSG_WAITING 10
+#define MSG_EXTENDED_LOGIN 11
+
+#define CS_VERSION_LENGTH_MAX 32
#define SRV_QUEUE_TEST_STARTS_NOW 0
#define SRV_QUEUE_TEST_STARTS_NOW_STR "0"
=======================================
--- /trunk/src/test_s2c_srv.c Mon Oct 14 13:20:21 2013 UTC
+++ /trunk/src/test_s2c_srv.c Tue Apr 15 22:51:33 2014 UTC
@@ -135,6 +135,8 @@
snapArgs.delay = options->snapDelay;
wait_sig = 0;
+ log_println(0, "test client version: %s", testOptions->client_version);
+
// Determine port to be used. Compute based on options set earlier
// by reading from config file, or use default port2 (3003)
if (testOptions->s2copt) {
=======================================
--- /trunk/src/testoptions.c Fri Feb 21 16:32:03 2014 UTC
+++ /trunk/src/testoptions.c Tue Apr 15 22:51:33 2014 UTC
@@ -206,13 +206,15 @@
int initialize_tests(int ctlsockfd, TestOptions* options, char * buff,
size_t buff_strlen) {
+ unsigned char msgValue[CS_VERSION_LENGTH_MAX + 1] = {'\0', };
unsigned char useropt = 0;
int msgType;
- int msgLen = 1;
+ int msgLen = CS_VERSION_LENGTH_MAX + 1;
int first = 1;
char *invalid_test_suite = "Invalid test suite request.";
char *client_timeout = "Client timeout.";
char *invalid_test = "Invalid test request.";
+ char *invalid_login_msg = "Invalid login message.";
// char remhostarr[256], protologlocalarr[256];
// char *remhost_ptr = get_remotehost();
@@ -220,8 +222,10 @@
assert(ctlsockfd != -1);
assert(options);
+ memset(options->client_version, 0, sizeof(options->client_version));
+
// read the test suite request
- if (recv_msg(ctlsockfd, &msgType, &useropt, &msgLen)) {
+ if (recv_msg(ctlsockfd, &msgType, msgValue, &msgLen)) {
send_msg(ctlsockfd, MSG_ERROR, invalid_test_suite,
strlen(invalid_test_suite));
return (-1);
@@ -230,11 +234,43 @@
snprintf(buff, buff_strlen, "Client timeout");
return (-4);
}
- // Expecting a MSG_LOGIN with payload byte indicating tests to be run
- if ((msgType != MSG_LOGIN) || (msgLen != 1)) {
- send_msg(ctlsockfd, MSG_ERROR, invalid_test, strlen(invalid_test));
+
+ /*
+ * Expecting a MSG_LOGIN or MSG_EXTENDED_LOGIN with
+ * payload byte indicating tests to be run and potentially
+ * a US-ASCII string indicating the version number.
+ * Three cases:
+ * 1: MSG_LOGIN: Check that msgLen is 1
+ * 2: MSG_EXTENDED_LOGIN: Check that msgLen is >= 1 and
+ * <= the maximum length of the client/server version
+ * string (plus 1 to account for the initial useropt
+ * and then copy the client version into client_version.
+ * 3: Neither
+ *
+ * In case (1) or (2) we copy the 0th byte from the msgValue
+ * into useropt so we'll do that in the fallthrough.
+ */
+ if (msgType == MSG_LOGIN) { /* Case 1 */
+ if (msgLen != 1) {
+ send_msg(ctlsockfd, MSG_ERROR, invalid_test, strlen(invalid_test));
+ return (-2);
+ }
+ } else if (msgType == MSG_EXTENDED_LOGIN) { /* Case 2 */
+ if (msgLen >= 1 && msgLen <= (CS_VERSION_LENGTH_MAX + 1)) {
+ memcpy(options->client_version, msgValue + 1, msgLen - 1);
+ log_println(0, "Client version: %s-\n", options->client_version);
+ } else {
+ send_msg(ctlsockfd, MSG_ERROR, invalid_test, strlen(invalid_test));
+ return (-2);
+ }
+ } else { /* Case 3 */
+ send_msg(ctlsockfd, MSG_ERROR,
+ invalid_login_msg,
+ strlen(invalid_login_msg));
return (-2);
}
+ useropt = msgValue[0];
+
// client connect received correctly. Logging activity
// log that client connected, and create log file
log_println(0,
=======================================
--- /trunk/src/testoptions.h Mon Oct 14 13:20:21 2013 UTC
+++ /trunk/src/testoptions.h Tue Apr 15 22:51:33 2014 UTC
@@ -10,6 +10,7 @@
#define SRC_TESTOPTIONS_H_
#include "web100srv.h"
+#include "protocol.h"
#define LISTENER_SOCKET_CREATE_FAILED -1
#define SOCKET_CONNECT_TIMEOUT -100
@@ -21,6 +22,8 @@
int multiple; // multiples tests enabled
int mainport; // main port used for test
+ char client_version[CS_VERSION_LENGTH_MAX + 1]; // client version number.
+
int midopt; // middlebox test to be perfomed?
int midsockfd; // socket file desc for middlebox test
int midsockport; // port used for middlebox test
=======================================
--- /trunk/src/web100srv.c Fri Mar 21 07:54:57 2014 UTC
+++ /trunk/src/web100srv.c Tue Apr 15 22:51:33 2014 UTC
@@ -2224,24 +2224,17 @@
close(ctlsockfd);
goto mainloop;
}
+ }
- log_println(6, "xxx, calling initialize_tests()");
- t_opts = initialize_tests(ctlsockfd, &testopt, test_suite,
- sizeof(test_suite));
+ t_opts = initialize_tests(ctlsockfd, &testopt, test_suite,
+ sizeof(test_suite));
+ if (t_opts < 1) { // some error in initialization routines
+ log_println(3, "Invalid test suite received, terminate child");
+ close(ctlsockfd);
+ shutdown(ctlsockfd, SHUT_WR);
+ goto mainloop;
+ }
- if (t_opts < 1) {
- log_println(
- 3,
- "Invalid test suite string '%s' received, terminate child",
- test_suite);
- close(chld_pipe[0]);
- close(chld_pipe[1]);
- shutdown(ctlsockfd, SHUT_WR);
- close(ctlsockfd);
-
- /* todo: handle other error contitions */
- }
- }
new_child = (struct ndtchild *) malloc(sizeof(struct ndtchild));
memset(new_child, 0, sizeof(struct ndtchild));
tt = time(0);
@@ -2304,24 +2297,6 @@
}
continue;
}
-
- t_opts = initialize_tests(ctlsockfd, &testopt, test_suite,
- sizeof(test_suite));
- if (t_opts < 1) { // some error in initialization routines
- log_println(3, "Invalid test suite received, terminate child");
- close(chld_pipe[0]);
- close(chld_pipe[1]);
- shutdown(ctlsockfd, SHUT_WR);
- close(ctlsockfd);
- kill(chld_pid, SIGTERM);
- if (new_child != NULL) {
- log_println(6, "Freeing new_child=0x%x because of "
- "invalid test suite",
- new_child);
- free(new_child);
- }
- continue;
- }
// socket interrupt, retry
while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
log_println(6, "Waiting for ndtq semaphore to free - 1");
- [ndt-dev] [ndt] r1048 committed - Merge branch Issue143 to solve Issue 143, ndt, 04/15/2014
Archive powered by MHonArc 2.6.16.