1Validator(3) User Contributed Perl Documentation Validator(3)
2
3
4
6 Net::DNS::SEC::Validator - interface to libval(3) and related constants, structures and functions.
7
9 use Net::DNS::SEC::Validator;
10 use Net::DNS::Packet;
11 use Net::hostent;
12 use Net::addrinfo;
13 use Socket qw(:all);
14
15 my $validator = new Net::DNS::SEC::Validator(policy => ":");
16 my (@r) = $validator->getaddrinfo("good-A.test.dnssec-tools.org");
17 my $r = $validator->res_query("marzot.net", "IN", "MX");
18 my $h = $validator->gethostbyname("good-AAAA.test.dnssec-tools.org",
19 AF_INET6);
20
22 This Perl module is designed to implement and export functionality pro‐
23 vided by the validating DNS resolver library, libval(3). The functions
24 are provided through an easy-to-use object oriented interface. The
25 interface is designed for the higher level user, hiding some of the
26 complexity of validating resolvers. Nevertheless, application interface
27 behavior can be customized through configuration files provided by lib‐
28 val(3) and extensive error codes returned.
29
30 Details of DNSSEC and associated resolver behavior may be found in the
31 core DNSSEC RFCs (4033-4035).
32
34 A description of the API follows:
35
36 Contructor:
37
38 To create a validator object use the Net::DNS::SEC::Validator->new()
39 method. This method optionally takes a policy label (policy =>
40 'label'), or default to using the default label in the libval(3)
41 dnsval.conf file.
42
43 Data Fields:
44
45 $validator->{error} =>The latest method error code
46 $validator->{errorStr} => the latest method error string
47 $validator->{valStatus} => the val_status of last call (if single)
48 $validator->{valStatusStr} => the val_status string of last call
49
50 Methods:
51
52 $validator->getaddrinfo(<name>[,<service>[,<hints>]])
53
54 where:
55
56 <name> => is the node name or numeric address being queried
57 <service> => is the name or number represting the service
58 (note: <name> or <service> may be undef, but not both)
59 <hint> => a Net::addrinfo object specying flags, family, etc.
60
61 returns:
62
63 An array of Net::addrinfo objects (augmented with a 'val_status'
64 field). On error, returns an empty array. in scalar context
65 returns first Net::addrinfo object, or undef on error.
66
67 $validator->gethostbyname(<name>[,<family>])
68
69 where:
70
71 <name> => is the node name or numeric address being queried
72 <family> => the address family of returned entry (default: AF_INET)
73
74 returns:
75
76 A Net::hostent object. Validator valStatus/valStatusStr fields
77 will be updated. On error, undef is returned and validator object
78 error/errorStr fields are updated.
79
80 $validator->res_query(<name>[,<class>[,<type>]])
81
82 where:
83
84 <name> => is the node name or numeric address being queried
85 <class> => is the DNS class of the record being queried (default: IN)
86 <type> => is the DNS record type being queried (defailt A)
87
88 returns:
89
90 A packed DNS query result is returned on success. This object is
91 suitable to be passed to the Net::DNS::Packet(\$result)
92 interface for parsing. Validator valStatus/valStatusStr fields
93 will be updated. On error, undef is returned and validator
94 object error/errorStr fields are updated.
95
96 $validator->policy([<label>])
97
98 where:
99
100 <label> => the policy label to use (old context is destroyed)
101 (default: ":" dnsval.conf default policy)
102
103 returns:
104
105 the policy label currently (after change) being used.
106
107 $validator->istrusted([<val_status>])
108
109 where:
110
111 <val_status> => numeric vaildator status code
112 (default: $validator->{valStatus})
113
114 returns:
115
116 A boolean positive value if <val_status> is a trusted result.
117
118 $validator->valStatusStr([<val_status>])
119
120 where:
121
122 <val_status> => numeric vaildator status code
123 (default: $validator->{valStatus})
124
125 returns:
126
127 A string representation of the given <val_status>.
128
130 use Net::DNS::SEC::Validator;
131 use Net::DNS::Packet;
132 use Net::hostent;
133 use Net::addrinfo;
134 use Socket qw(:all);
135
136 # construct object
137 my $validator = new Net::DNS::SEC::Validator(policy => ":");
138
139 # change validation policy
140 $validator->policy("validate_tools:");
141
142 # fetch array of Net::addrinfo objects
143 my (@r) = $validator->getaddrinfo("good-A.test.dnssec-tools.org");
144 foreach $a (@r) {
145 print $a->stringify, " is trusted\n"
146 if $validator->istrusted($a->val_status));
147 }
148
149 # query an MX record
150 my $r = $validator->res_query("marzot.net", "IN", "MX");
151 my ($pkt, $err) = new Net::DNS::Packet(\$r);
152 print ($validator->istrusted ?
153 "result is trusted\n" :
154 "result is NOT trusted\n");
155
156 my $h = $validator->gethostbyname("good-A.test.dnssec-tools.org");
157 if ( @{$h->addr_list}) {
158 my $i;
159 for $addr ( @{$h->addr_list} ) {
160 printf "\taddr #%d is [%s]\n", $i++, inet_ntoa($addr);
161 }
162 }
163
165 Copyright (c) 2006 G. S. Marzot. All rights reserved. This program
166 is free software; you can redistribute it and/or modify it under
167 the same terms as Perl itself.
168
169 Copyright (c) 2006 SPARTA, Inc. All Rights Reserved. This program
170 is free software; you can redistribute it and/or modify it under
171 the same terms as Perl itself.
172
174 G. S. Marzot (marz@users.sourceforge.net)
175
176
177
178perl v5.8.8 2007-07-08 Validator(3)