aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd/socketchan.cc
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2001-05-22 21:56:49 +0000
committerFritz Elfert <felfert@to.com>2001-05-22 21:56:49 +0000
commitec3b548646d8739c35e2a66379e921b3438fe367 (patch)
treeee135f860bdfd95b1796468872fbead343587476 /ncpd/socketchan.cc
parent8a7831faf62daf131ca72ac8f6aea1528b077684 (diff)
downloadplptools-ec3b548646d8739c35e2a66379e921b3438fe367.tar.gz
plptools-ec3b548646d8739c35e2a66379e921b3438fe367.tar.bz2
plptools-ec3b548646d8739c35e2a66379e921b3438fe367.zip
- Added support for extended sequence numbers (incoming only)
- Changed the behavior on initial connect to support the Clipboard-Server and to meet the doc in http://www.thouky.co.uk/software/psifs/plp.html: All services except SYS$RFSV now perform registration and connect is done when the Psion returned RegisterAck. Then the connect can use the service name as presented by the Psion's RegisterAck.
Diffstat (limited to 'ncpd/socketchan.cc')
-rw-r--r--ncpd/socketchan.cc85
1 files changed, 46 insertions, 39 deletions
diff --git a/ncpd/socketchan.cc b/ncpd/socketchan.cc
index dea883a..1eba086 100644
--- a/ncpd/socketchan.cc
+++ b/ncpd/socketchan.cc
@@ -1,44 +1,43 @@
-// $Id$
-//
-// PLP - An implementation of the PSION link protocol
-//
-// Copyright (C) 1999 Philip Proudman
-// Modifications for plptools:
-// Copyright (C) 1999 Fritz Elfert <felfert@to.com>
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// e-mail philip.proudman@btinternet.com
-
+/*-*-c++-*-
+ * $Id$
+ *
+ * This file is part of plptools.
+ *
+ * Copyright (C) 1999 Philip Proudman <philip.proudman@btinternet.com>
+ * Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stream.h>
-#include "stdio.h"
-#include "string.h"
-#include "malloc.h"
+#include <stdio.h>
+#include <string.h>
+#include <malloc.h>
#include "socketchan.h"
#include "ncp.h"
-#include "ppsocket.h"
+#include <ppsocket.h>
socketChan:: socketChan(ppsocket * _skt, ncp * _ncpController):
channel(_ncpController)
{
skt = _skt;
- connectName = 0;
+ registerName = 0;
connectTry = 0;
connected = false;
}
@@ -47,23 +46,23 @@ socketChan::~socketChan()
{
skt->closeSocket();
delete skt;
- if (connectName)
- free(connectName);
+ if (registerName)
+ free(registerName);
}
void socketChan::
ncpDataCallback(bufferStore & a)
{
- if (connectName != 0) {
+ if (registerName != 0) {
skt->sendBufferStore(a);
} else
cerr << "socketchan: Connect without name!!!\n";
}
char *socketChan::
-getNcpConnectName()
+getNcpRegisterName()
{
- return connectName;
+ return registerName;
}
// NCP Command processing
@@ -145,7 +144,7 @@ ncpRegisterAck()
void socketChan::
ncpConnectNak()
{
- if (!connectName || (connectTry > 1))
+ if (!registerName || (connectTry > 1))
ncpConnectTerminate();
else {
connectTry++;
@@ -158,7 +157,7 @@ socketPoll()
{
int res;
- if (connectName == 0) {
+ if (registerName == 0) {
bufferStore a;
res = skt->getBufferStore(a, false);
switch (res) {
@@ -180,7 +179,7 @@ socketPoll()
// before any connection can be made.
//
// All commands begin with "NCP$".
-
+
// There is a magic process name called "NCP$INFO.*"
// which is announced by the rfsvfactory. This causes a
// response to be issued containing the NCP version
@@ -196,9 +195,17 @@ socketPoll()
}
// This isn't a command, it's a remote process. Connect.
- connectName = strdup(a.getString());
+ registerName = strdup(a.getString());
connectTry++;
- ncpConnect();
+
+ // If this is SYS$RFSV, we immediately connect. In all
+ // other cases, we first perform a registration. Connect
+ // is then triggered by RegisterAck and uses the name
+ // we received from the Psion.
+ if (strncmp(registerName, "SYS$RFSV", 8) == 0)
+ ncpConnect();
+ else
+ ncpRegister();
break;
case -1:
ncpConnectTerminate();