summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-26 21:52:21 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-26 21:52:21 -0500
commit9c9085621bf01f9b39e15eb856ff521ecb01fccf (patch)
tree0d912f472a89ffccbcc3bb79ceed6a2b3a350118 /servers
parentb2f2dba837c0d28bf73ec36933af901f484633f5 (diff)
downloadulab-9c9085621bf01f9b39e15eb856ff521ecb01fccf.tar.gz
ulab-9c9085621bf01f9b39e15eb856ff521ecb01fccf.zip
Fix krb client/server sockets
Diffstat (limited to 'servers')
-rw-r--r--servers/auth_server_lin/src/auth_conn.cpp62
-rw-r--r--servers/auth_server_lin/src/auth_conn.h1
-rw-r--r--servers/fpga_server_lin/src/fpga_conn.cpp38
3 files changed, 85 insertions, 16 deletions
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp
index b71b608..e531099 100644
--- a/servers/auth_server_lin/src/auth_conn.cpp
+++ b/servers/auth_server_lin/src/auth_conn.cpp
@@ -115,6 +115,8 @@ int AuthSocket::initiateKerberosHandshake() {
}
int AuthSocket::enterCommandLoop() {
+ bool bound = false;
+
m_criticalSection++;
try {
TQString command;
@@ -194,6 +196,8 @@ int AuthSocket::enterCommandLoop() {
ds << TQString("ERRUNAVAL");
}
else {
+ bound = true;
+
// Update database
TQSqlRecord *buffer = m_databaseActivityCursor->primeInsert();
buffer->setValue("station", m_stationID);
@@ -201,12 +205,66 @@ int AuthSocket::enterCommandLoop() {
buffer->setValue("realmname", m_authenticatedRealmName);
buffer->setValue("logontime", TQDateTime::currentDateTime().toTime_t());
m_databaseActivityCursor->insert();
-
+
ds << TQString("OK");
}
}
+ else if (command == "SERV") {
+ // Get desired Service ID from client
+ TQ_UINT32 sid;
+ ds >> sid;
+
+ m_databaseActivityCursor->select(TQString("username='%1' AND realmname='%2'").arg(m_authenticatedUserName).arg(m_authenticatedRealmName));
+ if (m_databaseActivityCursor->next()) {
+ m_stationID = m_databaseActivityCursor->value("station").toInt();
+ }
+
+ if (bound == true) {
+ ds << TQString("ERRINVCMD");
+ }
+
+ if (m_stationID < 0) {
+ ds << TQString("ERRNOCONN");
+ }
+
+ // Attempt to connect to the backend server
+ m_databaseServicesCursor->select(TQString("pk=%1 AND station=%2").arg(sid).arg(m_stationID));
+ if (m_databaseServicesCursor->next()) {
+ TQString serviceHostName = m_databaseServicesCursor->value("hostname").toString();
+ int servicePort = m_databaseServicesCursor->value("port").toInt();
+
+ TDEKerberosClientSocket clientSocket;
+ clientSocket.setServiceName("remotefpga");
+
+ clientSocket.setServerFQDN(serviceHostName);
+ clientSocket.connectToHost(serviceHostName, servicePort);
+
+ while ((clientSocket.state() == TQSocket::Connecting) || (clientSocket.state() == TQSocket::HostLookup)) {
+ tqApp->processEvents();
+ }
+ if (clientSocket.state() == TQSocket::Connected) {
+ if (clientSocket.setUsingKerberos(true) != 0) {
+ clientSocket.close();
+ ds << TQString("ERRNOTAVL");
+ printf("[DEBUG] Connection failed to %s:%d for user %s@%s due to Kerberos failure\n\r", serviceHostName.ascii(), servicePort, m_authenticatedUserName.ascii(), m_authenticatedRealmName.ascii()); fflush(stdout);
+ }
+ else {
+ printf("[RAJA DEBUG 600.0] Connect OK!\n\r"); fflush(stdout);
+ // RAJA FIXME
+ }
+ }
+ else {
+ clientSocket.close();
+ ds << TQString("ERRNOTAVL");
+ printf("[DEBUG] Connection failed to %s:%d for user %s@%s\n\r", serviceHostName.ascii(), servicePort, m_authenticatedUserName.ascii(), m_authenticatedRealmName.ascii()); fflush(stdout);
+ }
+ }
+ else {
+ ds << TQString("ERRNOTAVL");
+ }
+ }
else {
- ds << "ERRINVCMD";
+ ds << TQString("ERRINVCMD");
}
}
tqApp->processEvents();
diff --git a/servers/auth_server_lin/src/auth_conn.h b/servers/auth_server_lin/src/auth_conn.h
index 710b4c0..aea8a48 100644
--- a/servers/auth_server_lin/src/auth_conn.h
+++ b/servers/auth_server_lin/src/auth_conn.h
@@ -34,6 +34,7 @@
#include <ksimpleconfig.h>
#include <tdekrbserversocket.h>
+#include <tdekrbclientsocket.h>
#include <tqtrla.h>
diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp
index 1b0927c..1335a5a 100644
--- a/servers/fpga_server_lin/src/fpga_conn.cpp
+++ b/servers/fpga_server_lin/src/fpga_conn.cpp
@@ -110,9 +110,15 @@ int FPGASocket::setupSerial() {
tcgetattr(m_fd_tty, &oldtio); // Save current port settings
long serialBaud;
- if (desiredBaudRate == "9600") {
+ if (desiredBaudRate == "1200") {
+ serialBaud = B1200;
+ }
+ else if (desiredBaudRate == "9600") {
serialBaud = B9600;
}
+ else if (desiredBaudRate == "19200") {
+ serialBaud = B19200;
+ }
else if (desiredBaudRate == "115200") {
serialBaud = B115200;
}
@@ -139,22 +145,26 @@ int FPGASocket::setupSerial() {
}
int FPGASocket::enterCommandLoop() {
+ int cc;
+ char buffer[10000];
+
m_criticalSection++;
try {
while (state() == TQSocket::Connected) {
- // RAJA FIXME
-// cc = read(fd_tty, readbuf, 100000);
-// if (cc > 0) {
-// write_data_to_client(fd, readbuf, cc);
-// fsync(fd_tty);
-// printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout);
-// }
-// cc = read(fd, writebuf, 100000);
-// if (cc > 0) {
-// write(fd_tty, writebuf, cc);
-// fsync(fd);
-// printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout);
-// }
+ cc = read(m_fd_tty, buffer, 10000);
+ if (cc > 0) {
+ writeBlock(buffer, cc);
+ printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout);
+ }
+ if (canReadLine()) {
+ cc = readBlock(buffer, 10000);
+ if (cc > 0) {
+ if (write(m_fd_tty, buffer, cc) < 0) {
+ // ERROR
+ }
+ printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout);
+ }
+ }
}
m_criticalSection--;