From ec3b548646d8739c35e2a66379e921b3438fe367 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Tue, 22 May 2001 21:56:49 +0000 Subject: - 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. --- ncpd/socketchan.cc | 85 +++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) (limited to 'ncpd/socketchan.cc') 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 -// -// 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 + * Copyright (C) 1999-2001 Fritz Elfert + * + * 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 #endif #include -#include "stdio.h" -#include "string.h" -#include "malloc.h" +#include +#include +#include #include "socketchan.h" #include "ncp.h" -#include "ppsocket.h" +#include 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(); -- cgit v1.2.3