]> git.sesse.net Git - greproxy/commitdiff
Add some code to drop packets on-demand, for debugging.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Feb 2015 11:49:24 +0000 (12:49 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Feb 2015 11:49:24 +0000 (12:49 +0100)
rsencoder.cpp

index 719d548bde48dcaa073181c761137e59a60993b4..4f63131f79641d3f4156d4c51468c3c0677ba3a9 100644 (file)
@@ -34,7 +34,17 @@ void RSEncoder::send_packet(uint16_t proto, const std::string &data, int incomin
                // Received an unfinished group.
                packet_history.clear();
        }
-       sender->send_packet(proto, data, incoming_seq);
+       bool debug_drop_packet = false;  // For testing only.
+       if (incoming_seq % RS_PAYLOAD_SIZE == 3) {
+               //debug_drop_packet = true;
+       }
+       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",
+                       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);
+       }
        packet_history.emplace_back(GREPacket{incoming_seq, proto, data});
        if (packet_history.size() == RS_PAYLOAD_SIZE) {
                finish_group();