File: 52-net-dhcp-packet-new-empty.t

package info (click to toggle)
libnet-dhcp-perl 0.693%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 368 kB
  • ctags: 111
  • sloc: perl: 1,974; sh: 51; makefile: 8
file content (53 lines) | stat: -rwxr-xr-x 1,823 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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");