• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

恥ずかしい勘違いから生まれた、DHCP6の不要かつ部分的な実装


Commit MetaInfo

Revision916c9dd705307497cf53e8253123e3f6f192c3f1 (tree)
Time2021-08-14 06:12:11
Authordyknon <dyknon@user...>
Commiterdyknon

Log Message

AbstructOption::Numeric

Change Summary

Incremental Difference

--- a/Net/DHCP6/AbstractOption/DUID.pm
+++ b/Net/DHCP6/AbstractOption/DUID.pm
@@ -11,6 +11,8 @@ use Net::DHCP6::Option;
1111 our $VERSION = "0.001";
1212 our @ISA = qw/Net::DHCP6::Option/;
1313
14+use constant verify => 1;
15+
1416 sub new {
1517 my $class = shift;
1618 my $self;
--- /dev/null
+++ b/Net/DHCP6/AbstractOption/Numeric.pm
@@ -0,0 +1,46 @@
1+package Net::DHCP6::AbstractOption::Numeric;
2+# base class for option
3+
4+use strict;
5+use warnings;
6+use Net::DHCP6::AbstractOption::FixedLength;
7+
8+our $VERSION = "0.001";
9+our @ISA = qw/Net::DHCP6::AbstractOption::FixedLength/;
10+
11+sub template { ... }
12+sub range { (undef, undef) }
13+
14+sub value {
15+ my $self = shift;
16+ $$self;
17+}
18+
19+sub len {
20+ my $self = shift;
21+ length pack($self->template, 0);
22+}
23+
24+sub verify {
25+ my $self = shift;
26+ my $who = shift;
27+ my ($from, $to) = $self->range;
28+ return 0 if(defined $from && $from > $self->value);
29+ return 0 if(defined $to && $to <= $self->value);
30+ 1;
31+}
32+
33+sub data {
34+ my $self = shift;
35+ die "out of range" unless($self->value >= 0 && $self->value < 2**16);
36+ pack($self->template, $self->value);
37+}
38+
39+sub parse_data {
40+ my $class = shift;
41+ my $data = shift;
42+ my ($value) = unpack($self->template, $data);
43+ \$value;
44+}
45+
46+1;
--- /dev/null
+++ b/Net/DHCP6/AbstractOption/U16.pm
@@ -0,0 +1,14 @@
1+package Net::DHCP6::AbstractOption::U16;
2+# base class for option
3+
4+use strict;
5+use warnings;
6+use Net::DHCP6::AbstractOption::Numeric;
7+
8+our $VERSION = "0.001";
9+our @ISA = qw/Net::DHCP6::AbstractOption::Numeric/;
10+
11+use constant template => "S>";
12+use constant len => 2;
13+
14+1;
--- /dev/null
+++ b/Net/DHCP6/AbstractOption/U32.pm
@@ -0,0 +1,14 @@
1+package Net::DHCP6::AbstractOption::U32;
2+# base class for option
3+
4+use strict;
5+use warnings;
6+use Net::DHCP6::AbstractOption::Numeric;
7+
8+our $VERSION = "0.001";
9+our @ISA = qw/Net::DHCP6::AbstractOption::Numeric/;
10+
11+use constant template => "L>";
12+use constant len => 4;
13+
14+1;
--- a/Net/DHCP6/Option/DnsServer.pm
+++ b/Net/DHCP6/Option/DnsServer.pm
@@ -11,6 +11,7 @@ our @ISA = qw/Net::DHCP6::AbstractOption::Ipv6AddrList/;
1111
1212 use constant code => DHCP6_OPT_DNS_SERVERS;
1313 use constant name => "DnsServer";
14+use constant verify => 1;
1415
1516 __PACKAGE__->register_option;
1617 1;
--- a/Net/DHCP6/Option/DomainList.pm
+++ b/Net/DHCP6/Option/DomainList.pm
@@ -11,6 +11,7 @@ our @ISA = qw/Net::DHCP6::AbstractOption::DomainNameList/;
1111
1212 use constant code => DHCP6_OPT_DOMAIN_LIST;
1313 use constant name => "DomainList";
14+use constant verify => 1;
1415
1516 __PACKAGE__->register_option;
1617 1;
--- a/Net/DHCP6/Option/ElapsedTime.pm
+++ b/Net/DHCP6/Option/ElapsedTime.pm
@@ -3,15 +3,15 @@ package Net::DHCP6::Option::ElapsedTime;
33
44 use strict;
55 use warnings;
6-use Net::DHCP6::AbstractOption::FixedLength;
6+use Net::DHCP6::AbstractOption::U16;
77 use Net::DHCP6::Parameters qw/DHCP6_OPT_ELAPSED_TIME/;
88
99 our $VERSION = "0.001";
10-our @ISA = qw/Net::DHCP6::AbstractOption::FixedLength/;
10+our @ISA = qw/Net::DHCP6::AbstractOption::U16/;
1111
1212 use constant code => DHCP6_OPT_ELAPSED_TIME;
1313 use constant name => "ElapsedTime";
14-use constant len => 2;
14+use constant verify => 1;
1515
1616 sub new_special {
1717 my $class = shift;
@@ -20,15 +20,9 @@ sub new_special {
2020 bless $self, $class;
2121 }
2222
23-sub data {
24- my $self = shift;
25- die "out of range" unless($self->time >= 0 && $self->time < 2**16);
26- pack("S>", $self->time);
27-}
28-
2923 sub time {
3024 my $self = shift;
31- $$self;
25+ $self->value;
3226 }
3327
3428 sub sec {
@@ -36,13 +30,6 @@ sub sec {
3630 $self->time / 100;
3731 }
3832
39-sub parse_data {
40- my $class = shift;
41- my $data = shift;
42- my ($time) = unpack("S>", $data);
43- \$time;
44-}
45-
4633 sub data_str {
4734 my $self = shift;
4835 $self->sec . "s";