summaryrefslogtreecommitdiff
path: root/comm/OLD/dgram.h
diff options
context:
space:
mode:
authorchatty1993-04-07 11:50:31 +0000
committerchatty1993-04-07 11:50:31 +0000
commitba066c34dde204aa192d03a23a81356374d93731 (patch)
tree39391f6235d2cf8a59a0634ac5ea430cdd21f5d4 /comm/OLD/dgram.h
parent05ab076e1c2a9ca16472f9a6b47b8d22914b3783 (diff)
downloadivy-league-ba066c34dde204aa192d03a23a81356374d93731.zip
ivy-league-ba066c34dde204aa192d03a23a81356374d93731.tar.gz
ivy-league-ba066c34dde204aa192d03a23a81356374d93731.tar.bz2
ivy-league-ba066c34dde204aa192d03a23a81356374d93731.tar.xz
Initial revision
Diffstat (limited to 'comm/OLD/dgram.h')
-rw-r--r--comm/OLD/dgram.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/comm/OLD/dgram.h b/comm/OLD/dgram.h
new file mode 100644
index 0000000..143687e
--- /dev/null
+++ b/comm/OLD/dgram.h
@@ -0,0 +1,102 @@
+/*
+ * The Unix Channel
+ *
+ * by Michel Beaudouin-Lafon
+ *
+ * Copyright 1990-1993
+ * Laboratoire de Recherche en Informatique (LRI)
+ *
+ * Reliable datagrams - to be updated
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#ifndef _DGRAM_H_
+#define _DGRAM_H_
+
+#include "global.h"
+#include "Datagram.h"
+#include "ccu/IdTable.h"
+#include "ccu/List.h"
+#include "ccu/Timer.h"
+
+class UchDGRAM;
+class UchMessage;
+
+class UchDGRAM_TIMER : public CcuBaseTimer {
+protected:
+ UchDGRAM& dgram;
+ void Handle (Millisecond);
+
+public:
+ UchDGRAM_TIMER (UchDGRAM&);
+ ~UchDGRAM_TIMER ();
+};
+
+class UchDGRAM : public UchDatagram {
+protected:
+ CcuIdTable pending; // pending messages
+ sword npending; // number of pending messages
+ short retry; // retry times
+ CcuList input; // input messages
+ sword ninput; // number of input messages
+ pUchAddress fromAddr; // address of last acknowledged message
+ lword outId; // id of message sent
+ UchDGRAM_TIMER timer; // timer to resend
+ Millisecond timeout; // timeout for timer
+ short locked;
+ bool resend;
+ bool sync;
+
+ void Init ();
+ int GetInput (int);
+ bool CheckInput ();
+ bool WaitInput ();
+
+ void SendAck (lword, UchAddress&);
+ void Expired ();
+ UchMsgBuffer* PrepareToSend (UchAddress&, int retries);
+ int SendBuffer (UchMsgBuffer&, UchAddress&);
+ void RemovePending (lword);
+ bool Wait (lword);
+ void Lock () { locked++; }
+ void Unlock () { if (--locked == 0 && resend) Resend (); }
+
+public:
+ UchDGRAM ();
+ UchDGRAM (UchAddress*, UchAddress*);
+ ~UchDGRAM ();
+
+ int Send (byte*, int, UchAddress&, bool = FALSE, int retries = 0);
+ int Receive (byte*, int);
+ int Reply (byte*, int, bool = FALSE, int retries = 0);
+
+ int Send (UchMsgBuffer&, UchAddress&, bool = FALSE, bool = FALSE, int retries = 0);
+ int Receive (UchMsgBuffer&);
+ int Reply (UchMsgBuffer&, bool = FALSE, bool = FALSE, int retries = 0);
+
+ bool Send (UchMessage&, UchAddress&, bool = FALSE, int retries = 0);
+ bool Receive (UchMessage* msg);
+ bool Reply (UchMessage&, bool = FALSE, int retries = 0);
+
+virtual bool DiscardNotify (UchMsgBuffer&, UchAddress&);
+
+ int NumPending () { return npending; }
+ int NumInput () { return ninput; }
+ void SetRetry (short r) { retry = r; }
+ void SetRetryTime (Millisecond);
+ void SetSync (bool s) { sync = s; if (s) Drain (); }
+
+ void Resend ();
+ void Drain ();
+
+virtual bool NewMessage (UchMsgBuffer&);
+ void HandleRead ();
+ bool HandleSelect ();
+
+friend class UchDGRAM_TIMER;
+};
+
+#endif /* _DGRAM_H_ */
+