X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=rrqnet.c;h=efd7066b457cb2438d96f1246cc553ad152cc3ed;hb=16be35c2186cfcecdfb3bcb9faa56ec0f61f144c;hp=db93fd70ec50e19bd708215d45e275622a8c06a3;hpb=9b24d4e275dbfa538b80ee6bcfe786f63c1c0904;p=rrq%2Frrqnet.git diff --git a/rrqnet.c b/rrqnet.c index db93fd7..efd7066 100644 --- a/rrqnet.c +++ b/rrqnet.c @@ -99,10 +99,10 @@ typedef struct _ReaderData { #define TIME_MICROS(TM) (((int64_t) (TM)->tv_sec * 1000000) + (TM)->tv_usec ) #define DIFF_MICROS(TM1,TM2) ( TIME_MICROS(TM1) - TIME_MICROS(TM2) ) -// RECENT(T,M) is the time logic for requiring a gap time (in +// RECENT_MICROS(T,M) is the time logic for requiring a gap time (in // milliseconds) before shifting a MAC to a new remote. The limit is -// 6000 for broadcast and 20000 for unicast. -#define RECENT(T,M) ((M) < ((T)? 6000 : 20000 )) +// 6s for broadcast and 20s for unicast. +#define RECENT_MICROS(T,M) ((M) < ((T)? 6000000 : 20000000 )) // VERYOLD_MICROSS is used for discarding downlink remotes whose latest // activity is older than this. @@ -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; @@ -570,6 +574,7 @@ static int parse_bits(char *bits,int max,struct Allowed *into) { // Formats: [/][:][=keyfile] // Formats: [/][=keyfile] // Formats: \[[/]\][:][=keyfile] +// Formats: hostname:port[=keyfile] static int parse_allowed(char *arg,struct Allowed *into) { static char buffer[10000]; int n = strlen( arg ); @@ -877,11 +882,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 > 1460 ) && ( n < 1478 ) ) { + VERBOSE2OUT( "tpg quirk applied\n" ); + n = 1478; // Add some "random" tag-along bytes + } if ( r->spec == 0 ) { if ( r->uaddr.in.sa_family == 0 ) { // Output to tap/stdio @@ -1058,10 +1068,10 @@ static struct Interface *input_check( // The packet source MAC has arrived on other than its // previous channel. It thus gets dropped if tap/stdin is the // primary channel, or the time since the last packet for that - // interface is less than RECENT, with different limits for - // broadcast and unicast. + // interface is less than RECENT_MICROS, with different limits + // for broadcast and unicast. int64_t dmac = DIFF_MICROS( &now, &x->rec_when); - if ( x->remote->spec == 0 || RECENT( *buf & 1, dmac ) ) { + if ( x->remote->spec == 0 || RECENT_MICROS( *buf & 1, dmac ) ) { if ( verbose >= 2 ) { fprintf( stderr, @@ -1300,10 +1310,10 @@ static void heartbeat(int fd) { // Tell how to use this program and exit with failure. static void usage(void) { fprintf( stderr, "Packet tunneling over UDP, multiple channels, " ); - fprintf( stderr, "version 0.2.5\n" ); + fprintf( stderr, "version 1.5.3\n" ); fprintf( stderr, "Usage: " ); fprintf( stderr, - "%s [-v] [-4] [-B n] [-T n] [-m mcast] [-t tap] port [remote]+ \n", + "%s [-v] [-tpg] [-4] [-B n] [-T n] [-m mcast] [-t tap] port [remote]+ \n", progname ); exit( 1 ); } @@ -1417,6 +1427,11 @@ int main(int argc, char *argv[]) { i++; ENSUREARGS( 1 ); } + if ( strncmp( "-tpg", argv[i], 4 ) == 0 ) { + tpg_quirk = 1; + i++; + ENSUREARGS( 1 ); + } // then: optional -4 if ( strncmp( "-4", argv[i], 2 ) == 0 ) { udp6 = 0; @@ -1459,7 +1474,7 @@ int main(int argc, char *argv[]) { } // then: required port if ( sscanf( argv[i++], "%d", &port ) != 1 ) { - fprintf( stderr, "Bad local port" ); + fprintf( stderr, "Bad local port: %s\n", argv[i-1] ); usage(); } // then: any number of allowed remotes