Home | History | Annotate | Line # | Download | only in DHCPv6
      1  1.1  christos In order to test the DHCPv6 server, we have a configuration file with
      2  1.1  christos known values, and some Perl scripts designed to send and receive
      3  1.1  christos DHCPv6 packets to check various code paths.
      4  1.1  christos 
      5  1.1  christos It is not complete test converage by any means, but it should be
      6  1.1  christos fairly easy to add additional tests as needed.
      7  1.1  christos 
      8  1.1  christos The scripts themselves are not very well written. There is a lot of
      9  1.1  christos copied code, poor error handling, and so on. These should be rewritten
     10  1.1  christos at some point.
     11  1.1  christos 
     12  1.1  christos To use, the DHCPv6 server must be running in test mode to send back to
     13  1.1  christos the originating port. (The scripts can be changed to bind to the
     14  1.1  christos appropriate client port, but they don't now, and have to run as root
     15  1.1  christos to do this). In server/dhcpv6.c, look for this comment:
     16  1.1  christos 
     17  1.1  christos /* For testing, we reply to the sending port, so we don't need a root */
     18  1.1  christos /* client */
     19  1.1  christos 		to_addr.sin6_port = remote_port;
     20  1.1  christos /*		to_addr.sin6_port = packet->client_port;*/
     21  1.1  christos 
     22  1.1  christos And change the code to use the client_port value.
     23  1.1  christos 
     24  1.1  christos You will need to modify one of the test configuration files to use one 
     25  1.1  christos of the physical subnets that your machine uses, in the subnet6 
     26  1.1  christos statement.
     27  1.1  christos 
     28  1.1  christos Then run the server as root, in debug mode:
     29  1.1  christos 
     30  1.1  christos # touch /tmp/test.leases
     31  1.1  christos # dhcpd -6 -cf test-a.conf -lf /tmp/test.leases -d
     32  1.1  christos 
     33  1.1  christos You can invoke the scripts then:
     34  1.1  christos 
     35  1.1  christos $ perl 000-badmsgtype.pl
     36  1.1  christos 
     37  1.1  christos The expected results vary per script, depending on the behavior that
     38  1.1  christos is being tested.
     39  1.1  christos 
     40  1.1  christos 
     41  1.1  christos Notes about scripts:
     42  1.1  christos 
     43  1.1  christos In order to manipulate IPv6 addresses, we need the Socket6 library,
     44  1.1  christos available from CPAN:
     45  1.1  christos 
     46  1.1  christos http://search.cpan.org/~umemoto/Socket6-0.19/Socket6.pm
     47  1.1  christos 
     48  1.1  christos The Perl that Sun issues for Solaris 10 is compiled with the Sun
     49  1.1  christos compiler. If you have the Sun compiler, then this will work fine.
     50  1.1  christos Otherwise you may need to install Perl from source.
     51  1.1  christos 
     52  1.1  christos We need to get the hardware address in order to build DUID properly.
     53  1.1  christos The IO::Interface module reports hardware address, but not on Solaris
     54  1.1  christos 10 it seems. Rather than do this the "right way", we do it the "Perl
     55  1.1  christos way", and hack it. "ifconfig" does return the Ethernet address, but
     56  1.1  christos only to the root user. However, we can look for files of the name
     57  1.1  christos /etc/hostname.*, get the IP address from "ifconfig", and then check
     58  1.1  christos for those addresses in the ARP table.
     59  1.1  christos 
     60  1.1  christos Client DUID is supposed to be an opaque value to the server, but we go
     61  1.1  christos ahead and make a "real" type 1 or type 3 DUID.
     62  1.1  christos 
     63