]> git.sesse.net Git - greproxy/blobdiff - reorderer.h
Move GREProtocol into its own files, and Reorderer into a .h file.
[greproxy] / reorderer.h
diff --git a/reorderer.h b/reorderer.h
new file mode 100644 (file)
index 0000000..476093f
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef _REORDERER_H
+#define _REORDERER_H 1
+
+#include <stdint.h>
+
+#include <algorithm>
+#include <map>
+#include <queue>
+#include <string>
+#include <vector>
+
+class Protocol;
+
+struct GREPacket {
+       int seq;
+       uint16_t proto;
+       std::string data;
+
+       bool operator> (const GREPacket &other) const {
+               return seq > other.seq;
+       }
+};
+
+class Reorderer {
+public:
+       Reorderer(Protocol* sender);
+       void handle_packet(uint16_t proto, const std::string& data, int seq);
+
+private:
+       void send_packet(uint16_t proto, const std::string &data, bool silence);
+
+       Protocol* sender;
+       int last_seq;
+
+       std::priority_queue<GREPacket, std::vector<GREPacket>, std::greater<GREPacket>> packet_buffer;
+       std::map<int, int> ccs;
+};
+
+#endif  // !defined(_REORDERER_H)