• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Révision3b42395e7dd142ac1921bf00340b822e4ae38d0f (tree)
l'heure2021-08-15 22:02:12
Auteurdyknon <dyknon@user...>
Commiterdyknon

Message de Log

InfoRefresh option

Change Summary

Modification

--- /dev/null
+++ b/Net/DHCP6/AbstractOption/Time.pm
@@ -0,0 +1,61 @@
1+package Net::DHCP6::AbstructOption::Time;
2+# RFC8415 7.7.
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+use constant len => 4;
12+sub range { (undef, undef) }
13+
14+sub data {
15+ my $self = shift;
16+ return "\xff\xff\xff\xff" if($self->value == "inf");
17+ pack("L>", $self->value);
18+}
19+
20+sub parse_data {
21+ my $class = shift;
22+ my $data = shift;
23+ my $value = unpack("L>", $data);
24+ $value = "inf" if($value == 0xffffffff);
25+ \$value;
26+}
27+
28+sub new_special {
29+ my $class = shift;
30+ my $val = shift;
31+ die "out of range" if(($val >= 0xffffffff || $val < 0) && $val != "inf");
32+ my $self = \$val;
33+ bless $self, $class;
34+}
35+
36+sub verify {
37+ my $self = shift;
38+ my $who = shift;
39+ my ($from, $to) = $self->range;
40+ return 0 if(defined $from && $from > $self->value);
41+ return 0 if(defined $to && $to <= $self->value);
42+ return 0 if($self->value != "inf" && $self->value >= 0xffffffff);
43+ 1;
44+}
45+
46+sub data_str {
47+ my $self = shift;
48+ if($self->sec == "inf"){
49+ "infinity";
50+ }else{
51+ $self->sec . "s";
52+ }
53+}
54+
55+sub time {
56+ my $self = shift;
57+ $$self;
58+}
59+sub sec { &time; }
60+
61+1;
--- /dev/null
+++ b/Net/DHCP6/Option/InfoRefresh.pm
@@ -0,0 +1,20 @@
1+package Net::DHCP6::Option::InfoRefresh;
2+# RFC8415 21.23.
3+
4+use strict;
5+use warnings;
6+use Net::DHCP6::AbstructOption::Time;
7+use Net::DHCP6::Parameters qw(
8+ DHCP6_OPT_INFORMATION_REFRESH_TIME
9+ DHCP6_TX_IRT_MINIMUM
10+);
11+
12+our $VERSION = "0.001";
13+our @ISA = qw/Net::DHCP6::AbstructOption::Time/;
14+
15+use constant code => DHCP6_OPT_INFORMATION_REFRESH_TIME;
16+use constant name => "InfoRefresh";
17+use constant range => (IRT_MINIMUM, undef);
18+
19+__PACKAGE__->register_option;
20+1;