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