]> git.sesse.net Git - greproxy/blob - reorderer.h
Add missing commits from previous cleanups.
[greproxy] / reorderer.h
1 #ifndef _REORDERER_H
2 #define _REORDERER_H 1
3
4 #include <stdint.h>
5
6 #include <algorithm>
7 #include <map>
8 #include <queue>
9 #include <string>
10 #include <vector>
11
12 class Protocol;
13
14 struct GREPacket {
15         int seq;
16         uint16_t proto;
17         std::string data;
18
19         bool operator> (const GREPacket &other) const {
20                 return seq > other.seq;
21         }
22 };
23
24 class Reorderer {
25 public:
26         Reorderer(Protocol* sender);
27         void handle_packet(uint16_t proto, const std::string& data, int seq);
28
29 private:
30         void send_packet(uint16_t proto, const std::string &data, bool silence);
31
32         Protocol* sender;
33         int last_seq;
34
35         std::priority_queue<GREPacket, std::vector<GREPacket>, std::greater<GREPacket>> packet_buffer;
36         std::map<int, int> ccs;
37 };
38
39 #endif  // !defined(_REORDERER_H)