trial of avoiding 1470 packets
[rrq/rrqnet.git] / rrqnet.c
index 6b57d08b304af3e989df44e8d07cdbb7148c3553..27769c8e9343a686f9a76af33749bc3a26ca938d 100644 (file)
--- a/rrqnet.c
+++ b/rrqnet.c
@@ -188,6 +188,10 @@ static struct {
 // Flag to signal the UDP socket as being ipv6 or not (forced ipv4)
 static int udp6 = 1;
 
+// Flag to indicate tpg transport patch = avoid UDP payload of 1470
+// bytes by adding 2 tag-along bytes
+static int tpg_quirk = 0;
+
 // Flag whether to make some stderr outputs or not.
 // 1 = normal verbosity, 2 = more output, 3 = source debug level stuff
 static int verbose;
@@ -877,11 +881,16 @@ static void write_remote(unsigned char *buf, int n,struct Remote *r) {
     if ( n < 12 ) {
        VERBOSE2OUT( "SEND %d bytes to %s\n", n, inet_stoa( &r->uaddr ) );
     } else {
-       VERBOSE2OUT( "SEND %s -> %s to %s\n",
+       VERBOSE2OUT( "SEND %d bytes %s -> %s to %s\n", n,
                     inet_mtoa( buf+6 ), inet_mtoa( buf ),
                     inet_stoa( &r->uaddr ) );
     }
     memcpy( output, buf, n ); // Use the private buffer for delivery
+    // Apply the TPG quirk
+    if ( tpg_quirk && ( n == 1470 ) ) {
+       VERBOSE2OUT( "tpg quirk applied\n" );
+       n += 8; // Add 8 "random" tag-along bytes
+    }
     if ( r->spec == 0 ) {
        if ( r->uaddr.in.sa_family == 0 ) {
            // Output to tap/stdio
@@ -1402,6 +1411,11 @@ int main(int argc, char *argv[]) {
     ///// Parse command line arguments
     i = 1;
 #define ENSUREARGS(n) if ( argc < i + n ) usage()
+    ENSUREARGS( 1 );
+    if ( strncmp( "-tpg", argv[i], 4 ) == 0 ) {
+       tpg_quirk = 1;
+       i++;
+    }
     ENSUREARGS( 1 );
     // First: optional -v, -vv or -vvv
     if ( strncmp( "-v", argv[i], 2 ) == 0 ) {