Note that any options must be given or omitted in the fixed order:
- [-v] [-tpg] [-4] [-B n] [-T n] [-m mcast] [-t tap] [-S source]
+ [-v] [-tpg] [-4] [-B n] [-T n] [-H r] [-m mcast] [-t tap] [-S source]
*-v*::
is serviced by the dispatch threads for optional decryption, dispatch
decision, optional encryption and delivery.
+*-H* _r_::
+
+This sets the number of seconds *rrqnet* should wait between "heart
+beat" messages to uplinks. The default is 30. This is used to hold the
+uplink open for return traffic through NAT routers. Set to 0 to
+disable the heartbeat messages.
+
*-m* _mcast_::
This tells *rrqnet* to open an ipv4 UDP multicast channel as an
} ReaderData;
// heartbeat interval, in seconds
-#define HEARTBEAT 30
-#define HEARTBEAT_MICROS ( HEARTBEAT * 1000000 )
+#define HEARTBEAT_MICROS ( heart_rate * 1000000 )
// Macros for timing, for struct timeval variables
#define TIME_MICROS(TM) (((int64_t) (TM)->tv_sec * 1000000) + (TM)->tv_usec )
static int udp_port;
static int threads_count = 0;
static int buffers_count = 0;
+static int heart_rate = 30;
// Setup for multicast channel
static struct {
return 0;
}
+static int parse_heartbeat_rate(char *arg) {
+ if ( ( sscanf( arg, "%u", &heart_rate ) != 1 ) || heart_rate < 0 ) {
+ return 1;
+ }
+ VERBOSEOUT( "** Heartbeat rate = %d\n", heart_rate );
+ return 0;
+}
+
static int parse_buffers_count(char *arg) {
if ( ( sscanf( arg, "%u", &buffers_count ) != 1 ) || buffers_count < 1 ) {
return 1;
r = (struct Remote *) tmp;
VERBOSE3OUT( "heartbeat check %s\n", inet_stoa( &r->uaddr ) );
if ( r->spec && is_uplink( r->spec ) ) {
- if ( DIFF_MICROS( &now, &r->rec_when ) > HEARTBEAT_MICROS ) {
+ if ( DIFF_MICROS( &now, &r->rec_when ) >= HEARTBEAT_MICROS ) {
VERBOSE3OUT( "heartbeat %s\n", inet_stoa( &r->uaddr ) );
write_remote( data, 0, r );
}
i += 2;
ENSUREARGS( 1 );
}
+ // then: optional -H seconds
+ if ( strncmp( "-H", argv[i], 2 ) == 0 ) {
+ ENSUREARGS( 2 );
+ if ( parse_heartbeat_rate( argv[i+1] ) ) {
+ usage();
+ }
+ i += 2;
+ ENSUREARGS( 1 );
+ }
// then: optional -m mcast
if ( strncmp( "-m", argv[i], 2 ) == 0 ) {
ENSUREARGS( 2 );
pthread_create( &thread, 0, doreadTap, &tap_reader );
}
- // Start heartbeating to uplinks
- for ( ;; ) {
- sleep( HEARTBEAT );
- heartbeat( udp_fd );
+ if ( heart_rate == 0 ) {
+ // Start heartbeating to uplinks
+ for ( ;; ) {
+ sleep( heart_rate );
+ heartbeat( udp_fd );
+ }
}
return 0;
}