libnet-dhcp-perl-0.693+dfsg.orig/0000755000175000017500000000000012224056470016414 5ustar cstamascstamaslibnet-dhcp-perl-0.693+dfsg.orig/README0000755000175000017500000000456712037236123017310 0ustar cstamascstamasNet-DHCP version 0.66 ===================== 0. DOCS/ FILES WARNING ---------------------- Some files in the docs/ directory are copied from iana. They may not be compatible with the Perl license. I have included them in the tar ball as-is for the sake of reference. Please remove them if needed for distribution packaging etc. Currently these files are: - docs/bootp-dhcp-parameters.txt All other files are licensed as described at the bottom of this file. You can fork and submit enhancements etc via https://github.com/djzort/Net-DHCP Sorry, I know github sucks but its popular. 1. DESCRIPTION -------------- Net::DHCP is a DHCP set of classes designed to handle basic DHCP handling. It can be used to develop either client, server or relays. It is composed of 100% pure Perl. The author invites feedback on Net::DHCP. If there's something you'd like to have added, please let me know. If you find a bug, please send me the information described in the BUGS section below. The original version of this module was written by Francis van Dun, and has been deeply reorganized. 2. PREREQUISITES ---------------- Net::DHCP requires Perl 5.8.0 or higher. Net::DHCP has been tested with the following: Perl 5.8.5 Windows XP with cygwin Windows XP with ActivePerl RedHat Enterprise Linux 5.5 x86_64 CentOS Linux 5.5 x86_64 Debian Squeeze x86_64 (Perl 5.10.1) Debian Wheezy x86_64 (Perl 5.14.2) Plus CPAN testers 3. INSTALLATION --------------- To install this module type the following: perl Makefile.PL make make test make install 4. BUGS ------- This module has not been deeply tested and any usage in production DHCP client or server must be considered cautiously. If you find a bug, please report it to the author along with the following information: * version of Perl (output of 'perl -V' is best) * version of Net::DHCP * operating system type and version * exact text of error message or description of problem * the shortest possible program that exhibits the problem COPYRIGHT AND LICENCE Copyright (C) 2002 by Francis van Dun. Copyright (C) 2005,2006 by Stephan Hadinger. Copyright (C) 2010-2012 by Dean Hamstead. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. libnet-dhcp-perl-0.693+dfsg.orig/Changes0000755000175000017500000000773612037236123017724 0ustar cstamascstamasNet::DHCP - A DHCP packet object 0.693 2012-10-16 - Changes kindly sent in my Alexander Clouter - Allows static routes to be included in dhcp packets - (no tests yet) 0.692 2012-09-05 - Minor typo in pod 0.691 2012-08-24 - Updated changelog for Kawlitee 0.69 2012-06-06 - Added 'use warnings' to improve Kwalitee - Now uses dist::zilla 0.685 2012-05-21 - Removed file 0.684 2012-05-21 - Changed to using Dist::Zilla. 0.683 2012-01-21 - Still chasing the Build requires issue. 0.682 2012-01-21 - Minor update to tests sent in from Gregory Herrmann via RT#74187. Thanks for that! - Updated pod to complete coverage 0.681 2012-01-16 - Forgot to update MANIFEST file... woops. Also some po updates. 0.68 2012-01-14 - Added Net/DHCP.pm stub. 0.67_2 2011-04-18 - Updated pod. Please be awair that i have added the word "CableLabs" to to pod. This 05-be of concern to Debian. Im not sure how their licensing works exactly vs CableLabs copyrights. Im reasonably certain its aok. - Minor changes for RT#73972 - Improvements to tests 0.67_1 2010-12-16 - Warning: the declaration of DHO_NIS_DOMAIN was overlapping for options 40 options 64. Therefore, options 64 and 65 where renamed DHO_NISV3_SERVER and DHO_NISV3_DOMAIN to remove this overlap and remain consistent. - Constants.pm. Added a vast number of option codes from the IANA listing. - Added updated DHCP message codes, added Netware IP Codes. Tests were added for coverage of constants. - Packet.pm. Changed a whole bunch of stuff. Including removing some then then else orgies, tidying up lots of warnings. - Tests. I'd added a bunch more tests :) - Rearranged the test suite. Added lots of tests. 0.67 2010-11-13 - Fixing a small bug in marshall (see cpanrt61693), fixed a bug in Constants.pm (see cpanrt32962), clarified version dependance closing out cpanrt19405 0.66 2006-07-12 - Module is definitely not compatible with Perl 5.6.0. Minimum version is Perl 5.8.0. - Corrected major bug in removeOption(), thanks to Nathan Scarlett. 0.65 2006--04-22 - Added a sample DHCP Server and tester: dhcpd.pl & dhcpd_test.pl in the examples folder. 0.64 2006-03-06 - Added removeOption() function 0.63 2006-01-01 - Major bug corrected in Net::DHCP::Packet->new() while parsing attributes. 0.62 2005-10-07 - Minor change to make module compatible Perl 5.6.0 instead of only 5.8.0. 0.61 2005-04-29 - Changed minimal acceptable packet length in marshall() method. 0.60 2005-03-29 - Lots of tests added. - getOption() and addOption() removed and replaced by: * getOptionValue() & addOptionValue() which provide automatic type conversion to/from text representation * getOptionRaw() & addOptionRaw() to manipulate binary format packed into strings. - new() now behaves differently for DHCP options, requiring text values and not packed binary values. - toString() now escapes unprintable characters. - Added methods : ciaddrRaw, giaddrRaw, siaddrRaw, yiaddrRaw that use packed binary formats. They are provided for performance enhancements when you want to avoid unnecessary type conversion. - Pad options (0x00) are now supported. - Example of DHCPLeaseQuery provided by John A. Murphy. 0.53 2005-03-02 - Performance enhancement in Packet->new() avoirding unnecessary type conversion and function calls. - Support for DHCPLEASEQUERY, Cisco extension (draft-ietf-dhc-leasequery-05.txt). - Corrected bug in Packet->new() not allowing '0' in Hlen and Htype parameters. Thanks to John A. Murphy. 0.52 2005-04-24 - Performance enhancements in Packet.pm. 0.51 2005-04-20 - Added encoding and decoding functions for Relay Agent information (option 82 - RFC 3046). - Comment field added in the Packet object. This lets you put any comment in the Packet object, such as a transaction number. This field not processed. 0.50 2005-04-8 - Deeply rewritten version based on Net::DHCP v0.11 by Francis van Dun. - Net::DHCP::Session is momentarily missing, it should be reintroduced soon. libnet-dhcp-perl-0.693+dfsg.orig/LICENSE0000644000175000017500000004365312037236123017431 0ustar cstamascstamasThis software is copyright (c) 2012 by Dean Hamstad. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012 by Dean Hamstad. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012 by Dean Hamstad. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End libnet-dhcp-perl-0.693+dfsg.orig/dist.ini0000755000175000017500000000132212037236123020056 0ustar cstamascstamasname = Net-DHCP version = 0.693 author = Dean Hamstead license = Perl_5 copyright_holder = Dean Hamstad copyright_year = 2012 [GatherDir] [MetaYAML] [MetaJSON] [MetaTests] [Manifest] [ManifestSkip] [PruneCruft] [License] [ModuleBuild] [ExtraTests] [CPANFile] [Test::Perl::Critic] critic_config = t/.perlcriticrc [Test::Kwalitee] [Test::EOL] [PodCoverageTests] [PodSyntaxTests] [TestRelease] [ConfirmRelease] [UploadToCPAN] [Twitter] hash_tags = #perl #cpan [Prereqs] Exporter = 0 Socket = 0 Carp = 0 Scalar::Util = 0 List::Util = 0 strict = 0 warnings = 0 constant = 0 perl = 5.8.0 [Prereqs / TestRequires] Test::More = 0 Test::Warn = 0 File::Spec = 0 libnet-dhcp-perl-0.693+dfsg.orig/META.yml0000644000175000017500000000114212037236123017660 0ustar cstamascstamas--- abstract: 'Object methods to create a DHCP packet.' author: - 'Dean Hamstead ' build_requires: File::Spec: 0 Module::Build: 0.3601 Test::More: 0 Test::Warn: 0 configure_requires: Module::Build: 0.3601 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300025, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Net-DHCP requires: Carp: 0 Exporter: 0 List::Util: 0 Scalar::Util: 0 Socket: 0 constant: 0 perl: v5.8.0 strict: 0 warnings: 0 version: 0.693 libnet-dhcp-perl-0.693+dfsg.orig/MANIFEST0000644000175000017500000000124712224056470017551 0ustar cstamascstamasBuild.PL Changes LICENSE MANIFEST META.json META.yml README cpanfile dhcp.patch dist.ini examples/dhcp_sniffer.pl examples/dhcpd.pl examples/dhcpd_test.pl examples/dumpianatoxml.pl examples/l2tp-dhcp-inform examples/lease_query.pl examples/list_dho.pl examples/send_packet.pl lib/Net/DHCP/Constants.pm lib/Net/DHCP/Packet.pm t/00.load.t t/03.manifest.t t/21-net-dhcp-packet-packinet.t t/22-net-dhcp-packet-options.t t/30-net-dhcp-constants-coverage.t t/51-net-dhcp-packet-new-basic.t t/52-net-dhcp-packet-new-empty.t t/53-net-dhcp-packet-new-broken.t t/author-critic.t t/author-test-eol.t t/release-distmeta.t t/release-kwalitee.t t/release-pod-coverage.t t/release-pod-syntax.t libnet-dhcp-perl-0.693+dfsg.orig/cpanfile0000644000175000017500000000076612037236123020126 0ustar cstamascstamasrequires "Carp" => "0"; requires "Exporter" => "0"; requires "List::Util" => "0"; requires "Scalar::Util" => "0"; requires "Socket" => "0"; requires "constant" => "0"; requires "perl" => "v5.8.0"; requires "strict" => "0"; requires "warnings" => "0"; on 'build' => sub { requires "Module::Build" => "0.3601"; }; on 'test' => sub { requires "File::Spec" => "0"; requires "Test::More" => "0"; requires "Test::Warn" => "0"; }; on 'configure' => sub { requires "Module::Build" => "0.3601"; }; libnet-dhcp-perl-0.693+dfsg.orig/Build.PL0000644000175000017500000000160312037236123017705 0ustar cstamascstamas use strict; use warnings; use Module::Build 0.3601; my %module_build_args = ( "build_requires" => { "File::Spec" => 0, "Module::Build" => "0.3601", "Test::More" => 0, "Test::Warn" => 0 }, "configure_requires" => { "Module::Build" => "0.3601" }, "dist_abstract" => "Object methods to create a DHCP packet.", "dist_author" => [ "Dean Hamstead " ], "dist_name" => "Net-DHCP", "dist_version" => "0.693", "license" => "perl", "module_name" => "Net::DHCP", "recommends" => {}, "recursive_test_files" => 1, "requires" => { "Carp" => 0, "Exporter" => 0, "List::Util" => 0, "Scalar::Util" => 0, "Socket" => 0, "constant" => 0, "perl" => "v5.8.0", "strict" => 0, "warnings" => 0 }, "script_files" => [] ); my $build = Module::Build->new(%module_build_args); $build->create_build_script; libnet-dhcp-perl-0.693+dfsg.orig/META.json0000644000175000017500000000225112037236123020032 0ustar cstamascstamas{ "abstract" : "Object methods to create a DHCP packet.", "author" : [ "Dean Hamstead " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300025, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Net-DHCP", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.3601" } }, "configure" : { "requires" : { "Module::Build" : "0.3601" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "List::Util" : "0", "Scalar::Util" : "0", "Socket" : "0", "constant" : "0", "perl" : "v5.8.0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "Test::More" : "0", "Test::Warn" : "0" } } }, "release_status" : "stable", "version" : "0.693" } libnet-dhcp-perl-0.693+dfsg.orig/dhcp.patch0000644000175000017500000000725212037236123020356 0ustar cstamascstamasdiff --git a/lib/Net/DHCP/Constants.pm b/lib/Net/DHCP/Constants.pm index ee2e130..53dc4c4 100755 --- a/lib/Net/DHCP/Constants.pm +++ b/lib/Net/DHCP/Constants.pm @@ -236,6 +236,8 @@ BEGIN { 'DHO_SUBNET_ALLOCATION' => 220, 'DHO_VIRTUAL_SUBNET' => 221, + 'DHO_CLASSLESS_STATIC_ROUTE_MS' => 249, + 'DHO_END' => 255 ); @@ -352,6 +354,7 @@ use constant \%RELAYAGENT_CODES; # string : char* (just kidding) # relays : DHCP sub-options (rfc 3046) # ids : client identifier : byte (htype) + string (chaddr) +# csr : classless static routes (rfc 3442) # suboptions : hex encoded sub options # our %DHO_FORMATS = ( @@ -449,6 +452,8 @@ our %DHO_FORMATS = ( DHO_NAME_SERVICE_SEARCH() => 'shorts', # rfc 2937 DHO_SUBNET_SELECTION() => 'inet', # rfc 3011 + DHO_CLASSLESS_STATIC_ROUTE() => 'csr', # rfc 3442 + DHO_CLASSLESS_STATIC_ROUTE_MS() => 'csr', ); # Links option codes with their suboption values @@ -671,6 +676,7 @@ Import all DHCP option codes. (213) DHO_OPTION_V4_ACCESS_DOMAIN (220) DHO_SUBNET_ALLOCATION (221) DHO_VIRTUAL_SUBNET + (249) DHO_CLASSLESS_STATIC_ROUTE_MS (255) DHO_END =item * ccc_codes diff --git a/lib/Net/DHCP/Packet.pm b/lib/Net/DHCP/Packet.pm index f0f6259..f67caf0 100755 --- a/lib/Net/DHCP/Packet.pm +++ b/lib/Net/DHCP/Packet.pm @@ -361,7 +361,7 @@ sub addOptionValue { } # verify number of parameters - if ( $format eq 'string' ) { + if ( $format eq 'string' || $format eq 'csr' ) { @values = ($value); # don't change format } elsif ( $format =~ /s$/ ) @@ -391,6 +391,7 @@ sub addOptionValue { return pack( 'C*', map { 255 & $_ } @_ ); }, string => sub { return shift }, + csr => sub { return packcsr(shift) }, ); @@ -529,6 +530,7 @@ sub getOptionValue { byte => sub { return unpack( 'C', shift ) }, bytes => sub { return unpack( 'C*', shift ) }, string => sub { return shift }, + csr => sub { return unpackcsr(shift) }, ); @@ -656,8 +658,15 @@ sub serialize { if ( $self->{isDhcp} ) { # add MAGIC_COOKIE and options $bytes .= MAGIC_COOKIE(); for my $key ( @{ $self->{options_order} } ) { - $bytes .= pack( 'C', $key ); - $bytes .= pack( 'C/a*', $self->{options}->{$key} ); + if ( ref($self->{options}->{$key}) eq 'ARRAY' ) { + for my $value ( @{$self->{options}->{$key}} ) { + $bytes .= pack( 'C', $key ); + $bytes .= pack( 'C/a*', $value ); + } + } else { + $bytes .= pack( 'C', $key ); + $bytes .= pack( 'C/a*', $self->{options}->{$key} ); + } } $bytes .= pack( 'C', 255 ); } @@ -962,6 +971,36 @@ sub unpackRelayAgent { # prints a human readable 'relay agent options' } +sub packcsr { + # catch empty value + my $results = [ '' ]; + + for my $pair ( @{$_[0]} ) { + push @$results, '' + if (length($results->[-1]) > 255 - 8); + + my ($ip, $mask) = split /\//, $pair->[0]; + $mask = '32' + unless (defined($mask)); + + my $addr = packinet($ip); + $addr = substr $addr, 0, int(($mask - 1)/8 + 1); + + $results->[-1] .= pack('C', $mask) . $addr; + $results->[-1] .= packinet($pair->[1]); + } + + return $results; +} + +sub unpackcsr { + my $csr = shift + or return; + + croak('unpack csr field still WIP'); + +} + #======================================================================= 1; libnet-dhcp-perl-0.693+dfsg.orig/t/0000755000175000017500000000000012224056470016657 5ustar cstamascstamaslibnet-dhcp-perl-0.693+dfsg.orig/t/00.load.t0000755000175000017500000000044312037236123020202 0ustar cstamascstamasuse warnings; use strict; use Test::More tests => 2; BEGIN { use_ok( 'Net::DHCP::Packet' ) or BAIL_OUT('unable to load module') } BEGIN { use_ok( 'Net::DHCP::Constants' ) or BAIL_OUT('unable to load module') } diag( "Testing Net::DHCP::Packet $Net::DHCP::Packet::VERSION, Perl $], $^X" ); libnet-dhcp-perl-0.693+dfsg.orig/t/03.manifest.t0000755000175000017500000000050412037236123021072 0ustar cstamascstamasuse strict; use warnings; use Test::More; if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::CheckManifest 0.9"; plan skip_all => "Test::CheckManifest 0.9 required" if $@; ok_manifest({filter => [qr/\.svn|\.old$/]}); libnet-dhcp-perl-0.693+dfsg.orig/t/author-critic.t0000644000175000017500000000067212037236123021623 0ustar cstamascstamas#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "t/.perlcriticrc" ) if -e "t/.perlcriticrc"; all_critic_ok(); libnet-dhcp-perl-0.693+dfsg.orig/t/author-test-eol.t0000644000175000017500000000061512037236123022077 0ustar cstamascstamas BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::EOL 0.07 eval "use Test::EOL; 1;" or die $@; # ^^ hack to get around prereqscanner detection, remove someday all_perl_files_ok({ trailing_whitespace => 1 }); libnet-dhcp-perl-0.693+dfsg.orig/t/release-distmeta.t0000644000175000017500000000045512037236123022275 0ustar cstamascstamas#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; meta_yaml_ok(); libnet-dhcp-perl-0.693+dfsg.orig/t/release-kwalitee.t0000644000175000017500000000061712037236123022270 0ustar cstamascstamas#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This test is generated by Dist::Zilla::Plugin::Test::Kwalitee use strict; use warnings; use Test::More; # needed to provide plan. eval "use Test::Kwalitee"; plan skip_all => "Test::Kwalitee required for testing kwalitee" if $@; libnet-dhcp-perl-0.693+dfsg.orig/t/release-pod-syntax.t0000644000175000017500000000045012037236123022564 0ustar cstamascstamas#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); libnet-dhcp-perl-0.693+dfsg.orig/t/release-pod-coverage.t0000644000175000017500000000076512037236123023042 0ustar cstamascstamas#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); libnet-dhcp-perl-0.693+dfsg.orig/t/22-net-dhcp-packet-options.t0000755000175000017500000001451612037236123023734 0ustar cstamascstamas#!/usr/bin/perl -wT use Test::More tests => 51; BEGIN { use_ok( 'Net::DHCP::Packet' ); } BEGIN { use_ok( 'Net::DHCP::Constants' ); } use strict; my $ip0 = '0.0.0.0'; my $pac0 = '\0\0\0\0'; my $foo = 'foobar'; my $pac; my @arr; $pac = Net::DHCP::Packet->new(); # dhcp message type $pac->addOptionValue(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); is($pac->getOptionValue(DHO_DHCP_MESSAGE_TYPE()), DHCPINFORM(), 'testing message type'); is($pac->getOptionRaw(DHO_DHCP_MESSAGE_TYPE()), chr(DHCPINFORM())); $pac = Net::DHCP::Packet->new(); is($pac->getOptionValue(DHO_SUBNET_MASK()), undef, 'testing inet format'); # test for 'inet' data type $pac->addOptionValue(DHO_SUBNET_MASK(), "255.255.255.0"); is($pac->getOptionValue(DHO_SUBNET_MASK()), "255.255.255.0"); is($pac->getOptionRaw(DHO_SUBNET_MASK()), "\xFF\xFF\xFF\0"); $pac->addOptionRaw(DHO_SUBNET_MASK(), "\xFF\xFF\xFF\0"); is($pac->getOptionValue(DHO_SUBNET_MASK()), "255.255.255.0"); is($pac->getOptionRaw(DHO_SUBNET_MASK()), "\xFF\xFF\xFF\0"); # exceptions eval { $pac->addOptionValue(DHO_SUBNET_MASK()); }; like( $@, qr/addOptionValue: exactly one value expected/); eval { $pac->addOptionValue(DHO_SUBNET_MASK(), undef); }; like( $@, qr/addOptionValue: exactly one value expected/); eval { $pac->addOptionValue(DHO_SUBNET_MASK(), "255.255.255.0 255.255.255.0"); }; like( $@, qr/addOptionValue: exactly one value expected/); $pac = Net::DHCP::Packet->new(); is($pac->getOptionValue(DHO_NAME_SERVERS()), undef, "testing inets format"); # test for 'inets' data type $pac->addOptionValue(DHO_NAME_SERVERS(), "1.2.3.15 4.5.6.14"); is($pac->getOptionRaw(DHO_NAME_SERVERS()), "\1\2\3\x0F\4\5\6\x0E"); is($pac->getOptionValue(DHO_NAME_SERVERS()), "1.2.3.15 4.5.6.14"); # empty $pac->addOptionValue(DHO_NAME_SERVERS()); is($pac->getOptionValue(DHO_NAME_SERVERS()), undef); $pac = Net::DHCP::Packet->new(); is($pac->getOptionValue(DHO_STATIC_ROUTES()), undef, "testing inets2 format"); # test for 'inet2' data type $pac->addOptionValue(DHO_STATIC_ROUTES(), "1.2.3.15 4.5.6.14"); is($pac->getOptionRaw(DHO_STATIC_ROUTES()), "\1\2\3\x0F\4\5\6\x0E"); is($pac->getOptionValue(DHO_STATIC_ROUTES()), "1.2.3.15 4.5.6.14"); # empty $pac->addOptionValue(DHO_STATIC_ROUTES()); is($pac->getOptionValue(DHO_STATIC_ROUTES()), undef); # exceptions eval { $pac->addOptionValue(DHO_STATIC_ROUTES()); }; ok( ! $@ ); eval { $pac->addOptionValue(DHO_STATIC_ROUTES(), undef); }; ok( ! $@ ); eval { $pac->addOptionValue(DHO_STATIC_ROUTES(), "255.255.255.0"); }; like( $@, qr/addOptionValue: only pairs of values expected/); $pac = Net::DHCP::Packet->new(); # test for 'int' format $pac->addOptionValue(DHO_DHCP_RENEWAL_TIME(), 0x12345678); is($pac->getOptionValue(DHO_DHCP_RENEWAL_TIME()), 0x12345678, "testing int format"); is($pac->getOptionRaw(DHO_DHCP_RENEWAL_TIME()), "\x12\x34\x56\x78"); eval { $pac->addOptionValue(DHO_DHCP_RENEWAL_TIME(), undef); } ; like( $@, qr/addOptionValue: exactly one value expected/); $pac = Net::DHCP::Packet->new(); # test for 'short' format $pac->addOptionValue(DHO_INTERFACE_MTU(), 0x12345678); is($pac->getOptionValue(DHO_INTERFACE_MTU()), 0x5678, 'testing short format 0x5678'); is($pac->getOptionRaw( DHO_INTERFACE_MTU()), "\x56\x78", 'testing short format \x56\x78'); eval { $pac->addOptionValue(DHO_INTERFACE_MTU(), undef); }; like( $@, qr/addOptionValue: exactly one value expected/, 'testing short format undef'); $pac = Net::DHCP::Packet->new(); # test for 'byte' format $pac->addOptionValue(DHO_DEFAULT_TCP_TTL(), 0x12345678); is($pac->getOptionValue(DHO_DEFAULT_TCP_TTL()), 0x78, 'testing byte format 0x78'); is($pac->getOptionRaw( DHO_DEFAULT_TCP_TTL()), "\x78", 'testing byte format \x78'); eval { $pac->addOptionValue(DHO_DEFAULT_TCP_TTL(), undef); }; like( $@, qr/addOptionValue: exactly one value expected/, 'testing byte format undef'); $pac = Net::DHCP::Packet->new(); is($pac->getOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST()), undef, 'testing bytes format is init\'d as empty'); # test for 'bytes' format $pac->addOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST(), "1 3 5 1278 ".0xFFFFFFFF,); is($pac->getOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST()), '1 3 5 254 255', 'testing bytes format with some integers, a wrap and a hex'); is($pac->getOptionRaw(DHO_DHCP_PARAMETER_REQUEST_LIST()), "\x01\x03\x05\xFE\xFF", 'testing bytes format as above, using hex format'); $pac->addOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST(), undef); is($pac->getOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST()), q(), 'testing bytes format, clearing with undef'); $pac = Net::DHCP::Packet->new(); # test for 'string' format $pac->addOptionValue(DHO_TFTP_SERVER(), $foo); is($pac->getOptionValue(DHO_TFTP_SERVER()), $foo, "testing string format"); is($pac->getOptionRaw(DHO_TFTP_SERVER()), $foo); eval { $pac->addOptionValue(DHO_TFTP_SERVER(), undef); }; is($pac->getOptionRaw(DHO_TFTP_SERVER()), undef); $pac = Net::DHCP::Packet->new(); # test for 'relays' format #my @relay = ( 1 => 'foo', 2 => 'bar', 3 => 'baz'); #$pac->addOptionValue(DHO_DHCP_AGENT_OPTIONS(), @relay); #my @relay2 = $pac->getOptionValue(DHO_DHCP_AGENT_OPTIONS()); #is_deeply(\@relay2, \@relay, "testing relays format"); # added removeOption as of version 0.64 $pac = Net::DHCP::Packet->new(); $pac->addOptionValue(DHO_DEFAULT_TCP_TTL(), 0x78); $pac->addOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST(), "1 3 5 254 255"); $pac->addOptionValue(DHO_TFTP_SERVER(), $foo); is($pac->getOptionValue(DHO_TFTP_SERVER()), $foo, "testing option removal"); is($pac->getOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST()), '1 3 5 254 255'); is($pac->getOptionValue(DHO_DEFAULT_TCP_TTL()), 0x78); # now remove one middle one $pac->removeOption(DHO_DHCP_PARAMETER_REQUEST_LIST()); is($pac->getOptionValue(DHO_TFTP_SERVER()), $foo); is($pac->getOptionRaw(DHO_DHCP_PARAMETER_REQUEST_LIST()), undef); is($pac->getOptionValue(DHO_DEFAULT_TCP_TTL()), 0x78); # remove again and undefs $pac->removeOption(DHO_DHCP_PARAMETER_REQUEST_LIST()); $pac->removeOption(DHO_STATIC_ROUTES()); # remove first value $pac->removeOption(DHO_TFTP_SERVER()); is($pac->getOptionRaw(DHO_TFTP_SERVER()), undef); is($pac->getOptionRaw(DHO_DHCP_PARAMETER_REQUEST_LIST()), undef); is($pac->getOptionValue(DHO_DEFAULT_TCP_TTL()), 0x78); # remove last $pac->removeOption(DHO_DEFAULT_TCP_TTL()); is($pac->getOptionRaw(DHO_TFTP_SERVER()), undef); is($pac->getOptionRaw(DHO_DHCP_PARAMETER_REQUEST_LIST()), undef); is($pac->getOptionRaw(DHO_DEFAULT_TCP_TTL()), undef); libnet-dhcp-perl-0.693+dfsg.orig/t/21-net-dhcp-packet-packinet.t0000755000175000017500000000361312037236123024032 0ustar cstamascstamas#!/usr/bin/perl -wT use Test::More tests => 39; BEGIN { use_ok( 'Net::DHCP::Packet' ); } BEGIN { use_ok( 'Net::DHCP::Constants' ); } use strict; my $pac1 = "\0\0\0\0"; my $pac2 = "\1\2\3\4"; my $pac3 = "\1\2\3\4\5\6"; my $pac4 = "\1\2"; my $pac5 = "\1\2\0\0"; my $ip1 = "0.0.0.0"; my $ip2 = "1.2.3.4"; my $ip3 = "1.2.3.4.5.6"; my $ip4 = " 1 . 2 . 3 . \t4 "; my $ip5 = "1.2.0.0"; is( packinet($ip1), $pac1, 'packinet 1'); is( packinet($ip2), $pac2 ,'packinet 2'); is( packinet($ip3), $pac2); is( packinet($ip4), $pac1); is( packinet(undef), $pac1); is( packinet(q||), $pac1); is( packinet(0), $pac1); is( packinet(0x04030201), $pac1); is( unpackinet($pac1), $ip1, 'unpackinet'); is( unpackinet($pac2), $ip2); is( unpackinet($pac3), $ip1); is( unpackinet($pac4), $ip1); is( unpackinet(undef), $ip1); is( unpackinet(q||), $ip1); is( unpackinet(0), $ip1); is( unpackinet(0x04030201), $ip1); is( packinets("$ip1 $ip1"), $pac1.$pac1, "packinets"); is( packinets("$ip2 $ip5"), $pac2.$pac5); is( packinets("$ip1,$ip2;$ip1/$ip2\t$ip1;;;$ip2"), $pac1.$pac2.$pac1.$pac2.$pac1.$pac2); is( packinets($ip1), $pac1); is( packinets($ip2), $pac2); is( packinets($ip3), $pac2); is( packinets($ip4), $pac1 x 8); is( packinets($ip5), $pac5); is( packinets(undef), $pac1,'packinets undef returns 0.0.0.0'); is( packinets(''), $pac1,'packinets "" returns 0.0.0.0'); is( packinets(0), $pac1,'0 goes to 0.0.0.0'); is( unpackinets($pac1), $ip1, "unpackinets"); is( unpackinets($pac2), $ip2); is( unpackinets($pac3), "$ip2 $ip1"); is( unpackinets($pac4), $ip1); is( unpackinets(undef), $ip1); is( unpackinets(''), $ip1); is( unpackinets(0), $ip1); is( unpackinets(0x04030201), '54.55.51.48 53.57.56.53'); # decimal value 67305985 my @arr; @arr = Net::DHCP::Packet::unpackinets_array($pac3); is_deeply( \@arr, [$ip2, $ip1], 'unpackinets_array'); @arr = ($ip2, $ip5); is( Net::DHCP::Packet::packinets_array(@arr), $pac2.$pac5, 'packinets_array'); libnet-dhcp-perl-0.693+dfsg.orig/t/51-net-dhcp-packet-new-basic.t0000755000175000017500000001076412037236123024114 0ustar cstamascstamas#!/usr/bin/perl -wT use Test::More tests => 33; use Test::Warn; BEGIN { use_ok('Net::DHCP::Packet'); } BEGIN { use_ok('Net::DHCP::Constants'); } use strict; my $str200 = '1234567890' x 20; my $pac; my $ref_packet = pack( 'H*', '0101060011223344000080000a0000010a0000020a0000030a00000400112233' . '445566778899aabbccddeeff3132333435363738393031323334353637383930' . '3132333435363738393031323334353637383930313233343536373839303132' . '3334353637383930313233003132333435363738393031323334353637383930' . '3132333435363738393031323334353637383930313233343536373839303132' . '3334353637383930313233343536373839303132333435363738393031323334' . '3536373839303132333435363738393031323334353637383930313233343536' . '3738393031323334353637006382536335010136040c22384433040001518001' . '04ffffff0003040a0000fe210816212c370a0000fe2a040a00000548040a0000' . '06ff000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '0000' ); my $packet; warnings_are { $packet = Net::DHCP::Packet->new( op => BOOTREQUEST(), Htype => HTYPE_ETHER(), Hlen => 6, Hops => 0, Xid => 0x11223344, Flags => 0x8000, Ciaddr => '10.0.0.1', Yiaddr => '10.0.0.2', Siaddr => '10.0.0.3', Giaddr => '10.0.0.4', Chaddr => '00112233445566778899AABBCCDDEEFF00', Sname => $str200, File => $str200, DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER(), DHO_DHCP_SERVER_IDENTIFIER() => '12.34.56.68', DHO_DHCP_LEASE_TIME() => 86400, DHO_SUBNET_MASK() => '255.255.255.0', DHO_ROUTERS() => '10.0.0.254', DHO_STATIC_ROUTES() => '22.33.44.55 10.0.0.254', DHO_NTP_SERVERS() => '10.0.0.5', DHO_WWW_SERVER() => '10.0.0.6', Padding => "\x00" x 256 ); } [ q|'sname' must not be > 63 bytes, (currently 200)|, q|'file' must not be > 127 bytes, (currently 200)| ]; my $packet2 = Net::DHCP::Packet->new($ref_packet); #diag($packet2->toString()); #diag(unpack("H*", $packet->serialize())); is( $packet2->serialize(), $ref_packet, 'comparing with reference packet' ); $pac = Net::DHCP::Packet->new($ref_packet); is( $pac->comment(), undef, 'comparing each attribute' ); is( $pac->op(), BOOTREQUEST() ); is( $pac->htype(), HTYPE_ETHER() ); is( $pac->hlen(), 6 ); is( $pac->hops(), 0 ); is( $pac->xid(), 0x11223344 ); is( $pac->flags(), 0x8000 ); is( $pac->ciaddr(), '10.0.0.1' ); is( $pac->ciaddrRaw(), "\x0a\x00\x00\x01" ); is( $pac->yiaddr(), '10.0.0.2' ); is( $pac->yiaddrRaw(), "\x0a\x00\x00\x02" ); is( $pac->siaddr(), '10.0.0.3' ); is( $pac->siaddrRaw(), "\x0a\x00\x00\x03" ); is( $pac->giaddr(), '10.0.0.4' ); is( $pac->giaddrRaw(), "\x0a\x00\x00\x04" ); is( $pac->chaddr(), '00112233445566778899aabbccddeeff' ); is( $pac->chaddrRaw(), "\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff" ); is( $pac->sname(), substr( $str200, 0, 63 ) ); is( $pac->file(), substr( $str200, 0, 127 ) ); is( $pac->padding(), "\x00" x 256 ); is( $pac->isDhcp(), 1 ); is( $pac->getOptionValue( DHO_DHCP_MESSAGE_TYPE() ), DHCPDISCOVER() ); is( $pac->getOptionValue( DHO_DHCP_SERVER_IDENTIFIER() ), '12.34.56.68' ); is( $pac->getOptionValue( DHO_DHCP_LEASE_TIME() ), 86400 ); is( $pac->getOptionValue( DHO_SUBNET_MASK() ), '255.255.255.0' ); is( $pac->getOptionValue( DHO_ROUTERS() ), '10.0.0.254' ); is( $pac->getOptionValue( DHO_STATIC_ROUTES() ), '22.33.44.55 10.0.0.254' ); is( $pac->getOptionValue( DHO_WWW_SERVER() ), '10.0.0.6' ); is( $pac->getOptionValue( DHO_IRC_SERVER() ), undef ); libnet-dhcp-perl-0.693+dfsg.orig/t/52-net-dhcp-packet-new-empty.t0000755000175000017500000000343712037236123024171 0ustar cstamascstamas#!/usr/bin/perl -wT use Test::More tests => 24; BEGIN { use_ok( 'Net::DHCP::Packet' ); } BEGIN { use_ok( 'Net::DHCP::Constants' ); } use strict; my $ip0 = "0.0.0.0"; my $pac0 = "\0\0\0\0"; my $ref_pac = pack("H*", "0101060012345678000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "00000000000000000000000063825363ff000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "000000000000000000000000" ); my $pac = Net::DHCP::Packet->new(); is( $pac->comment(), undef, "new empty packet"); is( $pac->op(), BOOTREQUEST()); is( $pac->htype(), 1); is( $pac->hlen(), 6); is( $pac->hops(), 0); is( $pac->xid(), 0x12345678); is( $pac->secs(), 0); is( $pac->ciaddr(), $ip0); is( $pac->ciaddrRaw(), $pac0); is( $pac->yiaddr(), $ip0); is( $pac->yiaddrRaw(), $pac0); is( $pac->siaddr(), $ip0); is( $pac->siaddrRaw(), $pac0); is( $pac->giaddr(), $ip0); is( $pac->giaddrRaw(), $pac0); is( $pac->chaddr(), ""); is( $pac->sname(), ""); is( $pac->file(), ""); is( $pac->padding(), ""); is( $pac->isDhcp(), 1); ok( !defined($pac->getOptionRaw(DHO_DHCP_MESSAGE_TYPE())), "undefined message type"); #diag(unpack("H*", $pac->serialize())); #diag("Packet lenght: ".length($pac->serialize())); is( $pac->serialize(), $ref_pac, "compare to reference packet");libnet-dhcp-perl-0.693+dfsg.orig/t/53-net-dhcp-packet-new-broken.t0000755000175000017500000000571612037236123024316 0ustar cstamascstamas#!/usr/bin/perl -wT use Test::More tests => 11; BEGIN { use_ok( 'Net::DHCP::Packet' ); } BEGIN { use_ok( 'Net::DHCP::Constants' ); } use strict; my $ip0 = "0.0.0.0"; my $pac0 = "\0\0\0\0"; my $pac; eval { $pac = Net::DHCP::Packet->new(""); }; #diag($@); like( $@, qr/marshall: packet too small/, "packet too small"); eval { $pac = Net::DHCP::Packet->new("\0" x 2000); }; #diag($@); like( $@, qr/marshall: packet too big/, "packet too big"); eval { $pac = Net::DHCP::Packet->new( Net::DHCP::Packet->new()->serialize()); }; #diag($@); ok( ! $@, "verifying default packet"); my $pac_without_option_end = pack("H*", "0101060012345678000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000006382536300000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "000000000000000000000000" ); eval { $pac = Net::DHCP::Packet->new($pac_without_option_end); }; #diag($@); like( $@, qr/marshall: unexpected end of options/, "marshall: unexpected end of options"); # now test serialize $pac = Net::DHCP::Packet->new(); $pac->padding("\0" x 2000); eval { $pac->serialize(); }; #diag($@); like($@, qr/serialize: packet too big/, "serialize: packet too big"); # testing DHO_DHCP_MAX_MESSAGE_SIZE conformance my %options = ( DHO_DHCP_MAX_MESSAGE_SIZE() => 200); my $ref_pac = pack("H*", "0101060012345678000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "00000000000000000000000063825363ff000000000000000000000000000000". "0000000000000000000000000000000000000000000000000000000000000000". "00000000000000000000000000000000" ); $pac = Net::DHCP::Packet->new($ref_pac); eval { $pac->serialize(\%options); }; #diag($@); ok( ! $@, "DHO_DHCP_MAX_MESSAGE_SIZE too small"); $options{DHO_DHCP_MAX_MESSAGE_SIZE()} = 2000; eval { $pac->serialize(\%options); }; #diag($@); ok( ! $@, "DHO_DHCP_MAX_MESSAGE_SIZE too big"); $options{DHO_DHCP_MAX_MESSAGE_SIZE()} = 305; eval { $pac->serialize(\%options); }; #diag($@); ok( ! $@, "DHO_DHCP_MAX_MESSAGE_SIZE is ok"); $options{DHO_DHCP_MAX_MESSAGE_SIZE()} = 302; eval { $pac->serialize(\%options); }; #diag($@); like($@, qr/serialize: message is bigger than allowed/, "serialize: packet too big"); libnet-dhcp-perl-0.693+dfsg.orig/t/30-net-dhcp-constants-coverage.t0000755000175000017500000001214312037236123024572 0ustar cstamascstamas#!/usr/bin/perl use Test::More tests => 207; BEGIN { use_ok('Net::DHCP::Constants'); } use Net::DHCP::Constants qw(%DHO_CODES %DHCP_MESSAGE %NWIP_CODES %CCC_CODES %GEOCONF_CODES %RELAYAGENT_CODES); use strict; use warnings; # load in the iana definitions my %iana; eval { our $VAR1; for my $file (qw( ./.iana.pl ../t/.iana.pl t/.iana.pl )) { require $file if -f $file; } die "couldnt load iana file" unless ref $VAR1; %iana = %$VAR1; }; SKIP: { skip( q|Couldn't load iana details, skipping coverage|, 206 ) if $@; # check that all iana codes are included # DHO CODES - bootp-dhcp-parameters-1 { my @val = values %DHO_CODES; my $codes = $iana{registry}->{'bootp-dhcp-parameters-1'} ->{record}; # this is mildy nasty for my $k ( sort { int $codes->{$a}->{value} <=> int $codes->{$b}->{value} } grep { $_ !~ m/unassigned|private use/i } keys %$codes ) { my $name = $k; $name =~ s/\n+//; my $value = int $codes->{$k}->{value}; ok( ( grep { $value == $_ } @val ), "\%DHO_CODES has $value aka $name" ); } } ## MESSAGE TYPES - bootp-dhcp-parameters-2 { my $codes = $iana{registry}->{'bootp-dhcp-parameters-1'}->{registry} ->{'bootp-dhcp-parameters-2'}->{record}; # this is mildy nasty for my $k ( sort { int $codes->{$a}->{value} <=> int $codes->{$b}->{value} } keys %$codes ) { ok( $DHCP_MESSAGE{$k}, "\%DHCP_MESSAGE has $k" ); ok( $DHCP_MESSAGE{$k} == int $codes->{$k}->{value}, "...and $k is " . $codes->{$k}->{value} ); } } ## NWIP CODES - bootp-dhcp-parameters-3 { my @val = values %NWIP_CODES; my $codes = $iana{registry}->{'bootp-dhcp-parameters-1'}->{registry} ->{'bootp-dhcp-parameters-3'}->{record}; # this is mildy nasty for my $k ( sort { int $codes->{$a}->{value} <=> int $codes->{$b}->{value} } grep { $_ !~ m/unassigned|private use/i } keys %$codes ) { my $name = $k; $name =~ s/\n+//; my $value = int $codes->{$k}->{value}; ok( ( grep { $value == $_ } @val ), "\%NWIP_CODES has $value aka $name" ); #die unless (grep {$value == $_} @val); } } ## CCC CODES - bootp-dhcp-parameters-4 { my @val = values %CCC_CODES; my $codes = $iana{registry}->{'bootp-dhcp-parameters-1'}->{registry} ->{'bootp-dhcp-parameters-4'}->{record}; # this is mildy nasty for my $k ( sort { int $a->{value} <=> int $b->{value} } grep { $_->{description} !~ m/unassigned|private use/i } @$codes ) { my $name = $k->{description}; $name =~ s/\n+//; my $value = $k->{value}; ok( ( grep { $value == $_ } @val ), "\%CCC_CODES has $value aka $name" ); #die unless (grep {$value == $_} @val); } } ## GEOCONF CODES - bootp-dhcp-parameters-5 { my @val = values %CCC_CODES; my $codes = $iana{registry}->{'bootp-dhcp-parameters-1'}->{registry} ->{'bootp-dhcp-parameters-5'}->{record}; # this is mildy nasty for my $k ( sort { int $a->{value} <=> int $b->{value} } grep { $_->{description} !~ m/unassigned|private use/i } @$codes ) { my $name = $k->{description}; $name =~ s/\n+//; my $value = $k->{value}; ok( ( grep { $value == $_ } @val ), "\%GEOCONF_CODES has $value aka $name" ); #die unless (grep {$value == $_} @val); } } ## GEOCONF CODES - bootp-dhcp-parameters-6 # im not quite sure what to do with geoconf ## CCC PacketCable mask bits. also not sure - bootp-dhcp-parameters-7 ## DHCP RELAY SUB OPTIONS CODES - bootp-dhcp-parameters-8 { my @val = values %RELAYAGENT_CODES; my $codes = $iana{registry}->{'bootp-dhcp-parameters-8'} ->{record}; # this is mildy nasty for my $k ( sort { int $a->{value} <=> int $b->{value} } grep { $_->{description} !~ m/unassigned|private use|reserved/i } @$codes ) { my $name = $k->{description}; $name =~ s/\n+//; my $value = $k->{value}; ok( ( grep { $value == $_ } @val ), "\%RELAYAGENT_CODES has $value aka $name" ); #die unless (grep {$value == $_} @val); } } ## DHCP RELAY SUB OPTIONS CODES - suboptions are defined in - bootp-dhcp-parameters-9 ## DHCP RELAY SUB OPTIONS CODES - suboptions are defined in - bootp-dhcp-parameters-10 # neither of which i have any idea what to do with yet } 1; libnet-dhcp-perl-0.693+dfsg.orig/examples/0000755000175000017500000000000012224056470020232 5ustar cstamascstamaslibnet-dhcp-perl-0.693+dfsg.orig/examples/dhcpd.pl0000755000175000017500000001403612037236123021655 0ustar cstamascstamas#!/usr/bin/perl ## >>--------------------------------------------------------------------------------- use strict; use Sys::Hostname; use Socket; use Net::DHCP::Packet; use Net::DHCP::Constants; use POSIX qw(setsid strftime); use IO::Socket::INET; # sample logger sub logger{ my $str = shift; print STDOUT strftime "[%d/%b/%Y:%H:%M:%S] ", localtime; print STDOUT "$str\n"; } logger("Starting dhcpd"); my $DAEMON = 0; # run as daemon ? # accept only from selected VENDOR classes (avoids messing existing networks) my $VENDOR_ACCEPTED = "foo|bar"; # broadcast address my $bcastaddr = sockaddr_in("68",INADDR_BROADCAST); # get a flag to force daemon to stop my $time_to_die = 0; # generic signal handler to cause daemon to stop sub signal_handler { $time_to_die = 1; } $SIG{INT} = $SIG{TERM} = $SIG{HUP} = \&signal_handler; # trap or ignore $SIG{PIPE} # Daemon behaviour # ignore any PIPE signal: standard behaviour is to quit process $SIG{PIPE} = 'IGNORE'; # open listening socket my $sock_in = IO::Socket::INET->new( LocalPort => 67, LocalAddr => "127.0.0.1", Proto => 'udp') || die "Socket creation error: $@\n"; if ($DAEMON) { # doesn't seem to work very well on cygwin logger("Entering Daemon mode"); chdir '/' or die "Can't chdir to /: $!"; umask 0; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!"; my $pid = fork; exit if $pid; die "Couldn't fork: $!" unless defined($pid); POSIX::setsid() or die "Can't start a new session: $!"; logger("Now in Daemon mode"); } logger("Initialization complete"); # main loop # # process incoming packets my $transaction = 0; # report transaction number until ($time_to_die) { my $buf = undef; my $fromaddr; # address & port from which packet was received my $dhcpreq; eval { # catch fatal errors logger("Waiting for incoming packet"); # receive packet $fromaddr = $sock_in->recv($buf,4096) || logger("recv:$!"); next if ($!); # continue loop if an error occured $transaction++; # transaction counter { use bytes; my ($port,$addr) = unpack_sockaddr_in($fromaddr); my $ipaddr = inet_ntoa($addr); logger("Got a packet tr=$transaction src=$ipaddr:$port length=".length($buf)); } my $dhcpreq = new Net::DHCP::Packet($buf); $dhcpreq->comment($transaction); my $messagetype = $dhcpreq->getOptionValue(DHO_DHCP_MESSAGE_TYPE()); if ($messagetype eq DHCPDISCOVER()) { do_discover($dhcpreq); } elsif ($messagetype eq DHCPREQUEST()) { do_request($dhcpreq); } elsif ($messagetype eq DHCPINFORM()) { } else { logger("Packet dropped"); # bad messagetype, we drop it } }; # end of 'eval' blocks if ($@) { logger("Caught error in main loop:$@"); } } logger("Exiting dhcpd"); #======================================================================= sub do_discover($) { my ($dhcpreq) = @_; my $sock_out; my ($calc_ip, $calc_router, $calc_mask); # calculate address $calc_ip = "12.34.56.78"; my $vendor = $dhcpreq->getOptionValue(DHO_VENDOR_CLASS_IDENTIFIER()); if ($vendor !~ $VENDOR_ACCEPTED) { logger("DISCOVER rejected, unsupported VENDOR class"); return; # dropping packet } my $dhcpresp = new Net::DHCP::Packet( Comment => $dhcpreq->comment(), Op => BOOTREPLY(), Hops => $dhcpreq->hops(), Xid => $dhcpreq->xid(), Flags => $dhcpreq->flags(), Ciaddr => $dhcpreq->ciaddr(), Yiaddr => $calc_ip, Siaddr => $dhcpreq->siaddr(), Giaddr => $dhcpreq->giaddr(), Chaddr => $dhcpreq->chaddr(), DHO_DHCP_MESSAGE_TYPE() => DHCPOFFER(), ); logger("Sending response"); # Socket object keeps track of whom sent last packet # so we don't need to specify target address logger("Sending OFFER tr=".$dhcpresp->comment()); $sock_in->send($dhcpresp->serialize()) || die "Error sending OFFER:$!\n"; # TODO: you have to choose between sending back to sender or broadcasting to network } #======================================================================= sub do_request($) { my ($dhcpreq) = @_; my $sock_out; my $calc_ip; my $dhcpresp; $calc_ip = "12.34.56.78"; my $vendor = $dhcpreq->getOptionValue(DHO_VENDOR_CLASS_IDENTIFIER()); if ($vendor !~ $VENDOR_ACCEPTED) { logger("REQUEST rejected, unsupported VENDOR class"); return; # dropping packet } # compare calculated address with requested address if ($calc_ip eq $dhcpreq->getOptionValue(DHO_DHCP_REQUESTED_ADDRESS())) { # address is correct, we send an ACK $dhcpresp = new Net::DHCP::Packet( Comment => $dhcpreq->comment(), Op => BOOTREPLY(), Hops => $dhcpreq->hops(), Xid => $dhcpreq->xid(), Flags => $dhcpreq->flags(), Ciaddr => $dhcpreq->ciaddr(), Yiaddr => $calc_ip, Siaddr => $dhcpreq->siaddr(), Giaddr => $dhcpreq->giaddr(), Chaddr => $dhcpreq->chaddr(), DHO_DHCP_MESSAGE_TYPE() => DHCPACK(), ); } else { # bad request, we send a NAK $dhcpresp = new Net::DHCP::Packet( Comment => $dhcpreq->comment(), Op => BOOTREPLY(), Hops => $dhcpreq->hops(), Xid => $dhcpreq->xid(), Flags => $dhcpreq->flags(), Ciaddr => $dhcpreq->ciaddr(), Yiaddr => "0.0.0.0", Siaddr => $dhcpreq->siaddr(), Giaddr => $dhcpreq->giaddr(), Chaddr => $dhcpreq->chaddr(), DHO_DHCP_MESSAGE_TYPE() => DHCPNAK(), DHO_DHCP_MESSAGE(), "Bad request...", ); } # Socket object keeps track of whom sent last packet # so we don't need to specify target address logger("Sending ACK/NAK tr=".$dhcpresp->comment()); $sock_in->send($dhcpresp->serialize()) || die "Error sending ACK/NAK:$!\n"; # TODO: you have to choose between sending back to sender or broadcasting to network } libnet-dhcp-perl-0.693+dfsg.orig/examples/list_dho.pl0000755000175000017500000000031612037236123022374 0ustar cstamascstamas#!/usr/bin/perl use strict; use warnings; use Net::DHCP::Constants qw( %REV_DHO_CODES ); for my $key (sort {$a <=> $b} keys %REV_DHO_CODES) { printf " (%03d) %s\n", $key, $REV_DHO_CODES{$key}; } 1; libnet-dhcp-perl-0.693+dfsg.orig/examples/dhcpd_test.pl0000755000175000017500000000377712037236123022726 0ustar cstamascstamas#!/usr/bin/perl # Simple DHCP client - sending a broadcasted DHCP Discover request use IO::Socket::INET; use Net::DHCP::Packet; use Net::DHCP::Constants; use POSIX qw(setsid strftime); # sample logger sub logger{ my $str = shift; print STDOUT strftime "[%d/%b/%Y:%H:%M:%S] ", localtime; print STDOUT "$str\n"; } logger("DHCPd tester - dummy client"); logger("Opening socket"); $handle = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1, PeerPort => '67', LocalPort => '68', PeerAddr => '127.0.0.1') || die "Socket creation error: $@\n"; # yes, it uses $@ here # create DHCP Packet DISCOVER $discover = Net::DHCP::Packet->new( Xid => 0x12345678, DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER(), DHO_VENDOR_CLASS_IDENTIFIER() => 'foo', ); logger("Sending DISCOVER to 127.0.0.1:67"); logger($discover->toString()); $handle->send($discover->serialize()) or die "Error sending:$!\n"; logger("Waiting for response from server"); $handle->recv($buf, 4096) || die("recv:$!"); logger("Got response"); $response = new Net::DHCP::Packet($buf); logger($response->toString()); # create DHCP Packet REQUEST $request = Net::DHCP::Packet->new( Xid => 0x12345678, Ciaddr => $response->yiaddr(), DHO_DHCP_MESSAGE_TYPE() => DHCPREQUEST(), DHO_VENDOR_CLASS_IDENTIFIER() => 'foo', DHO_DHCP_REQUESTED_ADDRESS() => $response->yiaddr(), ); logger("Sending REQUEST to 127.0.0.1:67"); logger($request->toString()); $handle->send($request->serialize()) or die "Error sending:$!\n"; logger("Waiting for response from server"); $handle->recv($buf, 4096) || die("recv:$!"); logger("Got response"); $response = new Net::DHCP::Packet($buf); logger($response->toString()); libnet-dhcp-perl-0.693+dfsg.orig/examples/send_packet.pl0000755000175000017500000000166012037236123023052 0ustar cstamascstamas#!/usr/bin/perl # Simple DHCP client - sending a broadcasted DHCP Discover request use IO::Socket::INET; use Net::DHCP::Packet; use Net::DHCP::Constants; # create DHCP Packet $discover = Net::DHCP::Packet->new( xid => int(rand(0xFFFFFFFF)), # random xid Flags => 0x8000, # ask for broadcast answer DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER(), DHO_VENDOR_CLASS_IDENTIFIER() => 'foo', ); # send packet $handle = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1, PeerPort => '67', LocalPort => '68', PeerAddr => '255.255.255.255') or die "socket: $@"; # yes, it uses $@ here $handle->send($discover->serialize()) or die "Error sending broadcast inform:$!\n"; libnet-dhcp-perl-0.693+dfsg.orig/examples/lease_query.pl0000755000175000017500000000226212037236123023107 0ustar cstamascstamas#!/usr/bin/perl # Simple DHCP client - send a LeaseQuery (by IP) and receive the response use IO::Socket::INET; use Net::DHCP::Packet; use Net::DHCP::Constants; $usage = "usage: $0 DHCP_SERVER_IP DHCP_CLIENT_IP\n"; $ARGV[1] || die $usage; # create a socket $handle = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1, PeerPort => '67', LocalPort => '67', PeerAddr => $ARGV[0]) or die "socket: $@"; # yes, it uses $@ here # create DHCP Packet $inform = Net::DHCP::Packet->new( op => BOOTREQUEST(), Htype => '0', Hlen => '0', Ciaddr => $ARGV[1], Giaddr => $handle->sockhost(), Xid => int(rand(0xFFFFFFFF)), # random xid DHO_DHCP_MESSAGE_TYPE() => DHCPLEASEQUERY ); # send request $handle->send($inform->serialize()) or die "Error sending LeaseQuery: $!\n"; #receive response $handle->recv($newmsg, 1024) or die; $packet = Net::DHCP::Packet->new($newmsg); print $packet->toString(); libnet-dhcp-perl-0.693+dfsg.orig/examples/dhcp_sniffer.pl0000755000175000017500000000044712037236123023226 0ustar cstamascstamas#!/usr/bin/perl 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 STDERR $packet->toString(); } libnet-dhcp-perl-0.693+dfsg.orig/examples/dumpianatoxml.pl0000755000175000017500000000034712037236123023455 0ustar cstamascstamas#!/usr/bin/perl use warnings; use strict; use XML::Simple; use Data::Dumper; $Data::Dumper::Indent = $Data::Dumper::Sortkeys = 1; my $filename = shift or die "please specify a filename\n"; print Dumper( XMLin($filename) ); libnet-dhcp-perl-0.693+dfsg.orig/examples/l2tp-dhcp-inform0000644000175000017500000000470312037236123023243 0ustar cstamascstamas#!/usr/bin/perl # TODO # * use syslog # * runit - as also invalid DHCP packets cause library to croak() # * error checking use strict; use warnings; use Sys::Hostname; use IO::Socket::INET; use Net::DHCP::Constants qw/:dho_codes :dhcp_message :bootp_codes :htype_codes :dhcp_other/; use Net::DHCP::Packet; # populated in BEGIN my %addOption; my $domainnameservers = '192.0.1.2 192.0.1.50'; # Mac OS X 10.7 seems to accept space seperated entries here (no idea if others do too) my $domainname = 'domain.foo'; my @subnets; for () { next if (/^(#|$)/); chomp; push @subnets, $_; } my $sock = IO::Socket::INET->new( Proto => 'udp', LocalPort => 67, ); unless ($sock) { print STDERR "unable to open socket: $@\n"; exit 1; } my $buf; while (my $src = $sock->recv($buf, DHCP_MAX_MTU - DHCP_UDP_OVERHEAD)) { my $sport = $sock->peerport; next unless ($sport == 68); # add padding to stop the library complaining # as the packets are typically 262 bytes long $buf .= "\x00" x (BOOTP_MIN_LEN() - length($buf)) if (length($buf) < BOOTP_MIN_LEN()); my $pac = Net::DHCP::Packet->new($buf); next unless ($pac->isDhcp && $pac->op == BOOTREQUEST() && $pac->htype == HTYPE_FDDI() && $pac->getOptionValue(DHO_DHCP_MESSAGE_TYPE()) == DHCPINFORM()); my $res = Net::DHCP::Packet->new( Op => BOOTREPLY(), Htype => $pac->htype, Xid => $pac->xid, Ciaddr => $sock->peerhost, Chaddr => $pac->chaddr, Sname => hostname, DHO_DHCP_MESSAGE_TYPE() => DHCPACK(), ); foreach (split / /, $pac->getOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST())) { &{$addOption{$_}}($res, $_) if (defined($addOption{$_})); } $sock->send($res->serialize); } exit 0; BEGIN { sub OptionSubnetMask { my ($res, $opt) = @_; $res->addOptionValue(DHO_SUBNET_MASK(), '255.255.255.255'); } $addOption{DHO_SUBNET_MASK()} = \&OptionSubnetMask; sub OptionDomainName { my ($res, $opt) = @_; $res->addOptionValue(DHO_DOMAIN_NAME(), $domainname); } $addOption{DHO_DOMAIN_NAME()} = \&OptionDomainName; sub OptionDomainNameServers { my ($res, $opt) = @_; $res->addOptionValue(DHO_DOMAIN_NAME_SERVERS(), $domainnameservers); } $addOption{DHO_DOMAIN_NAME_SERVERS()} = \&OptionDomainNameServers; sub OptionClasslessStaticRoutes { my ($res, $opt) = @_; $res->addOptionValue($opt, [ map { [$_, '0.0.0.0'] } @subnets ]); } $addOption{121} = \&OptionClasslessStaticRoutes; $addOption{249} = \&OptionClasslessStaticRoutes; } __DATA__ 10.0.0.0/8 192.168.0.0/16 libnet-dhcp-perl-0.693+dfsg.orig/lib/0000755000175000017500000000000012224056470017162 5ustar cstamascstamaslibnet-dhcp-perl-0.693+dfsg.orig/lib/Net/0000755000175000017500000000000012224056470017710 5ustar cstamascstamaslibnet-dhcp-perl-0.693+dfsg.orig/lib/Net/DHCP/0000755000175000017500000000000012224056470020426 5ustar cstamascstamaslibnet-dhcp-perl-0.693+dfsg.orig/lib/Net/DHCP/Packet.pm0000755000175000017500000013454112037236123022203 0ustar cstamascstamas#!/bin/false # Net::DHCP::Packet.pm # Author : D. Hamstead # Original Author: F. van Dun, S. Hadinger package Net::DHCP::Packet; # standard module declaration use 5.8.0; use strict; use warnings; our ( @ISA, @EXPORT, @EXPORT_OK, $VERSION ); use Exporter; $VERSION = 0.693; @ISA = qw(Exporter); @EXPORT = qw( packinet packinets unpackinet unpackinets ); @EXPORT_OK = qw( ); use Socket; use Carp; use Net::DHCP::Constants qw(:DEFAULT :dhcp_hashes :dhcp_other %DHO_FORMATS); use Scalar::Util qw(looks_like_number); # for numerical testing use List::Util qw(first); #======================================================================= sub new { my $class = shift; my $self = { options => {}, # DHCP options options_order => [] # order in which the options were added }; bless $self, $class; if ( scalar @_ == 1 ) { # we build the packet from a binary string $self->marshall(shift); } else { my %args = @_; my @ordered_args = @_; if ( exists $args{Comment} ) { $self->comment( $args{Comment} ); } else { $self->{comment} = undef; } if ( exists $args{Op} ) { $self->op( $args{Op} ); } else { $self->{op} = BOOTREQUEST(); } if ( exists $args{Htype} ) { $self->htype( $args{Htype} ) } else { $self->{htype} = 1; # 10mb ethernet } if ( exists $args{Hlen} ) { $self->hlen( $args{Hlen} ); } else { $self->{hlen} = 6; # Use 6 bytes MAC } if ( exists $args{Hops} ) { $self->hops( $args{Hops} ); } else { $self->{hops} = 0; } if ( exists $args{Xid} ) { $self->xid( $args{Xid} ); } else { $self->{xid} = 0x12345678; } if ( exists $args{Secs} ) { $self->secs( $args{Secs} ); } else { $self->{secs} = 0; } if ( exists $args{Flags} ) { $self->flags( $args{Flags} ); } else { $self->{flags} = 0; } if ( exists $args{Ciaddr} ) { $self->ciaddr( $args{Ciaddr} ); } else { $self->{ciaddr} = "\0\0\0\0"; } if ( exists $args{Yiaddr} ) { $self->yiaddr( $args{Yiaddr} ); } else { $self->{yiaddr} = "\0\0\0\0"; } if ( exists $args{Siaddr} ) { $self->siaddr( $args{Siaddr} ); } else { $self->{siaddr} = "\0\0\0\0"; } if ( exists $args{Giaddr} ) { $self->giaddr( $args{Giaddr} ); } else { $self->{giaddr} = "\0\0\0\0"; } if ( exists $args{Chaddr} ) { $self->chaddr( $args{Chaddr} ); } else { $self->{chaddr} = q||; } if ( exists $args{Sname} ) { $self->sname( $args{Sname} ); } else { $self->{sname} = q||; } if ( exists $args{File} ) { $self->file( $args{File} ); } else { $self->{file} = q||; } if ( exists $args{Padding} ) { $self->padding( $args{Padding} ); } else { $self->{padding} = q||; } if ( exists $args{IsDhcp} ) { $self->isDhcp( $args{IsDhcp} ); } else { $self->{isDhcp} = 1; } # TBM add DHCP option parsing while ( defined( my $key = shift @ordered_args ) ) { my $value = shift @ordered_args; my $is_numeric; { no warnings; $is_numeric = ( $key eq ( 0 + $key ) ); } if ($is_numeric) { $self->addOptionValue( $key, $value ); } } } return $self } #======================================================================= # comment attribute : enables transaction number identification sub comment { my $self = shift; if (@_) { $self->{comment} = shift } return $self->{comment}; } # op attribute sub op { my $self = shift; if (@_) { $self->{op} = shift } return $self->{op}; } # htype attribute sub htype { my $self = shift; if (@_) { $self->{htype} = shift } return $self->{htype}; } # hlen attribute sub hlen { my $self = shift; if (@_) { $self->{hlen} = shift } if ( $self->{hlen} < 0 ) { carp( 'hlen must not be < 0 (currently ' . $self->{hlen} . ')' ); $self->{hlen} = 0; } if ( $self->{hlen} > 16 ) { carp( 'hlen must not be > 16 (currently ' . $self->{hlen} . ')' ); $self->{hlen} = 16; } return $self->{hlen}; } # hops attribute sub hops { my $self = shift; if (@_) { $self->{hops} = shift } return $self->{hops}; } # xid attribute sub xid { my $self = shift; if (@_) { $self->{xid} = shift } return $self->{xid}; } # secs attribute sub secs { my $self = shift; if (@_) { $self->{secs} = shift } return $self->{secs}; } # flags attribute sub flags { my $self = shift; if (@_) { $self->{flags} = shift } return $self->{flags}; } # ciaddr attribute sub ciaddr { my $self = shift; if (@_) { $self->{ciaddr} = packinet(shift) } return unpackinet( $self->{ciaddr} ); } # ciaddr attribute, Raw version sub ciaddrRaw { my $self = shift; if (@_) { $self->{ciaddr} = shift } return $self->{ciaddr}; } # yiaddr attribute sub yiaddr { my $self = shift; if (@_) { $self->{yiaddr} = packinet(shift) } return unpackinet( $self->{yiaddr} ); } # yiaddr attribute, Raw version sub yiaddrRaw { my $self = shift; if (@_) { $self->{yiaddr} = shift } return $self->{yiaddr}; } # siaddr attribute sub siaddr { my $self = shift; if (@_) { $self->{siaddr} = packinet(shift) } return unpackinet( $self->{siaddr} ); } # siaddr attribute, Raw version sub siaddrRaw { my $self = shift; if (@_) { $self->{siaddr} = shift } return $self->{siaddr}; } # giaddr attribute sub giaddr { my $self = shift; if (@_) { $self->{giaddr} = packinet(shift) } return unpackinet( $self->{giaddr} ); } # giaddr attribute, Raw version sub giaddrRaw { my $self = shift; if (@_) { $self->{giaddr} = shift } return $self->{giaddr}; } # chaddr attribute sub chaddr { my $self = shift; if (@_) { $self->{chaddr} = pack( "H*", shift ) } return unpack( "H*", $self->{chaddr} ); } # chaddr attribute, Raw version sub chaddrRaw { my $self = shift; if (@_) { $self->{chaddr} = shift } return $self->{chaddr}; } # sname attribute sub sname { use bytes; my $self = shift; if (@_) { $self->{sname} = shift } if ( length( $self->{sname} ) > 63 ) { carp( q|'sname' must not be > 63 bytes, (currently | . length( $self->{sname} ) . ')' ); $self->{sname} = substr( $self->{sname}, 0, 63 ); } return $self->{sname}; } # file attribute sub file { use bytes; my $self = shift; if (@_) { $self->{file} = shift } if ( length( $self->{file} ) > 127 ) { carp( q|'file' must not be > 127 bytes, (currently | . length( $self->{file} ) . ')' ); $self->{file} = substr( $self->{file}, 0, 127 ); } return $self->{file}; } # is it DHCP or BOOTP # -> DHCP needs magic cookie and options sub isDhcp { my $self = shift; if (@_) { $self->{isDhcp} = shift } return $self->{isDhcp}; } # padding attribute sub padding { my $self = shift; if (@_) { $self->{padding} = shift } return $self->{padding}; } #======================================================================= sub addOptionRaw { my ( $self, $key, $value_bin ) = @_; $self->{options}->{$key} = $value_bin; push @{ $self->{options_order} }, ($key); } sub addOptionValue { my $self = shift; my $code = shift; # option code my $value = shift; # my $value_bin; # option value in binary format carp("addOptionValue: unknown format for code ($code)") unless exists $DHO_FORMATS{$code}; my $format = $DHO_FORMATS{$code}; if ( $format eq 'suboption' ) { carp 'Use addSubOptionValue to add sub options'; return; } # decompose input value into an array my @values; if ( defined $value && $value ne q|| ) { @values = split( /[\s\/,;]+/, $value ); # array of values, split by space } # verify number of parameters if ( $format eq 'string' || $format eq 'csr' ) { @values = ($value); # don't change format } elsif ( $format =~ /s$/ ) { # ends with an 's', meaning any number of parameters ; } elsif ( $format =~ /2$/ ) { # ends with a '2', meaning couples of parameters croak( "addOptionValue: only pairs of values expected for option '$code'") if ( ( @values % 2 ) != 0 ); } else { # only one parameter croak("addOptionValue: exactly one value expected for option '$code'") if ( @values != 1 ); } my %options = ( inet => sub { return packinet(shift) }, inets => sub { return packinets_array(@_) }, inets2 => sub { return packinets_array(@_) }, int => sub { return pack( 'N', shift ) }, short => sub { return pack( 'n', shift ) }, byte => sub { return pack( 'C', 255 & shift ) } , # 255 & trims the input to single octet bytes => sub { return pack( 'C*', map { 255 & $_ } @_ ); }, string => sub { return shift }, csr => sub { return packcsr(shift) }, ); # } elsif ($format eq 'relays') { # $value_bin = $self->encodeRelayAgent(@values); # } elsif ($format eq 'ids') { # $value_bin = $values[0]; # # TBM bad format # decode the option if we know how, otherwise use the original value $self->addOptionRaw( $code, $options{$format} ? $options{$format}->(@values) : $value ); } # end AddOptionValue sub addSubOptionRaw { my ( $self, $key, $subkey, $value_bin ) = @_; $self->{options}->{$key}->{$subkey} = $value_bin; push @{ $self->{sub_options_order}{$subkey} }, ($key); } sub addSubOptionValue { my $self = shift; my $code = shift; # option code my $subcode = shift; # sub option code my $value = shift; my $value_bin; # option value in binary format # FIXME carp("addSubOptionValue: unknown format for code ($code)") unless exists $DHO_FORMATS{$code}; carp("addSubOptionValue: not a suboption parameter for code ($code)") unless ( $DHO_FORMATS{$code} eq 'suboptions' ); carp( "addSubOptionValue: unknown format for subcode ($subcode) on code ($code)" ) unless ( $DHO_FORMATS{$code} eq 'suboptions' ); carp("addSubOptionValue: no suboptions defined for code ($code)?") unless exists $SUBOPTION_CODES{$code}; carp( "addSubOptionValue: suboption ($subcode) not defined for code ($code)?") unless exists $SUBOPTION_CODES{$code}->{$subcode}; my $format = $SUBOPTION_CODES{$code}->{$subcode}; # decompose input value into an array my @values; if ( defined $value && $value ne q|| ) { @values = split( /[\s\/,;]+/, $value ); # array of values, split by space } # verify number of parameters if ( $format eq 'string' ) { @values = ($value); # don't change format } elsif ( $format =~ m/s$/ ) { # ends with an 's', meaning any number of parameters ; } elsif ( $format =~ m/2$/ ) { # ends with a '2', meaning couples of parameters croak( "addSubOptionValue: only pairs of values expected for option '$code'" ) if ( ( @values % 2 ) != 0 ); } else { # only one parameter croak( "addSubOptionValue: exactly one value expected for option '$code'") if ( @values != 1 ); } my %options = ( inet => sub { return packinet(shift) }, inets => sub { return packinets_array(@_) }, inets2 => sub { return packinets_array(@_) }, int => sub { return pack( 'N', shift ) }, short => sub { return pack( 'n', shift ) }, byte => sub { return pack( 'C', 255 & shift ) } , # 255 & trims the input to single octet bytes => sub { return pack( 'C*', map { 255 & $_ } @_ ); }, string => sub { return shift }, ); # } elsif ($format eq 'relays') { # $value_bin = $self->encodeRelayAgent(@values); # } elsif ($format eq 'ids') { # $value_bin = $values[0]; # # TBM bad format # decode the option if we know how, otherwise use the original value $self->addOptionRaw( $code, $options{$format} ? $options{$format}->(@values) : $value ); } sub getOptionRaw { my ( $self, $key ) = @_; return $self->{options}->{$key} if exists( $self->{options}->{$key} ); return; } sub getOptionValue { my $self = shift; my $code = shift; carp("getOptionValue: unknown format for code ($code)") unless exists( $DHO_FORMATS{$code} ); my $format = $DHO_FORMATS{$code}; my $value_bin = $self->getOptionRaw($code); return unless defined $value_bin; my @values; # hash out these options for speed and sanity my %options = ( inet => sub { return unpackinets_array(shift) }, inets => sub { return unpackinets_array(shift) }, inets2 => sub { return unpackinets_array(shift) }, int => sub { return unpack( 'N', shift ) }, short => sub { return unpack( 'n', shift ) }, shorts => sub { return unpack( 'n*', shift ) }, byte => sub { return unpack( 'C', shift ) }, bytes => sub { return unpack( 'C*', shift ) }, string => sub { return shift }, csr => sub { return unpackcsr(shift) }, ); # } elsif ($format eq 'relays') { # @values = $self->decodeRelayAgent($value_bin); # # TBM, bad format # } elsif ($format eq 'ids') { # $values[0] = $value_bin; # # TBM, bad format # decode the options if we know the format return join( q| |, $options{$format}->($value_bin) ) if $options{$format}; # if we cant work out the format return $value_bin } # getOptionValue sub getSubOptionRaw { my ( $self, $key, $subkey ) = @_; return $self->{options}->{$key}->{$subkey} if exists( $self->{options}->{$key}->{$subkey} ); return; } sub getSubOptionValue { # FIXME #~ my $self = shift; #~ my $code = shift; #~ #~ carp("getOptionValue: unknown format for code ($code)") #~ unless exists( $DHO_FORMATS{$code} ); #~ #~ my $format = $DHO_FORMATS{$code}; #~ #~ my $value_bin = $self->getOptionRaw($code); #~ #~ return unless defined $value_bin; #~ #~ my @values; #~ #~ # hash out these options for speed and sanity #~ my %options = ( #~ inet => sub { return unpackinets_array(shift) }, #~ inets => sub { return unpackinets_array(shift) }, #~ inets2 => sub { return unpackinets_array(shift) }, #~ int => sub { return unpack( 'N', shift ) }, #~ short => sub { return unpack( 'n', shift ) }, #~ shorts => sub { return unpack( 'n*', shift ) }, #~ byte => sub { return unpack( 'C', shift ) }, #~ bytes => sub { return unpack( 'C*', shift ) }, #~ string => sub { return shift }, #~ #~ ); #~ #~ # } elsif ($format eq 'relays') { #~ # @values = $self->decodeRelayAgent($value_bin); #~ # # TBM, bad format #~ # } elsif ($format eq 'ids') { #~ # $values[0] = $value_bin; #~ # # TBM, bad format #~ #~ # decode the options if we know the format #~ return join( q| |, $options{$format}->($value_bin) ) #~ if $options{$format}; #~ #~ # if we cant work out the format #~ return $value_bin } # getSubOptionValue sub removeOption { my ( $self, $key ) = @_; if ( exists( $self->{options}->{$key} ) ) { my $i = first { $self->{options_order}->[$_] == $key } 0 .. $#{ $self->{options_order} }; # for ( $i = 0 ; $i < @{ $self->{options_order} } ; $i++ ) { # last if ( $self->{options_order}->[$i] == $key ); # } if ( $i < @{ $self->{options_order} } ) { splice @{ $self->{options_order} }, $i, 1; } delete( $self->{options}->{$key} ); } } sub removeSubOption { # FIXME #~ my ( $self, $key ) = @_; #~ if ( exists( $self->{options}->{$key} ) ) { #~ my $i = first { $self->{options_order}->[$_] == $key } 0..$#{ $self->{options_order} }; #~ # for ( $i = 0 ; $i < @{ $self->{options_order} } ; $i++ ) { #~ # last if ( $self->{options_order}->[$i] == $key ); #~ # } #~ if ( $i < @{ $self->{options_order} } ) { #~ splice @{ $self->{options_order} }, $i, 1; #~ } #~ delete( $self->{options}->{$key} ); #~ } } #======================================================================= my $BOOTP_FORMAT = 'C C C C N n n a4 a4 a4 a4 a16 Z64 Z128 a*'; #my $DHCP_MIN_LENGTH = length(pack($BOOTP_FORMAT)); #======================================================================= sub serialize { use bytes; my ($self) = shift; my $options = shift; # reference to an options hash for special options my $bytes = undef; $bytes = pack( $BOOTP_FORMAT, $self->{op}, $self->{htype}, $self->{hlen}, $self->{hops}, $self->{xid}, $self->{secs}, $self->{flags}, $self->{ciaddr}, $self->{yiaddr}, $self->{siaddr}, $self->{giaddr}, $self->{chaddr}, $self->{sname}, $self->{file} ); if ( $self->{isDhcp} ) { # add MAGIC_COOKIE and options $bytes .= MAGIC_COOKIE(); for my $key ( @{ $self->{options_order} } ) { if ( ref($self->{options}->{$key}) eq 'ARRAY' ) { for my $value ( @{$self->{options}->{$key}} ) { $bytes .= pack( 'C', $key ); $bytes .= pack( 'C/a*', $value ); } } else { $bytes .= pack( 'C', $key ); $bytes .= pack( 'C/a*', $self->{options}->{$key} ); } } $bytes .= pack( 'C', 255 ); } $bytes .= $self->{padding}; # add optional padding # add padding if packet is less than minimum size my $min_padding = BOOTP_MIN_LEN() - length($bytes); if ( $min_padding > 0 ) { $bytes .= "\0" x $min_padding; } # test if packet is not bigger than absolute maximum MTU if ( length($bytes) > DHCP_MAX_MTU() ) { croak( 'serialize: packet too big (' . length($bytes) . ' greater than max MAX_MTU (' . DHCP_MAX_MTU() ); } # test if packet length is not bigger than DHO_DHCP_MAX_MESSAGE_SIZE if ( $options && exists( $options->{ DHO_DHCP_MAX_MESSAGE_SIZE() } ) ) { # maximum packet size is specified my $max_message_size = $options->{ DHO_DHCP_MAX_MESSAGE_SIZE() }; if ( ( $max_message_size >= BOOTP_MIN_LEN() ) && ( $max_message_size < DHCP_MAX_MTU() ) ) { # relevant message size if ( length($bytes) > $max_message_size ) { croak( 'serialize: message is bigger than allowed (' . length($bytes) . '), max specified :' . $max_message_size ); } } } return $bytes } # end sub serialize #======================================================================= sub marshall { use bytes; my ( $self, $buf ) = @_; my $opt_buf; if ( length($buf) < BOOTP_ABSOLUTE_MIN_LEN() ) { croak( 'marshall: packet too small (' . length($buf) . '), absolute minimum size is ' . BOOTP_ABSOLUTE_MIN_LEN() ); } if ( length($buf) < BOOTP_MIN_LEN() ) { carp( 'marshall: packet too small (' . length($buf) . '), minimum size is ' . BOOTP_MIN_LEN() ); } if ( length($buf) > DHCP_MAX_MTU() ) { croak( 'marshall: packet too big (' . length($buf) . '), max MTU size is ' . DHCP_MAX_MTU() ); } # if we are re-using this object, then we need to clear out these arrays delete $self->{options} if $self->{options}; delete $self->{options_order} if $self->{options_order}; ( $self->{op}, $self->{htype}, $self->{hlen}, $self->{hops}, $self->{xid}, $self->{secs}, $self->{flags}, $self->{ciaddr}, $self->{yiaddr}, $self->{siaddr}, $self->{giaddr}, $self->{chaddr}, $self->{sname}, $self->{file}, $opt_buf ) = unpack( $BOOTP_FORMAT, $buf ); $self->{isDhcp} = 0; # default to BOOTP if ( ( length($opt_buf) > 4 ) && ( substr( $opt_buf, 0, 4 ) eq MAGIC_COOKIE() ) ) { # it is definitely DHCP $self->{isDhcp} = 1; my $pos = 4; # Skip magic cookie my $total = length($opt_buf); my $type; while ( $pos < $total ) { $type = ord( substr( $opt_buf, $pos++, 1 ) ); next if ( $type eq DHO_PAD() ); # Skip padding bytes last if ( $type eq DHO_END() ); # Type 'FF' signals end of options. my $len = ord( substr( $opt_buf, $pos++, 1 ) ); my $option = substr( $opt_buf, $pos, $len ); $pos += $len; $self->addOptionRaw( $type, $option ); } # verify that we ended with an "END" code if ( $type != DHO_END() ) { croak('marshall: unexpected end of options'); } # put remaining bytes in the padding attribute if ( $pos < $total ) { $self->{padding} = substr( $opt_buf, $pos, $total - $pos ); } else { $self->{padding} = q||; } } else { # in bootp, everything is padding $self->{padding} = $opt_buf; } return $self } # end sub marshall #======================================================================= sub decodeRelayAgent { use bytes; my $self = shift; my ($opt_buf) = @_; my @opt; if ( length($opt_buf) > 1 ) { my $pos = 0; my $total = length($opt_buf); while ( $pos < $total ) { my $type = ord( substr( $opt_buf, $pos++, 1 ) ); my $len = ord( substr( $opt_buf, $pos++, 1 ) ); my $option = substr( $opt_buf, $pos, $len ); $pos += $len; push @opt, $type, $option; } } return @opt } sub encodeRelayAgent { use bytes; my $self = shift; my @opt; # expect key-value pairs my $buf; while ( defined( my $key = shift(@opt) ) ) { my $value = shift(@opt); $buf .= pack( 'C', $key ); $buf .= pack( 'C/a*', $value ); } return $buf; } #======================================================================= sub toString { my ($self) = @_; my $s; $s .= sprintf( "comment = %s\n", $self->comment() ) if defined( $self->comment() ); $s .= sprintf( "op = %s\n", ( exists( $REV_BOOTP_CODES{ $self->op() } ) && $REV_BOOTP_CODES{ $self->op() } ) || $self->op() ); $s .= sprintf( "htype = %s\n", ( exists( $REV_HTYPE_CODES{ $self->htype() } ) && $REV_HTYPE_CODES{ $self->htype() } ) || $self->htype() ); $s .= sprintf( "hlen = %s\n", $self->hlen() ); $s .= sprintf( "hops = %s\n", $self->hops() ); $s .= sprintf( "xid = %x\n", $self->xid() ); $s .= sprintf( "secs = %i\n", $self->secs() ); $s .= sprintf( "flags = %x\n", $self->flags() ); $s .= sprintf( "ciaddr = %s\n", $self->ciaddr() ); $s .= sprintf( "yiaddr = %s\n", $self->yiaddr() ); $s .= sprintf( "siaddr = %s\n", $self->siaddr() ); $s .= sprintf( "giaddr = %s\n", $self->giaddr() ); $s .= sprintf( "chaddr = %s\n", substr( $self->chaddr(), 0, 2 * $self->hlen() ) ); $s .= sprintf( "sname = %s\n", $self->sname() ); $s .= sprintf( "file = %s\n", $self->file() ); $s .= "Options : \n"; for my $key ( @{ $self->{options_order} } ) { my $value; # value of option to be printed if ( $key == DHO_DHCP_MESSAGE_TYPE() ) { $value = $self->getOptionValue($key); $value = ( exists( $REV_DHCP_MESSAGE{$value} ) && $REV_DHCP_MESSAGE{$value} ) || $self->getOptionValue($key); } else { if ( exists( $DHO_FORMATS{$key} ) ) { $value = join( q| |, $self->getOptionValue($key) ); } else { $value = $self->getOptionRaw($key); } $value =~ s/([[:^print:]])/ sprintf q[\x%02X], ord $1 /eg; # printable text } $s .= sprintf( " %s(%d) = %s\n", exists $REV_DHO_CODES{$key} ? $REV_DHO_CODES{$key} : '', $key, $value ); } $s .= sprintf( "padding [%s] = %s\n", length( $self->{padding} ), unpack( 'H*', $self->{padding} ) ); return $s } # end toString #======================================================================= # internal utility functions # never failing versions of the "Socket" module functions sub packinet { # bullet-proof version, never complains use bytes; my $addr = shift; if ( $addr && $addr =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/ ) { return chr($1) . chr($2) . chr($3) . chr($4); } return "\0\0\0\0"; } sub unpackinet { # bullet-proof version, never complains use bytes; my $ip = shift; return '0.0.0.0' unless ( $ip && length($ip) == 4 ); return ord( substr( $ip, 0, 1 ) ) . q|.| . ord( substr( $ip, 1, 1 ) ) . q|.| . ord( substr( $ip, 2, 1 ) ) . q|.| . ord( substr( $ip, 3, 1 ) ); } sub packinets { # multiple ip addresses, space delimited return join( q(), map { packinet($_) } split( /[\s\/,;]+/, shift || 0 ) ); } sub unpackinets { # multiple ip addresses return join( q| |, map { unpackinet($_) } unpack( "(a4)*", shift || 0 ) ); } sub packinets_array { # multiple ip addresses, space delimited return unless @_; return join( q(), map { packinet($_) } @_ ); } sub unpackinets_array { # multiple ip addresses, returns an array return map { unpackinet($_) } unpack( "(a4)*", shift || 0 ); } sub unpackRelayAgent { # prints a human readable 'relay agent options' my %relay_opt = @_ or return; return join( q|,|, map { "($_)=" . $relay_opt{$_} } ( sort keys %relay_opt ) ) } sub packcsr { # catch empty value my $results = [ '' ]; for my $pair ( @{$_[0]} ) { push @$results, '' if (length($results->[-1]) > 255 - 8); my ($ip, $mask) = split /\//, $pair->[0]; $mask = '32' unless (defined($mask)); my $addr = packinet($ip); $addr = substr $addr, 0, int(($mask - 1)/8 + 1); $results->[-1] .= pack('C', $mask) . $addr; $results->[-1] .= packinet($pair->[1]); } return $results; } sub unpackcsr { my $csr = shift or return; croak('unpack csr field still WIP'); } #======================================================================= 1; =pod =head1 NAME Net::DHCP::Packet - Object methods to create a DHCP packet. =head1 SYNOPSIS use Net::DHCP::Packet; my $p = Net::DHCP::Packet->new( 'Chaddr' => '000BCDEF', 'Xid' => 0x9F0FD, 'Ciaddr' => '0.0.0.0', 'Siaddr' => '0.0.0.0', 'Hops' => 0); =head1 DESCRIPTION Represents a DHCP packet as specified in RFC 1533, RFC 2132. =head1 CONSTRUCTOR This module only provides basic constructor. For "easy" constructors, you can use the L module. =over 4 =item new( ) =item new( BUFFER ) =item new( ARG => VALUE, ARG => VALUE... ) Creates an C 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 C argument is interpreted as a binary buffer like one provided by the socket C 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 C 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 packet See below methods for values and syntax descrption. Note: DHCP options are created in the same order as key-value pairs. =back =head1 METHODS =head2 ATTRIBUTE METHODS =over 4 =item comment( [STRING] ) Sets or gets the comment attribute (object meta-data only) =item op( [BYTE] ) Sets/gets the I. Normal values are: BOOTREQUEST() BOOTREPLY() =item htype( [BYTE] ) Sets/gets the I. Common value is: C (1) = ethernet =item hlen ( [BYTE] ) Sets/gets the I. Value must be between C<0> and C<16>. For most NIC's, the MAC address has 6 bytes. =item hops ( [BYTE] ) Sets/gets the I. This field is incremented by each encountered DHCP relay agent. =item xid ( [INTEGER] ) Sets/gets the 32 bits I. This field should be a random value set by the DHCP client. =item secs ( [SHORT] ) Sets/gets the 16 bits I in seconds. =item flags ( [SHORT] ) Sets/gets the 16 bits I. 0x8000 = Broadcast reply requested. =item ciaddr ( [STRING] ) Sets/gets the I. IP address is only accepted as a string like '10.24.50.3'. Note: IP address is internally stored as a 4 bytes binary string. See L below. =item yiaddr ( [STRING] ) Sets/gets the I. IP address is only accepted as a string like '10.24.50.3'. Note: IP address is internally stored as a 4 bytes binary string. See L below. =item siaddr ( [STRING] ) Sets/gets the I. IP address is only accepted as a string like '10.24.50.3'. Note: IP address is internally stored as a 4 bytes binary string. See L below. =item giaddr ( [STRING] ) Sets/gets the I. IP address is only accepted as a string like '10.24.50.3'. Note: IP address is internally stored as a 4 bytes binary string. See L below. =item chaddr ( [STRING] ) Sets/gets the I. Its length is given by the C attribute. Valude is formatted as an Hexadecimal string representation. Example: "0010A706DFFF" for 6 bytes mac address. Note : internal format is packed bytes string. See L below. =item sname ( [STRING] ) Sets/gets the "server host name". Maximum size is 63 bytes. If greater a warning is issued. =item file ( [STRING] ) Sets/gets the "boot file name". Maximum size is 127 bytes. If greater a warning is issued. =item isDhcp ( [BOOLEAN] ) Sets/gets the I. Returns whether the cookie is valid or not, hence whether the packet is DHCP or BOOTP. Default value is C<1>, valid DHCP cookie. =item padding ( [BYTES] ) Sets/gets the optional padding at the end of the DHCP packet, i.e. after DHCP options. =back =head2 DHCP OPTIONS METHODS This section describes how to read or set DHCP options. Methods are given in two flavours : (i) text format with automatic type conversion, (ii) raw binary format. Standard way of accessing options is through automatic type conversion, described in the L section. Only a subset of types is supported, mainly those defined in rfc 2132. Raw binary functions are provided for pure performance optimization, and for unsupported types manipulation. =over 4 =item addOptionValue ( CODE, VALUE ) Adds a DHCP option field. Common code values are listed in C C*. Values are automatically converted according to their data types, depending on their format as defined by RFC 2132. Please see L for supported options and corresponding formats. If you nedd access to the raw binary values, please use C. $pac = Net::DHCP::Packet->new(); $pac->addOption(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); $pac->addOption(DHO_NAME_SERVERS(), "10.0.0.1", "10.0.0.2")); =item addSubOptionValue ( CODE, SUBCODE, VALUE ) Adds a DHCP sub-option field. Common code values are listed in C C*. Values are automatically converted according to their data types, depending on their format as defined by RFC 2132. Please see L for supported options and corresponding formats. If you nedd access to the raw binary values, please use C. $pac = Net::DHCP::Packet->new(); # FIXME update exampls $pac->addSubOption(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); $pac->addSubOption(DHO_NAME_SERVERS(), "10.0.0.1", "10.0.0.2")); =item getOptionValue ( CODE ) Returns the value of a DHCP option. Automatic type conversion is done according to their data types, as defined in RFC 2132. Please see L for supported options and corresponding formats. If you nedd access to the raw binary values, please use C. Return value is either a string or an array, depending on the context. $ip = $pac->getOptionValue(DHO_SUBNET_MASK()); $ips = $pac->getOptionValue(DHO_NAME_SERVERS()); =item addOptionRaw ( CODE, VALUE ) Adds a DHCP OPTION provided in packed binary format. Please see corresponding RFC for manual type conversion. =item addSubOptionRaw ( CODE, SUBCODE, VALUE ) Adds a DHCP SUB-OPTION provided in packed binary format. Please see corresponding RFC for manual type conversion. =item getOptionRaw ( CODE ) Gets a DHCP OPTION provided in packed binary format. Please see corresponding RFC for manual type conversion. =item getSubOptionRaw ( CODE, SUBCODE ) Gets a DHCP SUB-OPTION provided in packed binary format. Please see corresponding RFC for manual type conversion. =item getSubOptionValue () This is an empty stub for now =item removeSubOption () This is an empty stub for now =item removeOption ( CODE ) Remove option from option list. =item encodeRelayAgent () These are half baked, but will encode the relay agent options in the future =item decodeRelayAgent () These are half baked, but will decode the relay agent options in the future =item unpackRelayAgent ( HASH ) returns a human readable 'relay agent options', not to be confused with C =item I I instead.> =item I I instead.> =item =back =head2 DHCP OPTIONS TYPES This section describes supported option types (cf. rfc 2132). For unsupported data types, please use C and C to manipulate binary format directly. =over 4 =item dhcp message type Only supported for DHO_DHCP_MESSAGE_TYPE (053) option. Converts a integer to a single byte. Option code for 'dhcp message' format: (053) DHO_DHCP_MESSAGE_TYPE Example: $pac->addOptionValue(DHO_DHCP_MESSAGE_TYPE(), DHCPINFORM()); =item string Pure string attribute, no type conversion. Option codes for 'string' format: (012) DHO_HOST_NAME (014) DHO_MERIT_DUMP (015) DHO_DOMAIN_NAME (017) DHO_ROOT_PATH (018) DHO_EXTENSIONS_PATH (047) DHO_NETBIOS_SCOPE (056) DHO_DHCP_MESSAGE (060) DHO_VENDOR_CLASS_IDENTIFIER (062) DHO_NWIP_DOMAIN_NAME (064) DHO_NIS_DOMAIN (065) DHO_NIS_SERVER (066) DHO_TFTP_SERVER (067) DHO_BOOTFILE (086) DHO_NDS_TREE_NAME (098) DHO_USER_AUTHENTICATION_PROTOCOL Example: $pac->addOptionValue(DHO_TFTP_SERVER(), "foobar"); =item single ip address Exactly one IP address, in dotted numerical format '192.168.1.1'. Option codes for 'single ip address' format: (001) DHO_SUBNET_MASK (016) DHO_SWAP_SERVER (028) DHO_BROADCAST_ADDRESS (032) DHO_ROUTER_SOLICITATION_ADDRESS (050) DHO_DHCP_REQUESTED_ADDRESS (054) DHO_DHCP_SERVER_IDENTIFIER (118) DHO_SUBNET_SELECTION Example: $pac->addOptionValue(DHO_SUBNET_MASK(), "255.255.255.0"); =item multiple ip addresses Any number of IP address, in dotted numerical format '192.168.1.1'. Empty value allowed. Option codes for 'multiple ip addresses' format: (003) DHO_ROUTERS (004) DHO_TIME_SERVERS (005) DHO_NAME_SERVERS (006) DHO_DOMAIN_NAME_SERVERS (007) DHO_LOG_SERVERS (008) DHO_COOKIE_SERVERS (009) DHO_LPR_SERVERS (010) DHO_IMPRESS_SERVERS (011) DHO_RESOURCE_LOCATION_SERVERS (041) DHO_NIS_SERVERS (042) DHO_NTP_SERVERS (044) DHO_NETBIOS_NAME_SERVERS (045) DHO_NETBIOS_DD_SERVER (048) DHO_FONT_SERVERS (049) DHO_X_DISPLAY_MANAGER (068) DHO_MOBILE_IP_HOME_AGENT (069) DHO_SMTP_SERVER (070) DHO_POP3_SERVER (071) DHO_NNTP_SERVER (072) DHO_WWW_SERVER (073) DHO_FINGER_SERVER (074) DHO_IRC_SERVER (075) DHO_STREETTALK_SERVER (076) DHO_STDA_SERVER (085) DHO_NDS_SERVERS Example: $pac->addOptionValue(DHO_NAME_SERVERS(), "10.0.0.11 192.168.1.10"); =item pairs of ip addresses Even number of IP address, in dotted numerical format '192.168.1.1'. Empty value allowed. Option codes for 'pairs of ip address' format: (021) DHO_POLICY_FILTER (033) DHO_STATIC_ROUTES Example: $pac->addOptionValue(DHO_STATIC_ROUTES(), "10.0.0.1 192.168.1.254"); =item byte, short and integer Numerical value in byte (8 bits), short (16 bits) or integer (32 bits) format. Option codes for 'byte (8)' format: (019) DHO_IP_FORWARDING (020) DHO_NON_LOCAL_SOURCE_ROUTING (023) DHO_DEFAULT_IP_TTL (027) DHO_ALL_SUBNETS_LOCAL (029) DHO_PERFORM_MASK_DISCOVERY (030) DHO_MASK_SUPPLIER (031) DHO_ROUTER_DISCOVERY (034) DHO_TRAILER_ENCAPSULATION (036) DHO_IEEE802_3_ENCAPSULATION (037) DHO_DEFAULT_TCP_TTL (039) DHO_TCP_KEEPALIVE_GARBAGE (046) DHO_NETBIOS_NODE_TYPE (052) DHO_DHCP_OPTION_OVERLOAD (116) DHO_AUTO_CONFIGURE Option codes for 'short (16)' format: (013) DHO_BOOT_SIZE (022) DHO_MAX_DGRAM_REASSEMBLY (026) DHO_INTERFACE_MTU (057) DHO_DHCP_MAX_MESSAGE_SIZE Option codes for 'integer (32)' format: (002) DHO_TIME_OFFSET (024) DHO_PATH_MTU_AGING_TIMEOUT (035) DHO_ARP_CACHE_TIMEOUT (038) DHO_TCP_KEEPALIVE_INTERVAL (051) DHO_DHCP_LEASE_TIME (058) DHO_DHCP_RENEWAL_TIME (059) DHO_DHCP_REBINDING_TIME Examples: $pac->addOptionValue(DHO_DHCP_OPTION_OVERLOAD(), 3); $pac->addOptionValue(DHO_INTERFACE_MTU(), 1500); $pac->addOptionValue(DHO_DHCP_RENEWAL_TIME(), 24*60*60); =item multiple bytes, shorts A list a bytes or shorts. Option codes for 'multiple bytes (8)' format: (055) DHO_DHCP_PARAMETER_REQUEST_LIST Option codes for 'multiple shorts (16)' format: (025) DHO_PATH_MTU_PLATEAU_TABLE (117) DHO_NAME_SERVICE_SEARCH Examples: $pac->addOptionValue(DHO_DHCP_PARAMETER_REQUEST_LIST(), "1 3 6 12 15 28 42 72"); =back =head2 SERIALIZATION METHODS =over 4 =item serialize () Converts a Net::DHCP::Packet to a string, ready to put on the network. =item marshall ( BYTES ) The inverse of serialize. Converts a string, presumably a received UDP packet, into a Net::DHCP::Packet. If the packet is malformed, a fatal error is produced. =back =head2 HELPER METHODS =over 4 =item toString () Returns a textual representation of the packet, for debugging. =item packinet ( STRING ) Transforms a IP address "xx.xx.xx.xx" into a packed 4 bytes string. These are simple never failing versions of inet_ntoa and inet_aton. =item packinets ( STRING ) Transforms a list of space delimited IP addresses into a packed bytes string. =item packinets_array( LIST ) Transforms an array (list) of IP addresses into a packed bytes string. =item unpackinet ( STRING ) Transforms a packed bytes IP address into a "xx.xx.xx.xx" string. =item unpackinets ( STRING ) Transforms a packed bytes liste of IP addresses into a list of "xx.xx.xx.xx" space delimited string. =item unpackinets_array ( STRING ) Transforms a packed bytes liste of IP addresses into a array of "xx.xx.xx.xx" strings. =back =head2 SPECIAL METHODS These methods are provided for performance tuning only. They give access to internal data representation , thus avoiding unnecessary type conversion. =over 4 =item ciaddrRaw ( [STRING]) Sets/gets the I in packed 4 characters binary strings. =item yiaddrRaw ( [STRING] ) Sets/gets the I in packed 4 characters binary strings. =item siaddrRaw ( [STRING] ) Sets/gets the I in packed 4 characters binary strings. =item giaddrRaw ( [STRING] ) Sets/gets the I in packed 4 characters binary strings. =item chaddrRaw ( [STRING] ) Sets/gets the I in packed binary string. Its length is given by the C attribute. =back =head1 EXAMPLES Sending a simple DHCP packet: #!/usr/bin/perl # Simple DHCP client - sending a broadcasted DHCP Discover request use IO::Socket::INET; use Net::DHCP::Packet; use Net::DHCP::Constants; # creat DHCP Packet $discover = Net::DHCP::Packet->new( xid => int(rand(0xFFFFFFFF)), # random xid Flags => 0x8000, # ask for broadcast answer DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER() ); # send packet $handle = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1, PeerPort => '67', LocalPort => '68', PeerAddr => '255.255.255.255') or die "socket: $@"; # yes, it uses $@ here $handle->send($discover->serialize()) or die "Error sending broadcast inform:$!\n"; Sniffing DHCP packets. #!/usr/bin/perl # Simple DHCP server - listen to DHCP packets and print them 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 STDERR $packet->toString(); } Sending a LEASEQUERY (provided by John A. Murphy). #!/usr/bin/perl # Simple DHCP client - send a LeaseQuery (by IP) and receive the response use IO::Socket::INET; use Net::DHCP::Packet; use Net::DHCP::Constants; $usage = "usage: $0 DHCP_SERVER_IP DHCP_CLIENT_IP\n"; $ARGV[1] || die $usage; # create a socket $handle = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1, PeerPort => '67', LocalPort => '67', PeerAddr => $ARGV[0]) or die "socket: $@"; # yes, it uses $@ here # create DHCP Packet $inform = Net::DHCP::Packet->new( op => BOOTREQUEST(), Htype => '0', Hlen => '0', Ciaddr => $ARGV[1], Giaddr => $handle->sockhost(), Xid => int(rand(0xFFFFFFFF)), # random xid DHO_DHCP_MESSAGE_TYPE() => DHCPLEASEQUERY ); # send request $handle->send($inform->serialize()) or die "Error sending LeaseQuery: $!\n"; #receive response $handle->recv($newmsg, 1024) or die; $packet = Net::DHCP::Packet->new($newmsg); print $packet->toString(); A simple DHCP Server is provided in the "examples" directory. It is composed of "dhcpd.pl" a *very* simple server example, and "dhcpd_test.pl" a simple tester for this server. =head1 AUTHOR Dean Hamstead Edjzort@cpan.orgE Previously Stephan Hadinger Eshadinger@cpan.orgE. Original version by F. van Dun. =head1 BUGS See L =head1 COPYRIGHT This is free software. It can be distributed and/or modified under the same terms as Perl itself. =head1 SEE ALSO L, L. =cut libnet-dhcp-perl-0.693+dfsg.orig/lib/Net/DHCP/Constants.pm0000755000175000017500000006376012037236123022754 0ustar cstamascstamas#!/bin/false # Net::DHCP::Constants.pm # Author: Dean Hamstead, Stephan Hadinger package Net::DHCP::Constants; # standard module declaration use 5.8.0; use strict; use warnings; our ( @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION ); use Exporter; $VERSION = 0.693; @ISA = qw(Exporter); @EXPORT = qw(MAGIC_COOKIE); # Constants our ( %DHO_CODES, %REV_DHO_CODES ); our ( %DHCP_MESSAGE, %REV_DHCP_MESSAGE ); our ( %BOOTP_CODES, %REV_BOOTP_CODES ); our ( %HTYPE_CODES, %REV_HTYPE_CODES ); our ( %NWIP_CODES, %REV_NWIP_CODES ); our ( %CCC_CODES, %REV_CCC_CODES ); our ( %GEOCONF_CODES, %REV_GEOCONF_CODES ); our ( %RELAYAGENT_CODES, %REV_RELAYAGENT_CODES ); our ( %SUBOPTION_CODES ); %EXPORT_TAGS = ( dho_codes => [ keys %DHO_CODES ], dhcp_message => [ keys %DHCP_MESSAGE ], bootp_codes => [ keys %BOOTP_CODES ], htype_codes => [ keys %HTYPE_CODES ], nwip_codes => [ keys %NWIP_CODES ], ccc_codes => [ keys %CCC_CODES ], geoconf_codes => [ keys %GEOCONF_CODES ], ra_codes => [ keys %RELAYAGENT_CODES ], dhcp_hashes => [ qw( %DHO_CODES %REV_DHO_CODES %DHCP_MESSAGE %REV_DHCP_MESSAGE %BOOTP_CODES %REV_BOOTP_CODES %NWIP_CODES %CCC_CODES %HTYPE_CODES %REV_HTYPE_CODES %GEOCONF_CODES %REV_GEOCONF_CODES %RELAYAGENT_CODES %REV_RELAYAGENT_CODES %SUBOPTION_CODES ) ], dhcp_other => [ qw(MAGIC_COOKIE DHCP_UDP_OVERHEAD DHCP_MAX_MTU BOOTP_MIN_LEN BOOTP_ABSOLUTE_MIN_LEN DHCP_MIN_LEN) ] ); @EXPORT_OK = qw( %DHO_CODES %REV_DHO_CODES %DHCP_MESSAGE %REV_DHCP_MESSAGE %BOOTP_CODES %REV_BOOTP_CODES %NWIP_CODES %REV_NWIP_CODES %HTYPE_CODES %REV_HTYPE_CODES %CCC_CODES %REV_CCC_CODES %DHO_FORMATS %GEOCONF_CODES %REV_GEOCONF_CODES %RELAYAGENT_CODES %REV_RELAYAGENT_CODES %SUBOPTION_CODES ); Exporter::export_tags('dho_codes'); Exporter::export_tags('dhcp_message'); Exporter::export_tags('bootp_codes'); Exporter::export_tags('htype_codes'); Exporter::export_tags('nwip_codes'); Exporter::export_tags('ccc_codes'); Exporter::export_tags('geoconf_codes'); Exporter::export_ok_tags('dhcp_other'); # MAGIC_COOKIE for DHCP (otherwise it is BOOTP) use constant MAGIC_COOKIE => "\x63\x82\x53\x63"; use constant DHCP_UDP_OVERHEAD => ( 14 + 20 + 8 ); # Ethernet + IP + UDP use constant DHCP_MAX_MTU => 1500; use constant BOOTP_ABSOLUTE_MIN_LEN => 236; use constant BOOTP_MIN_LEN => 300; use constant DHCP_MIN_LEN => 548; BEGIN { %BOOTP_CODES = ( 'BOOTREQUEST' => 1, 'BOOTREPLY' => 2 ); %HTYPE_CODES = ( 'HTYPE_ETHER' => 1, 'HTYPE_IEEE802' => 6, 'HTYPE_FDDI' => 8 ); %DHO_CODES = ( # rfc 2132 'DHO_PAD' => 0, 'DHO_SUBNET_MASK' => 1, 'DHO_TIME_OFFSET' => 2, 'DHO_ROUTERS' => 3, 'DHO_TIME_SERVERS' => 4, 'DHO_NAME_SERVERS' => 5, 'DHO_DOMAIN_NAME_SERVERS' => 6, 'DHO_LOG_SERVERS' => 7, 'DHO_COOKIE_SERVERS' => 8, 'DHO_LPR_SERVERS' => 9, 'DHO_IMPRESS_SERVERS' => 10, 'DHO_RESOURCE_LOCATION_SERVERS' => 11, 'DHO_HOST_NAME' => 12, 'DHO_BOOT_SIZE' => 13, 'DHO_MERIT_DUMP' => 14, 'DHO_DOMAIN_NAME' => 15, 'DHO_SWAP_SERVER' => 16, 'DHO_ROOT_PATH' => 17, 'DHO_EXTENSIONS_PATH' => 18, 'DHO_IP_FORWARDING' => 19, 'DHO_NON_LOCAL_SOURCE_ROUTING' => 20, 'DHO_POLICY_FILTER' => 21, 'DHO_MAX_DGRAM_REASSEMBLY' => 22, 'DHO_DEFAULT_IP_TTL' => 23, 'DHO_PATH_MTU_AGING_TIMEOUT' => 24, 'DHO_PATH_MTU_PLATEAU_TABLE' => 25, 'DHO_INTERFACE_MTU' => 26, 'DHO_ALL_SUBNETS_LOCAL' => 27, 'DHO_BROADCAST_ADDRESS' => 28, 'DHO_PERFORM_MASK_DISCOVERY' => 29, 'DHO_MASK_SUPPLIER' => 30, 'DHO_ROUTER_DISCOVERY' => 31, 'DHO_ROUTER_SOLICITATION_ADDRESS' => 32, 'DHO_STATIC_ROUTES' => 33, 'DHO_TRAILER_ENCAPSULATION' => 34, 'DHO_ARP_CACHE_TIMEOUT' => 35, 'DHO_IEEE802_3_ENCAPSULATION' => 36, 'DHO_DEFAULT_TCP_TTL' => 37, 'DHO_TCP_KEEPALIVE_INTERVAL' => 38, 'DHO_TCP_KEEPALIVE_GARBAGE' => 39, 'DHO_NIS_DOMAIN' => 40, 'DHO_NIS_SERVERS' => 41, 'DHO_NTP_SERVERS' => 42, 'DHO_VENDOR_ENCAPSULATED_OPTIONS' => 43, 'DHO_NETBIOS_NAME_SERVERS' => 44, 'DHO_NETBIOS_DD_SERVER' => 45, 'DHO_NETBIOS_NODE_TYPE' => 46, 'DHO_NETBIOS_SCOPE' => 47, 'DHO_FONT_SERVERS' => 48, 'DHO_X_DISPLAY_MANAGER' => 49, 'DHO_DHCP_REQUESTED_ADDRESS' => 50, 'DHO_DHCP_LEASE_TIME' => 51, 'DHO_DHCP_OPTION_OVERLOAD' => 52, 'DHO_DHCP_MESSAGE_TYPE' => 53, 'DHO_DHCP_SERVER_IDENTIFIER' => 54, 'DHO_DHCP_PARAMETER_REQUEST_LIST' => 55, 'DHO_DHCP_MESSAGE' => 56, 'DHO_DHCP_MAX_MESSAGE_SIZE' => 57, 'DHO_DHCP_RENEWAL_TIME' => 58, 'DHO_DHCP_REBINDING_TIME' => 59, 'DHO_VENDOR_CLASS_IDENTIFIER' => 60, 'DHO_DHCP_CLIENT_IDENTIFIER' => 61, 'DHO_NWIP_DOMAIN_NAME' => 62, 'DHO_NWIP_SUBOPTIONS' => 63, 'DHO_NISV3_DOMAIN' => 64, 'DHO_NISV3_SERVER' => 65, 'DHO_TFTP_SERVER' => 66, # actually named 'server name' by iana 'DHO_BOOTFILE' => 67, 'DHO_MOBILE_IP_HOME_AGENT' => 68, 'DHO_SMTP_SERVER' => 69, 'DHO_POP3_SERVER' => 70, 'DHO_NNTP_SERVER' => 71, 'DHO_WWW_SERVER' => 72, 'DHO_FINGER_SERVER' => 73, 'DHO_IRC_SERVER' => 74, 'DHO_STREETTALK_SERVER' => 75, 'DHO_STDA_SERVER' => 76, 'DHO_USER_CLASS' => 77, 'DHO_DIRECTORY_AGENT' => 78, 'DHO_SERVICE_SCOPE' => 79, 'DHO_RAPID_COMMIT' => 80, 'DHO_FQDN' => 81, 'DHO_DHCP_AGENT_OPTIONS' => 82, 'DHO_ISNS' => 83, 'DHO_NDS_SERVERS' => 85, 'DHO_NDS_TREE_NAME' => 86, 'DHO_NDS_CONTEXT' => 87, 'DHO_BCMCS_CONTROLLER_DOMAIN_NAME_LIST' => 88, 'DHO_BCMCS_CONTROLLER_IPV4_ADDRESS' => 89, 'DHO_AUTHENTICATION' => 90, 'DHO_CLIENT_LAST_TRANSACTION_TIME' => 91, 'DHO_ASSOCIATED_IP' => 92, 'DHO_CLIENT_SYSTEM' => 93, 'DHO_CLIENT_NDI' => 94, 'DHO_LDAP' => 95, 'DHO_UUID_GUID' => 97, 'DHO_USER_AUTHENTICATION_PROTOCOL' => 98, 'DHO_GEOCONF_CIVIC' => 99, 'DHO_PCODE' => 100, 'DHO_TCODE' => 101, 'DHO_NETINFO_ADDRESS' => 112, 'DHO_NETINFO_TAG' => 113, 'DHO_URL' => 114, 'DHO_AUTO_CONFIGURE' => 116, 'DHO_NAME_SERVICE_SEARCH' => 117, 'DHO_SUBNET_SELECTION' => 118, 'DHO_DOMAIN_SEARCH' => 119, 'DHO_SIP_SERVERS' => 120, 'DHO_CLASSLESS_STATIC_ROUTE' => 121, 'DHO_CCC' => 122, 'DHO_GEOCONF' => 123, 'DHO_VI_VENDOR_CLASS' => 124, 'DHO_VI_VENDOR_SPECIFIC_INFOMATION' => 125, 'DHO_DOCSIS_FULL_SECURITY_SERVER_ADDRESS' => 128, 'DHO_TFTP_SERVER_IPPHONE' => 128, 'DHO_ETHERBOOT_SIGNATURE' => 128, 'DHO_CALL_SERVER_ADDRESS' => 129, 'DHO_KERNEL_OPTIONS' => 129, 'DHO_DISCRIMINATION_STRING' => 130, 'DHO_ETHERNET_INTERFACE' => 130, 'DHO_REMOTE_STATISTICS_SERVER' => 131, 'DHO_VLAN_ID' => 132, 'DHO_L2_PRIORITY' => 133, 'DHO_DSCP' => 134, 'DHO_PXE' => 135, 'DHO_HTTP_PROXY_FORPHONES' => 135, 'DHO_OPTION_PANA_AGENT' => 136, 'DHO_OPTION_PANA_V4_LOST' => 137, 'DHO_OPTION_CAPWAP_AC_V4' => 138, 'DHO_OPTION_IPV4_ADDRESS_MOS' => 139, 'DHO_OPTION_IPV4_FQDN_MOS' => 140, 'DHO_SIP_UA_CONFIGURATION_SERVICE_DOMAINS' => 141, 'DHO_GRUB_CONF_PATH' => 150, 'DHO_TFTP_SERVER_ADDRESS' => 150, # not to be confused with 66 'DHO_ETHERBOOT' => 150, 'DHO_IP_TELEPHONE' => 176, 'DHO_PACKETCABLE_DEPRECATED' => 177, 'DHO_ETHERBOOT_TENTATIVE' => 177, 'DHO_PXELINUX_MAGIC' => 208, 'DHO_CONFIGURATION_FILE' => 209, 'DHO_PATH_PREFIX' => 210, 'DHO_REBOOT_TIME' => 211, 'DHO_OPTION_6RD' => 212, 'DHO_OPTION_V4_ACCESS_DOMAIN' => 213, 'DHO_SUBNET_ALLOCATION' => 220, 'DHO_VIRTUAL_SUBNET' => 221, 'DHO_CLASSLESS_STATIC_ROUTE_MS' => 249, 'DHO_END' => 255 ); # Type 53 codes... %DHCP_MESSAGE = ( #RFC2132 'DHCPDISCOVER' => 1, 'DHCPOFFER' => 2, 'DHCPREQUEST' => 3, 'DHCPDECLINE' => 4, 'DHCPACK' => 5, 'DHCPNAK' => 6, 'DHCPRELEASE' => 7, 'DHCPINFORM' => 8, 'DHCPFORCERENEW' => 9, # RFC4388 'DHCPLEASEQUERY' => 10 , # This is now ratified in RFC4388. If you have an old crappy CMTS you might need to change it with 13 'DHCPLEASEUNASSIGNED' => 11, 'DHCPLEASEUNKNOWN' => 12, 'DHCPLEASEACTIVE' => 13, ); # Type 63 sub-option codes... %NWIP_CODES = ( 'NWIP_DOES_NOT_EXIST' => 1, 'NWIP_EXIST_IN_OPTIONS_AREA' => 2, 'NWIP_EXIST_IN_SNAME_FILE' => 3, 'NWIP_EXIST_BUT_TOO_BIG' => 4, 'NWIP_NSQ_BROADCAST' => 5, 'NWIP_PREFERRED_DSS' => 6, 'NWIP_NEAREST_NWIP_SERVER' => 7, 'NWIP_AUTORETRIES' => 8, 'NWIP_AUTORETRY_SECS' => 9, 'NWIP_1_1' => 10, 'NWIP_PRIMARY_DSS' => 11, #'Unassigned' => '12-255' ); # Type 122 sub option codes %CCC_CODES = ( 'CCC_PRIMARY_DHCP_SERVER' => 1, 'CCC_SECONDARY_DHCP_SERVER' => 2, 'CCC_PROVISIONING_SERVER' => 3, 'CCC_AS_REQ_AS_REP_BACKOFFRETRY' => 4, 'CCC_AP_REQ_AS_REP_BACKOFFRETRY' => 5, 'CCC_KERBEROS_REALM' => 6, 'CCC_TICKET_SERVER_UTILIZATION' => 7, 'CCC_PROVISIONING_TIMER' => 8, 'CCC_SECURITY_TICKET_CONTROL' => 9, 'CCC_KDC_SERVER' => 10, ); # Type 123 sub option codes (there are more, but im not sure how to deal with them) %GEOCONF_CODES = ( 'GEO_METERS' => 1, 'GEO_FLOORS' => 2, ); # Type 82 sub option codes %RELAYAGENT_CODES = ( 'RA_CIRCUIT_ID' => 1, 'RA_REMOTE_ID' => 2, 'RA_DOCSIS_CLASS' => 4, 'RA_LINK_SELECTION' => 5, 'RA_SUBSCRIBER_ID' => 6, 'RA_RADIUS_ATTRIBUTES' => 7, 'RA_AUTHENTICATION' => 8, 'RA_VENDOR_INFO' => 9, 'RA_FLAGS' => 10, 'RA_SERVER_ID_OVERRIDE' => 11, ); } use constant \%DHO_CODES; %REV_DHO_CODES = reverse %DHO_CODES; use constant \%DHCP_MESSAGE; %REV_DHCP_MESSAGE = reverse %DHCP_MESSAGE; use constant \%BOOTP_CODES; %REV_BOOTP_CODES = reverse %BOOTP_CODES; # for reverse lookup use constant \%HTYPE_CODES; %REV_HTYPE_CODES = reverse %HTYPE_CODES; # for reverse lookup use constant \%NWIP_CODES; %REV_NWIP_CODES = reverse %NWIP_CODES; use constant \%CCC_CODES; %REV_CCC_CODES = reverse %CCC_CODES; use constant \%GEOCONF_CODES; %REV_GEOCONF_CODES = reverse %GEOCONF_CODES; use constant \%RELAYAGENT_CODES; %REV_RELAYAGENT_CODES = reverse %RELAYAGENT_CODES; # # Format of DHCP options : for pretty-printing # void : no parameter # inet : 4 bytes IP address # inets : list of 4 bytess IP addresses # inets2 : liste of 4 bytes IP addresses pairs (multiple of 8 bytes) # int : 4 bytes integer # short : 2 bytes integer # shorts : list of 2 bytes integers # byte : 1 byte int # bytes : list of 1 byte code # string : char* (just kidding) # relays : DHCP sub-options (rfc 3046) # ids : client identifier : byte (htype) + string (chaddr) # csr : classless static routes (rfc 3442) # suboptions : hex encoded sub options # our %DHO_FORMATS = ( DHO_PAD() => 'void', DHO_SUBNET_MASK() => 'inet', DHO_TIME_OFFSET() => 'int', DHO_ROUTERS() => 'inets', DHO_TIME_SERVERS() => 'inets', DHO_NAME_SERVERS() => 'inets', DHO_DOMAIN_NAME_SERVERS() => 'inets', DHO_LOG_SERVERS() => 'inets', DHO_COOKIE_SERVERS() => 'inets', DHO_LPR_SERVERS() => 'inets', DHO_IMPRESS_SERVERS() => 'inets', DHO_RESOURCE_LOCATION_SERVERS() => 'inets', DHO_HOST_NAME() => 'string', DHO_BOOT_SIZE() => 'short', DHO_MERIT_DUMP() => 'string', DHO_DOMAIN_NAME() => 'string', DHO_SWAP_SERVER() => 'inet', DHO_ROOT_PATH() => 'string', DHO_EXTENSIONS_PATH() => 'string', DHO_IP_FORWARDING() => 'byte', DHO_NON_LOCAL_SOURCE_ROUTING() => 'byte', DHO_POLICY_FILTER() => 'inets2', DHO_MAX_DGRAM_REASSEMBLY() => 'short', DHO_DEFAULT_IP_TTL() => 'byte', DHO_PATH_MTU_AGING_TIMEOUT() => 'int', DHO_PATH_MTU_PLATEAU_TABLE() => 'shorts', DHO_INTERFACE_MTU() => 'short', DHO_ALL_SUBNETS_LOCAL() => 'byte', DHO_BROADCAST_ADDRESS() => 'inet', DHO_PERFORM_MASK_DISCOVERY() => 'byte', DHO_MASK_SUPPLIER() => 'byte', DHO_ROUTER_DISCOVERY() => 'byte', DHO_ROUTER_SOLICITATION_ADDRESS() => 'inet', DHO_STATIC_ROUTES() => 'inets2', DHO_TRAILER_ENCAPSULATION() => 'byte', DHO_ARP_CACHE_TIMEOUT() => 'int', DHO_IEEE802_3_ENCAPSULATION() => 'byte', DHO_DEFAULT_TCP_TTL() => 'byte', DHO_TCP_KEEPALIVE_INTERVAL() => 'int', DHO_TCP_KEEPALIVE_GARBAGE() => 'byte', DHO_NIS_DOMAIN() => 'string', DHO_NIS_SERVERS() => 'inets', DHO_NTP_SERVERS() => 'inets', DHO_VENDOR_ENCAPSULATED_OPTIONS() => 'suboptions', DHO_NETBIOS_NAME_SERVERS() => 'inets', DHO_NETBIOS_DD_SERVER() => 'inets', DHO_NETBIOS_NODE_TYPE() => 'byte', DHO_NETBIOS_SCOPE() => 'string', DHO_FONT_SERVERS() => 'inets', DHO_X_DISPLAY_MANAGER() => 'inets', DHO_DHCP_REQUESTED_ADDRESS() => 'inet', DHO_DHCP_LEASE_TIME() => 'int', DHO_DHCP_OPTION_OVERLOAD() => 'byte', DHO_DHCP_MESSAGE_TYPE() => 'byte', DHO_DHCP_SERVER_IDENTIFIER() => 'inet', DHO_DHCP_PARAMETER_REQUEST_LIST() => 'bytes', DHO_DHCP_MESSAGE() => 'string', DHO_DHCP_MAX_MESSAGE_SIZE() => 'short', DHO_DHCP_RENEWAL_TIME() => 'int', DHO_DHCP_REBINDING_TIME() => 'int', DHO_VENDOR_CLASS_IDENTIFIER() => 'string', # DHO_DHCP_CLIENT_IDENTIFIER() => 'ids', DHO_NWIP_DOMAIN_NAME() => 'string', # rfc 2242 DHO_NWIP_SUBOPTIONS() => 'suboptions', # rfc 2242 DHO_NISV3_DOMAIN() => 'string', DHO_NISV3_SERVER() => 'string', DHO_TFTP_SERVER() => 'string', DHO_BOOTFILE() => 'string', DHO_MOBILE_IP_HOME_AGENT() => 'inets', DHO_SMTP_SERVER() => 'inets', DHO_POP3_SERVER() => 'inets', DHO_NNTP_SERVER() => 'inets', DHO_WWW_SERVER() => 'inets', DHO_FINGER_SERVER() => 'inets', DHO_IRC_SERVER() => 'inets', DHO_STREETTALK_SERVER() => 'inets', DHO_STDA_SERVER() => 'inets', DHO_CCC => 'suboptions', # DHO_USER_CLASS() => '', # rfc 3004 # DHO_FQDN() => '', # draft-ietf-dhc-fqdn-option-10.txt # DHO_DHCP_AGENT_OPTIONS() => 'relays', # rfc 3046 DHO_DHCP_AGENT_OPTIONS() => 'string', # rfc 3046 DHO_NDS_SERVERS() => 'inets', # rfc 2241 DHO_NDS_TREE_NAME() => 'string', # rfc 2241 DHO_USER_AUTHENTICATION_PROTOCOL() => 'string', # rfc 2485 DHO_AUTO_CONFIGURE() => 'byte', # rfc 2563 DHO_NAME_SERVICE_SEARCH() => 'shorts', # rfc 2937 DHO_SUBNET_SELECTION() => 'inet', # rfc 3011 DHO_CLASSLESS_STATIC_ROUTE() => 'csr', # rfc 3442 DHO_CLASSLESS_STATIC_ROUTE_MS() => 'csr', ); # Links option codes with their suboption values %SUBOPTION_CODES = ( $DHO_CODES{'DHO_NWIP_SUBOPTIONS'} => \%NWIP_CODES, # option 63 $DHO_CODES{'DHO_DHCP_AGENT_OPTIONS'} => \%RELAYAGENT_CODES, # option 82 $DHO_CODES{'DHO_CCC'} => \%CCC_CODES, # option 122 $DHO_CODES{'DHO_GEOCONF'} => \%GEOCONF_CODES, # option 123 ); 1; =pod =head1 NAME Net::DHCP::Constants - Constants for DHCP codes and options =head1 SYNOPSIS use Net::DHCP::Constants; print "DHCP option SUBNET_MASK is ", DHO_SUBNET_MASK(); =head1 DESCRIPTION Represents constants used in DHCP protocol, defined in RFC 1533, RFC 2132, RFC 2241, RFC 2485, RFC 2563, RFC 2937, RFC 3004, RFC 3011, RFC 3046. =head1 TAGS As mentioned above, constants can either be imported individually or in sets grouped by tag names. The tag names are: =over 4 =item * bootp_codes Imports all of the basic I constants. (01) BOOTREQUEST (02) BOOTREPLY =item * htype_codes Imports all I (hardware address type) codes. (01) HTYPE_ETHER (06) HTYPE_IEEE802 (08) HTYPE_FDDI Most common value is HTYPE_ETHER for C. =item * dhcp_message Import all DHCP Message codes. (rfc2132) (01) DHCPDISCOVER (02) DHCPOFFER (03) DHCPREQUEST (04) DHCPDECLINE (05) DHCPACK (06) DHCPNAK (07) DHCPRELEASE (08) DHCPINFORM (09) DHCPFORCERENEW (rfc4388) (10) DHCPLEASEQUERY (11) DHCPLEASEUNASSIGNED (12) DHCPLEASEUNKNOWN (13) DHCPLEASEACTIVE Nb. Previously Cisco used 13 for DHCPLEASEQUERY. If you need to decode or encode packets to communicate with such a system, you might simply us the integer rather than the constant - or use the updated constant and comment in your code appropriately. =item * dho_codes Import all DHCP option codes. (000) DHO_PAD (001) DHO_SUBNET_MASK (002) DHO_TIME_OFFSET (003) DHO_ROUTERS (004) DHO_TIME_SERVERS (005) DHO_NAME_SERVERS (006) DHO_DOMAIN_NAME_SERVERS (007) DHO_LOG_SERVERS (008) DHO_COOKIE_SERVERS (009) DHO_LPR_SERVERS (010) DHO_IMPRESS_SERVERS (011) DHO_RESOURCE_LOCATION_SERVERS (012) DHO_HOST_NAME (013) DHO_BOOT_SIZE (014) DHO_MERIT_DUMP (015) DHO_DOMAIN_NAME (016) DHO_SWAP_SERVER (017) DHO_ROOT_PATH (018) DHO_EXTENSIONS_PATH (019) DHO_IP_FORWARDING (020) DHO_NON_LOCAL_SOURCE_ROUTING (021) DHO_POLICY_FILTER (022) DHO_MAX_DGRAM_REASSEMBLY (023) DHO_DEFAULT_IP_TTL (024) DHO_PATH_MTU_AGING_TIMEOUT (025) DHO_PATH_MTU_PLATEAU_TABLE (026) DHO_INTERFACE_MTU (027) DHO_ALL_SUBNETS_LOCAL (028) DHO_BROADCAST_ADDRESS (029) DHO_PERFORM_MASK_DISCOVERY (030) DHO_MASK_SUPPLIER (031) DHO_ROUTER_DISCOVERY (032) DHO_ROUTER_SOLICITATION_ADDRESS (033) DHO_STATIC_ROUTES (034) DHO_TRAILER_ENCAPSULATION (035) DHO_ARP_CACHE_TIMEOUT (036) DHO_IEEE802_3_ENCAPSULATION (037) DHO_DEFAULT_TCP_TTL (038) DHO_TCP_KEEPALIVE_INTERVAL (039) DHO_TCP_KEEPALIVE_GARBAGE (040) DHO_NIS_DOMAIN (041) DHO_NIS_SERVERS (042) DHO_NTP_SERVERS (043) DHO_VENDOR_ENCAPSULATED_OPTIONS (044) DHO_NETBIOS_NAME_SERVERS (045) DHO_NETBIOS_DD_SERVER (046) DHO_NETBIOS_NODE_TYPE (047) DHO_NETBIOS_SCOPE (048) DHO_FONT_SERVERS (049) DHO_X_DISPLAY_MANAGER (050) DHO_DHCP_REQUESTED_ADDRESS (051) DHO_DHCP_LEASE_TIME (052) DHO_DHCP_OPTION_OVERLOAD (053) DHO_DHCP_MESSAGE_TYPE (054) DHO_DHCP_SERVER_IDENTIFIER (055) DHO_DHCP_PARAMETER_REQUEST_LIST (056) DHO_DHCP_MESSAGE (057) DHO_DHCP_MAX_MESSAGE_SIZE (058) DHO_DHCP_RENEWAL_TIME (059) DHO_DHCP_REBINDING_TIME (060) DHO_VENDOR_CLASS_IDENTIFIER (061) DHO_DHCP_CLIENT_IDENTIFIER (062) DHO_NWIP_DOMAIN_NAME (063) DHO_NWIP_SUBOPTIONS (064) DHO_NISV3_DOMAIN (065) DHO_NISV3_SERVER (066) DHO_TFTP_SERVER (067) DHO_BOOTFILE (068) DHO_MOBILE_IP_HOME_AGENT (069) DHO_SMTP_SERVER (070) DHO_POP3_SERVER (071) DHO_NNTP_SERVER (072) DHO_WWW_SERVER (073) DHO_FINGER_SERVER (074) DHO_IRC_SERVER (075) DHO_STREETTALK_SERVER (076) DHO_STDA_SERVER (077) DHO_USER_CLASS (078) DHO_DIRECTORY_AGENT (079) DHO_SERVICE_SCOPE (080) DHO_RAPID_COMMIT (081) DHO_FQDN (082) DHO_DHCP_AGENT_OPTIONS (083) DHO_ISNS (085) DHO_NDS_SERVERS (086) DHO_NDS_TREE_NAME (087) DHO_NDS_CONTEXT (088) DHO_BCMCS_CONTROLLER_DOMAIN_NAME_LIST (089) DHO_BCMCS_CONTROLLER_IPV4_ADDRESS (090) DHO_AUTHENTICATION (091) DHO_CLIENT_LAST_TRANSACTION_TIME (092) DHO_ASSOCIATED_IP (093) DHO_CLIENT_SYSTEM (094) DHO_CLIENT_NDI (095) DHO_LDAP (097) DHO_UUID_GUID (098) DHO_USER_AUTHENTICATION_PROTOCOL (099) DHO_GEOCONF_CIVIC (100) DHO_PCODE (101) DHO_TCODE (112) DHO_NETINFO_ADDRESS (113) DHO_NETINFO_TAG (114) DHO_URL (116) DHO_AUTO_CONFIGURE (117) DHO_NAME_SERVICE_SEARCH (118) DHO_SUBNET_SELECTION (119) DHO_DOMAIN_SEARCH (120) DHO_SIP_SERVERS (121) DHO_CLASSLESS_STATIC_ROUTE (122) DHO_CCC (123) DHO_GEOCONF (124) DHO_VI_VENDOR_CLASS (125) DHO_VI_VENDOR_SPECIFIC_INFOMATION (128) DHO_ETHERBOOT_SIGNATURE (129) DHO_CALL_SERVER_ADDRESS (130) DHO_DISCRIMINATION_STRING (131) DHO_REMOTE_STATISTICS_SERVER (132) DHO_VLAN_ID (133) DHO_L2_PRIORITY (134) DHO_DSCP (135) DHO_HTTP_PROXY_FORPHONES (136) DHO_OPTION_PANA_AGENT (137) DHO_OPTION_PANA_V4_LOST (138) DHO_OPTION_CAPWAP_AC_V4 (139) DHO_OPTION_IPV4_ADDRESS_MOS (140) DHO_OPTION_IPV4_FQDN_MOS (141) DHO_SIP_UA_CONFIGURATION_SERVICE_DOMAINS (150) DHO_ETHERBOOT (176) DHO_IP_TELEPHONE (177) DHO_PACKETCABLE_DEPRECATED (208) DHO_PXELINUX_MAGIC (209) DHO_CONFIGURATION_FILE (210) DHO_PATH_PREFIX (211) DHO_REBOOT_TIME (212) DHO_OPTION_6RD (213) DHO_OPTION_V4_ACCESS_DOMAIN (220) DHO_SUBNET_ALLOCATION (221) DHO_VIRTUAL_SUBNET (249) DHO_CLASSLESS_STATIC_ROUTE_MS (255) DHO_END =item * ccc_codes Import all CableLabs Client Configuration (001) CCC_PRIMARY_DHCP_SERVER (002) CCC_SECONDARY_DHCP_SERVER (003) CCC_PROVISIONING_SERVER (004) CCC_AS_REQ_AS_REP_BACKOFFRETRY (005) CCC_AP_REQ_AS_REP_BACKOFFRETRY (006) CCC_KERBEROS_REALM (007) CCC_TICKET_SERVER_UTILIZATION (008) CCC_PROVISIONING_TIMER (009) CCC_SECURITY_TICKET_CONTROL (010) CCC_KDC_SERVER =back =head1 TO DO, LIMITATIONS Automatic parsing of DHO_VENDOR_ENCAPSULATED_OPTIONS (code 43) is unsupported. Automatic parsing of DHO_NWIP_SUBOPTIONS (code 63 - rfc 2242) is unsupported. Automatic parsing of DHO_USER_CLASS (code 77 - rfc 3004) is unsupported. Automatic parsing of DHO_CCC (code 122 - rfc 3495) is unsupported. Automatic parsing of DHO_PACKETCABLE_DEPRECATED (code 177 - rfc 3495) is unsupported. =head1 SEE ALSO L, L =head1 AUTHOR Dean Hamstead Edjzort@cpan.orgE and past Authors (see README) =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut libnet-dhcp-perl-0.693+dfsg.orig/docs/0000755000175000017500000000000012224056470017344 5ustar cstamascstamas