Debian Codegraph @

contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecZone.pm

raw
1 package DNS::LDNS::DNSSecZone;
2
3 use 5.008008;
4 use strict;
5 use warnings;
6
7 use DNS::LDNS ':all';
8
9 our $VERSION = '0.61';
10
11 sub new {
12 my ($class, %args) = @_;
13
14 my $line_nr;
15 my $status = &LDNS_STATUS_OK;
16 my $zone;
17 my $file;
18
19 if ($args{filename}) {
20 unless (open FILE, $args{filename}) {
21 $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR;
22 $DNS::LDNS::line_nr = 0;
23 return;
24 }
25
26 $file = \*FILE;
27 }
28 elsif ($args{file}) {
29 $file = $args{file};
30 }
31
32 if ($file) {
33 $zone = _new_from_file($file,
34 $args{origin},
35 $args{ttl} || 0,
36 $args{class} || 0,
37 $status, $line_nr);
38 }
39 else {
40 $zone = _new();
41 }
42
43 if ($args{filename}) {
44 close $file;
45 }
46
47 $DNS::LDNS::last_status = $status;
48 $DNS::LDNS::line_nr = $line_nr;
49 if (!defined $zone) {
50 return;
51 }
52
53 return $zone;
54 }
55
56 sub soa {
57 my $self = shift;
58 return DNS::LDNS::GC::own($self->_soa, $self);
59 }
60
61 sub names {
62 my $self = shift;
63 return DNS::LDNS::GC::own($self->_names, $self);
64 }
65
66 sub find_rrset {
67 my ($self, $name, $type) = @_;
68 return DNS::LDNS::GC::own($self->_find_rrset($name, $type), $self);
69 }
70
71 sub add_rr {
72 my ($self, $rr) = @_;
73
74 # Set a copy of the rr in case it is already owned
75 my $s = _add_rr($self, my $copy = $rr->clone);
76 $DNS::LDNS::last_status = $s;
77 DNS::LDNS::GC::own($copy, $self);
78 return $s;
79 }
80
81 sub add_empty_nonterminals {
82 my $self = shift;
83 my $s = _add_empty_nonterminals($self);
84 $DNS::LDNS::last_status = $s;
85 return $s;
86 }
87
88 sub mark_glue {
89 my $self = shift;
90 my $s = _mark_glue($self);
91 $DNS::LDNS::last_status = $s;
92 return $s;
93 }
94
95 sub sign {
96 my ($self, $keylist, $policy, $flags) = @_;
97 my $s = _sign($self, $keylist, $policy, $flags);
98 $DNS::LDNS::last_status = $s;
99 return $s;
100 }
101
102 sub sign_nsec3 {
103 my ($self, $keylist, $policy, $algorithm, $flags, $iterations, $salt,
104 $signflags) = @_;
105 my $s = _sign_nsec3($self, $keylist, $policy, $algorithm, $flags,
106 $iterations, $salt, $signflags);
107 $DNS::LDNS::last_status = $s;
108 return $s;
109 }
110
111 sub to_string {
112 return "DNS::LDNS::DNSSecZone::to_string is not yet implemented";
113 }
114
115 sub DESTROY {
116 DNS::LDNS::GC::free($_[0]);
117 }
118
119 1;
120 __END__
121
122 =head1 NAME
123
124 DNS::LDNS::DNSSecZone - Zone with dnssec data
125
126 =head1 SYNOPSIS
127
128 use DNS::LDNS ':all'
129
130 my z = new DNS::LDNS::DNSSecZone(
131 filename => '/path/to/myzone',
132 origin => new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone'), #optional
133 ttl => 3600, #optional
134 class => LDNS_RR_CLASS_, #optional
135 )
136 my z = new DNS::LDNS::DNSSecZone(
137 file => \*FILE,
138 origin => ..., ttl => ..., class => ...
139 )
140 my z = new DNS::LDNS::DNSSecZone
141
142 rr = z->soa
143 rbtree = z->names
144 rrsets = z->find_rrset
145 z->add_rr(rr)
146 z->create_from_zone(zone)
147 z->add_empty_nonterminals
148
149 z->sign(keylist, policy)
150 z->sign_nsec3(keylist, policy, algorithm, flags, iterations, salt)
151
152 z->create_nsecs
153 z->create_nsec3s(algorithm, flags, iterations, salt)
154 z->create_rrsigs(key_list, policy, flags)
155
156 =head1 TODO
157
158 z->to_string
159
160 =head1 SEE ALSO
161
162 http://www.nlnetlabs.nl/projects/ldns
163
164 =head1 AUTHOR
165
166 Erik Pihl Ostlyngen, E<lt>[email protected]<gt>
167
168 =head1 COPYRIGHT AND LICENSE
169
170 Copyright (C) 2013 by UNINETT Norid AS
171
172 This library is free software; you can redistribute it and/or modify
173 it under the same terms as Perl itself, either Perl version 5.14.2 or,
174 at your option, any later version of Perl 5 you may have available.
175
176 =cut