|
NAMENet::RNDC::Packet - RNDC Protocol V1 Packet Parsing and GenerationVERSIONversion 0.003SYNOPSISTo send an RNDC command and get a response:use IO::Socket::INET; use Net::RNDC::Packet; my $buff; my $key = 'aabc'; my $c = IO::Socket::INET->new( PeerAddr => '127.0.0.1:953', ) or die "Failed to create a socket: $@ ($!)"; # Send opener packet my $pkt = Net::RNDC::Packet->new( key => $key, ); $c->send($pkt->data); # Read nonce response $c->recv($buff, 4096); $pkt->parse($buff); # Send command request with nonce my $nonce = $pkt->{data}->{_ctrl}{_nonce}; my $cmd = Net::RNDC::Packet->new( key => $key, nonce => $nonce, data => {type => 'status'}, ); $c->send($cmd->data); # Read final response $c->recv($buff, 4096); $cmd->parse($buff); my $resp = $cmd->{data}{_data}{text} || 'command success'; print "$resp\n"; DESCRIPTIONThis package provides low-level RNDC V1 protocol parsing and generation. It allows full control over the data in the sent/received packets.Currently this is provided by hacking at "$pkt->{data}", setter/getter methods will be forthcoming. Constructornewmy $packet = Net::RNDC::Packet->new(%args); Arguments:
Methodsdatamy $binary = $packet->data; Generates a binary representation of the packet, suitable for sending over the wire. parse if ($packet->parse($binary)) { ... } Parses data from the wire and populates the current packet with the information, as well as verifies the data with the provided key that was passed to the constructor. Returns 1 on success, 0 on failure. Check "error" if there's a failure. error my $err = $packet->error; Returns a string error, if any, after packet parsing or generation failed. TODO
SEE ALSONet::RNDC - Simple RNDC communication.Net::RNDC::Session - Manage the 4-packet RNDC session AUTHORMatthew Horsfall (alh) <WolfSage@gmail.com>LICENSEYou may distribute this code under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |