--- /dev/null
+#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)