aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd/linkchan.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ncpd/linkchan.cc')
-rw-r--r--ncpd/linkchan.cc61
1 files changed, 58 insertions, 3 deletions
diff --git a/ncpd/linkchan.cc b/ncpd/linkchan.cc
index e4891c1..4a2a4d4 100644
--- a/ncpd/linkchan.cc
+++ b/ncpd/linkchan.cc
@@ -23,30 +23,63 @@
// e-mail philip.proudman@btinternet.com
#include <stream.h>
+#include <iomanip.h>
#include "linkchan.h"
#include "bufferstore.h"
+#include "bufferarray.h"
linkChan::linkChan(ncp * _ncpController):channel(_ncpController)
{
+ registerSer = 0x1234;
+ ncpConnect();
}
void linkChan::
ncpDataCallback(bufferStore & a)
{
+ int len = a.getLen();
if (verbose & LINKCHAN_DEBUG_LOG) {
cout << "linkchan: << msg ";
if (verbose & LINKCHAN_DEBUG_DUMP)
cout << a << endl;
else
- cout << a.getLen() << endl;
+ cout << len << endl;
}
+ if ((len > 7) && (a.getByte(0) == 1)) {
+ unsigned int ser = a.getWord(1);
+ int res = a.getWord(3);
+ // int dontknow = a.getWord(5);
+ const char *srvName = a.getString(7);
+ bufferArray newStack;
+ bufferStore se;
+
+ if (verbose & LINKCHAN_DEBUG_LOG)
+ cout << "linkchan: received registerAck: ser=0x" << hex << setw(4)
+ << setfill(0) << ser << " res=" << res << " srvName=\""
+ << srvName << "\"" << endl;
+
+ while (!registerStack.empty()) {
+ se = registerStack.popBuffer();
+ if (se.getWord(0) == ser) {
+ if (verbose & LINKCHAN_DEBUG_LOG)
+ cout << "linkchan: found ser=0x" << hex << setw(4) <<
+ setfill(0) << se.getWord(0) <<
+ " on stack -> callBack to waiting chan" << endl;
+ ncpDoRegisterAck((int)se.getWord(2));
+ } else
+ newStack.pushBuffer(se);
+ }
+ registerStack = newStack;
+ return;
+ }
+ cerr << "linkchan: unknown message " << a.getByte(0) << endl;
}
-const char *linkChan::
+char *linkChan::
getNcpConnectName()
{
- return "LINK.*";
+ return "LINK";
}
void linkChan::
@@ -63,3 +96,25 @@ ncpConnectTerminate()
cout << "linkchan: << ctrm" << endl;
terminateWhenAsked();
}
+
+void linkChan::
+ncpConnectNak()
+{
+ ncpConnectTerminate();
+}
+
+void linkChan::
+Register(channel *ch)
+{
+ bufferStore a;
+ bufferStore stack;
+
+ stack.addWord(registerSer);
+ stack.addWord(ch->getNcpChannel());
+ registerStack.pushBuffer(stack);
+ a.addByte(0);
+ a.addWord(registerSer++);
+ a.addString(ch->getNcpConnectName());
+ a.addByte(0);
+ ncpSend(a);
+}