]> git.sesse.net Git - greproxy/commitdiff
Merge branch 'master' of /srv/git.sesse.net/www/greproxy master
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 28 Feb 2016 18:28:17 +0000 (19:28 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 28 Feb 2016 18:28:17 +0000 (19:28 +0100)
13 files changed:
greprotocol.cpp
greprotocol.h
pacer.cpp
pacer.h
protocol.h
reorderer.cpp
reorderer.h
rsdecoder.cpp
rsdecoder.h
rsencoder.cpp
rsencoder.h
tunprotocol.cpp
tunprotocol.h

index d3daa9c829ae9a14c100291405312595f9a63664..6f3513039ed67e00706bd2458cab0970c0cb3764 100644 (file)
@@ -51,7 +51,7 @@ GREProtocol::GREProtocol(const in6_addr &src, const in6_addr &dst)
        }
 }
 
-void GREProtocol::send_packet(uint16_t proto, const string &data, int incoming_seq)
+void GREProtocol::send_packet(uint16_t proto, const string &data, uint32_t incoming_seq)
 {
        char buf[4096];
        gre_header *gre = (gre_header *)buf;
@@ -62,7 +62,7 @@ void GREProtocol::send_packet(uint16_t proto, const string &data, int incoming_s
        gre->protocol_type = htons(proto);
 
        char *ptr = buf + sizeof(*gre);
-       int seq_be = htonl(incoming_seq);
+       uint32_t seq_be = htonl(incoming_seq);
        memcpy(ptr, &seq_be, sizeof(seq_be));
        ptr += sizeof(seq_be);
 
index 738ec7b195ef620ddbf99db72a8a7dfa609c52f0..c54efd699cc530fcafcbb40ab2c67582210e18fd 100644 (file)
@@ -11,7 +11,7 @@
 class GREProtocol : public Sender, public Reader {
 public:
        GREProtocol(const in6_addr &myaddr, const in6_addr &dst);
-       virtual void send_packet(uint16_t proto, const std::string &data, int incoming_seq);
+       virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq);
        virtual int fd() const;
        virtual void read_packet(Sender* sender);
 
index d049067ed8b6d04730cb11f4da468cbf2820180b..7de87a45c73acd23c42e0bdcc5f3e75bfe21c3fd 100644 (file)
--- a/pacer.cpp
+++ b/pacer.cpp
@@ -12,7 +12,7 @@ Pacer::Pacer(Sender *sender, int max_rate_kbit_per_sec, int burst_num_packets)
        seconds_per_byte = 1.0 / max_rate_byte_per_sec;
 }
 
-void Pacer::send_packet(uint16_t proto, const string &data, int incoming_seq)
+void Pacer::send_packet(uint16_t proto, const string &data, uint32_t incoming_seq)
 {
        waiting_packets.push_back(GREPacket{incoming_seq, proto, data, {0, 0}});
        possibly_flush_packets();
diff --git a/pacer.h b/pacer.h
index 90d0c4ff39010aceae464dd3f1a1af00e406711c..b42d73fa26e201c52609d63e711c43def305ce97 100644 (file)
--- a/pacer.h
+++ b/pacer.h
@@ -12,7 +12,7 @@
 struct Pacer : public Sender {
 public:
        Pacer(Sender *sender, int max_rate_kbit_per_sec, int burst_num_packets);
-       virtual void send_packet(uint16_t proto, const std::string &data, int incoming_seq);
+       virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq);
 
        void possibly_adjust_tv(timeval *tv);
        void possibly_flush_packets();
index 65c4d1d10f538952a2fd6de679953e35168ccdad..acbaa3b489f51d368a370e524d6a0ebc6ddc0bfb 100644 (file)
@@ -6,7 +6,7 @@
 
 class Sender {
 public:
-       virtual void send_packet(uint16_t proto, const std::string &data, int incoming_seq) = 0;
+       virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq) = 0;
 };
 
 class Reader {
index c2823e5254c94a85c7201d61efbb613d27d88073..71b90c54d7433308ea0684574768b6bd990ecfa5 100644 (file)
@@ -30,7 +30,7 @@ void Reorderer::possibly_adjust_tv(timeval *tv)
        }
 }
 
-void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
+void Reorderer::send_packet(uint16_t proto, const string& data, uint32_t seq)
 {
        timeval now;
        gettimeofday(&now, NULL);
@@ -55,7 +55,7 @@ void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
        if (packet_buffer.empty() &&
            seq < last_seq &&
            tdiff(last_sent_packet, now) > 5.0) {
-               printf("No good data for five seconds, resetting sequence to %d\n", seq);
+               printf("No good data for five seconds, resetting sequence to %u\n", seq);
                last_seq = seq - 1;
        }
 
@@ -70,9 +70,9 @@ void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
 
        while (!packet_buffer.empty() &&
               (last_seq == -1 || packet_buffer.top().seq <= last_seq + 1)) {
-               int front_seq = packet_buffer.top().seq;
+               uint32_t front_seq = packet_buffer.top().seq;
                if (front_seq < last_seq + 1) {
-                       printf("Duplicate packet or way out-of-order: seq=%d front_seq=%d\n",
+                       printf("Duplicate packet or way out-of-order: seq=%u front_seq=%u\n",
                                front_seq, last_seq + 1);
                        packet_buffer.pop();
                        continue;
index 77fda65a43b70475296a1833a60dc21b3f762708..d7f585c50c7066c92e58a28dabde9e53dbe34692 100644 (file)
@@ -14,7 +14,7 @@
 #include "protocol.h"
 
 struct GREPacket {
-       int seq;
+       uint32_t seq;
        uint16_t proto;
        std::string data;
        timeval ts;
@@ -27,7 +27,7 @@ struct GREPacket {
 class Reorderer : public Sender {
 public:
        Reorderer(Sender* sender);
-       void send_packet(uint16_t proto, const std::string& data, int seq);
+       void send_packet(uint16_t proto, const std::string& data, uint32_t seq);
        void possibly_adjust_tv(timeval *tv);
 
        int get_reorders() const { return num_reorders; }
index 58fa1ac634cd4df294d6a04a4554e1d30fb53028..0a11541c377a595a1ce7cfcffff9421656817a6e 100644 (file)
@@ -17,7 +17,7 @@ RSDecoder::RSDecoder(Sender *sender)
 {
 }
 
-void RSDecoder::send_packet(uint16_t proto, const std::string &data, int incoming_seq)
+void RSDecoder::send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq)
 {
        int rs_group;
        if (proto == 0xffff) {
@@ -85,7 +85,7 @@ void RSDecoder::send_packet(uint16_t proto, const std::string &data, int incomin
                        vector<string> padded_packets;
                        std::map<size_t, const fecpp::byte *> shares;
                        for (const auto &packet_pair : group.packets) {
-                               int packet_seq = packet_pair.first;
+                               uint32_t packet_seq = packet_pair.first;
                                int share_num;
                                string p;
                                p.resize(max_length);
index 3b1634db7e63347574788b1cd032b136dc575353..db8c6e31b12edf62907779f8db3c510055dfc350 100644 (file)
@@ -13,7 +13,7 @@ class Sender;
 class RSDecoder : public Sender {
 public:
        RSDecoder(Sender *sender);
-       virtual void send_packet(uint16_t proto, const std::string &data, int incoming_seq);
+       virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq);
 
        int get_recovered_packets() const { return num_recovered_packets; }
 
index 4f63131f79641d3f4156d4c51468c3c0677ba3a9..e4e9481f8b35c61715a3d2ba1966eaa8c414fa83 100644 (file)
@@ -21,7 +21,7 @@ RSEncoder::RSEncoder(Sender *sender)
 {
 }
 
-void RSEncoder::send_packet(uint16_t proto, const std::string &data, int incoming_seq)
+void RSEncoder::send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq)
 {
        if (!packet_history.empty() &&
            incoming_seq <= packet_history.back().seq) {
@@ -40,7 +40,7 @@ void RSEncoder::send_packet(uint16_t proto, const std::string &data, int incomin
        }
        if (debug_drop_packet) {
                const unsigned char *ptr = reinterpret_cast<const unsigned char *>(data.data());
-               printf("DEBUG: Dropping packet seq=%d proto=0x%04x len=%d data=%02x %02x %02x %02x %02x %02x %02x %02x ...\n",
+               printf("DEBUG: Dropping packet seq=%u proto=0x%04x len=%d data=%02x %02x %02x %02x %02x %02x %02x %02x ...\n",
                        incoming_seq, proto, data.size(), ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]);
        } else {
                sender->send_packet(proto, data, incoming_seq);
@@ -84,7 +84,7 @@ void RSEncoder::finish_group()
                        }
 
                        const char *sdata = reinterpret_cast<const char *>(data);
-                       int start_seq = packet_history[0].seq - 1;
+                       uint32_t start_seq = packet_history[0].seq - 1;
                        sender->send_packet(0xffff, string(sdata, size), start_seq - (packet_num - RS_PAYLOAD_SIZE));
                });
        
index 6ab6e4b2de6f140a20fe02ce876431fcccc13ca4..538bcc839677ee15cf7c11c19921da3b24a5b62c 100644 (file)
@@ -14,7 +14,7 @@ class Sender;
 class RSEncoder : public Sender {
 public:
        RSEncoder(Sender* sender);
-       virtual void send_packet(uint16_t proto, const std::string &data, int incoming_seq);
+       virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq);
 
 private:
        void finish_group();
index 510decf29464d5e9b77b7ec38ff9c291c7a63ab9..f455e20ce7aeed31b4218619a8846c309e3bc09f 100644 (file)
@@ -42,7 +42,7 @@ TUNProtocol::TUNProtocol(const char *devname)
        : tunfd(tun_open(devname)), seq(0) {
 }
 
-void TUNProtocol::send_packet(uint16_t proto, const string &data, int incoming_seq)
+void TUNProtocol::send_packet(uint16_t proto, const string &data, uint32_t incoming_seq)
 {
        char buf[4096];
 
index 79e528f379904f9b642440fb5328285f79325b7a..81fd900f0f02238819a6cb4a261977d2a3a16cbf 100644 (file)
@@ -9,7 +9,7 @@
 class TUNProtocol : public Sender, public Reader {
 public:
        TUNProtocol(const char *devname);
-       virtual void send_packet(uint16_t proto, const std::string &data, int incoming_seq);
+       virtual void send_packet(uint16_t proto, const std::string &data, uint32_t incoming_seq);
        virtual int fd() const;
        virtual void read_packet(Sender* sender);
 
@@ -18,7 +18,7 @@ public:
 
 private:
        int tunfd;
-       int seq;
+       uint32_t seq;
 
        int received_packets = 0, sent_packets = 0;
 };