Net::DHCP::Packet

Net::DHCP::Packet is a Perl module with object methods to create a DHCP packet.
Download

Net::DHCP::Packet Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Stephan Hadinger
  • Publisher web site:
  • http://search.cpan.org/~shadinger/Net-DHCP-0.66/lib/Net/DHCP/Packet.pm

Net::DHCP::Packet Tags


Net::DHCP::Packet Description

Net::DHCP::Packet is a Perl module with object methods to create a DHCP packet. Net::DHCP::Packet is a Perl module with object methods to create a DHCP packet.SYNOPSIS use Net::DHCP::Packet; my $p = new Net::DHCP::Packet->new( 'Chaddr' => '000BCDEF', 'Xid' => 0x9F0FD, 'Ciaddr' => '0.0.0.0', 'Siaddr' => '0.0.0.0', 'Hops' => 0);Represents a DHCP packet as specified in RFC 1533, RFC 2132.CONSTRUCTORThis module only provides basic constructor. For "easy" constructors, you can use the Net::DHCP::Session module.new( ) new( BUFFER ) new( ARG => VALUE, ARG => VALUE... )Creates an Net::DHCP::Packet object, which can be used to send or receive DHCP network packets. BOOTP is not supported.Without argument, a default empty packet is created. $packet = Net::DHCP::Packet();A BUFFER argument is interpreted as a binary buffer like one provided by the socket recv() function. if the packet is malformed, a fatal error is issued. use IO::Socket::INET; use Net::DHCP::Packet; $sock = IO::Socket::INET->new(LocalPort => 67, Proto => "udp", Broadcast => 1) or die "socket: $@"; while ($sock->recv($newmsg, 1024)) { $packet = Net::DHCP::Packet->new($newmsg); print $packet->toString(); }To create a fresh new packet new() takes arguments as a key-value pairs : ARGUMENT FIELD OCTETS DESCRIPTION -------- ----- ------ ----------- Op op 1 Message op code / message type. 1 = BOOTREQUEST, 2 = BOOTREPLY Htype htype 1 Hardware address type, see ARP section in "Assigned Numbers" RFC; e.g., '1' = 10mb ethernet. Hlen hlen 1 Hardware address length (e.g. '6' for 10mb ethernet). Hops hops 1 Client sets to zero, optionally used by relay agents when booting via a relay agent. Xid xid 4 Transaction ID, a random number chosen by the client, used by the client and server to associate messages and responses between a client and a server. Secs secs 2 Filled in by client, seconds elapsed since client began address acquisition or renewal process. Flags flags 2 Flags (see figure 2). Ciaddr ciaddr 4 Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests. Yiaddr yiaddr 4 'your' (client) IP address. Siaddr siaddr 4 IP address of next server to use in bootstrap; returned in DHCPOFFER, DHCPACK by server. Giaddr giaddr 4 Relay agent IP address, used in booting via a relay agent. Chaddr chaddr 16 Client hardware address. Sname sname 64 Optional server host name, null terminated string. File file 128 Boot file name, null terminated string; "generic" name or null in DHCPDISCOVER, fully qualified directory-path name in DHCPOFFER. IsDhcp isDhcp 4 Controls whether the packet is BOOTP or DHCP. DHCP conatains the "magic cookie" of 4 bytes. 0x63 0x82 0x53 0x63. DHO_*code Optional parameters field. See the options documents for a list of defined options. See Net::DHCP::Constants. Padding padding * Optional padding at the end of the packetSee below methods for values and syntax descrption.Note: DHCP options are created in the same order as key-value pairs. Requirements: · Perl


Net::DHCP::Packet Related Software