Lines Matching +full:assoc +full:- +full:select
1 #!/local/bin/perl --*-perl-*-
8 ;# Rainer Pruy Friedrich-Alexander Universitaet Erlangen-Nuernberg
15 select((select(STDERR),$|=1)[$[]);
48 die("usage: $0 [-p <port>] [-l <logfile>] [host] ...\n");
52 &Getopts if 0; # make -w happy
56 $opt_p = 0 # port to use locally - (0 does mean: will be chosen by kernel)
63 $DEBUGFILE="&STDERR" if $DEBUGFILE eq '-';
66 select((select(DEBUG),$|=1)[$[]);
150 warn "$0: unknown host \"$_\" - ignored\n";
177 grep(&debug(" - ".$_),keys(%Host));
181 $assoc=0;
198 ($addr,$assoc,$op) = unpack("a4SC",($req = shift(@Requests)));
199 &debug(sprintf("Request: %s: %s(%d)",&hostname($addr), &ntp'cntrlop_name($op), $assoc)); #';))
200 $ret = &ntp'send(S,$op,$assoc,"", #'(
202 &set_timeout("retry-".unpack("H*",$req),time+$BASE_TIMEOUT,
216 $timeout = $TIMEOUTS{$TIMEOUTS[$[]} - time;
223 ;# no work yet - wait for some messages dropping in
230 $ret = select($mask,undef,undef,$timeout);
232 warn("$0: select: $!\n"),last if $ret < 0; # give up on error return from select
256 ;# could check for ntp_port - but who cares
257 &debug("-Packet from ",&hostname($from));
269 &clear_timeout("retry-".unpack("H*",pack("a4SC",$from,$associd,$op))) unless $op == 7;
280 &clear_timeout("retry-".unpack("H*",pack("a4SC",$from,$associd,$op)));
332 &debug(sprintf("Retry failed: %s assoc %5d op %d",
337 &debug(sprintf("Retrying: %s assoc %5d op %d",
350 $msg .= sprintf("%40s trap#%-5d",
376 ($peer) = ($data =~ /peer=([0-9]+)/);
383 ($cstatus) = ($data =~ /refclockstatus=0?x?([\da-fA-F]+)/);
385 $msg .= sprintf("- %-32s",&ntp'clock_status($Cstatus)); #');
399 $msg .= sprintf("%-18s %40s ", "[$srcadr]",
408 ;#&debug("----\n$data\n====\n");
409 ($cstatus) = ($data =~ /refclockstatus=0?x?([\da-fA-F]+)/);
411 $msg .= sprintf("- %-32s",&ntp'clock_status($Cstatus)); #');
417 ;# no clockvars included - post a cv request
431 &set_timeout("refresh-".unpack("H*",$from),time+$REFRESH_TIME,
447 $msg .= sprintf("%-32s",&ntp'clock_status($status)); #');
456 &clear_timeout("refresh-".unpack("H*",$from));
461 $msg .= "unexpected response to op $op assoc=$associd";