1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
4/**
5 * DNS Library for handling lookups and updates.
6 *
7 * PHP Version 5
8 *
9 * Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 *   * Redistributions of source code must retain the above copyright
17 *     notice, this list of conditions and the following disclaimer.
18 *
19 *   * Redistributions in binary form must reproduce the above copyright
20 *     notice, this list of conditions and the following disclaimer in
21 *     the documentation and/or other materials provided with the
22 *     distribution.
23 *
24 *   * Neither the name of Mike Pultz nor the names of his contributors
25 *     may be used to endorse or promote products derived from this
26 *     software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 *
41 * @category  Networking
42 * @package   Net_DNS2
43 * @author    Mike Pultz <mike@mikepultz.com>
44 * @copyright 2010 Mike Pultz <mike@mikepultz.com>
45 * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
46 * @version   SVN: $Id$
47 * @link      http://pear.php.net/package/Net_DNS2
48 * @since     File available since Release 0.6.0
49 *
50 */
51
52//
53// initalize the packet id value
54//
55Net_DNS2_Lookups::$next_packet_id   = mt_rand(0, 65535);
56
57//
58// build the reverse lookup tables; this is just so we don't have to
59// have duplicate static content laying around.
60//
61Net_DNS2_Lookups::$rr_types_by_id       = array_flip(Net_DNS2_Lookups::$rr_types_by_name);
62Net_DNS2_Lookups::$classes_by_id        = array_flip(Net_DNS2_Lookups::$classes_by_name);
63Net_DNS2_Lookups::$rr_types_class_to_id = array_flip(Net_DNS2_Lookups::$rr_types_id_to_class);
64Net_DNS2_Lookups::$algorithm_name_to_id = array_flip(Net_DNS2_Lookups::$algorithm_id_to_name);
65Net_DNS2_Lookups::$digest_name_to_id    = array_flip(Net_DNS2_Lookups::$digest_id_to_name);
66Net_DNS2_Lookups::$rr_qtypes_by_id      = array_flip(Net_DNS2_Lookups::$rr_qtypes_by_name);
67Net_DNS2_Lookups::$rr_metatypes_by_id   = array_flip(Net_DNS2_Lookups::$rr_metatypes_by_name);
68Net_DNS2_Lookups::$protocol_by_id       = array_flip(Net_DNS2_Lookups::$protocol_by_name);
69
70/**
71 * This class provides simple lookups used througout the Net_DNS2 code
72 *
73 * @category Networking
74 * @package  Net_DNS2
75 * @author   Mike Pultz <mike@mikepultz.com>
76 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
77 * @link     http://pear.php.net/package/Net_DNS2
78 *
79 */
80class Net_DNS2_Lookups
81{
82    /*
83     * size (in bytes) of a header in a standard DNS packet
84     */
85    const DNS_HEADER_SIZE       = 12;
86
87    /*
88     * max size of a UDP packet
89     */
90    const DNS_MAX_UDP_SIZE      = 512;
91
92    /*
93     * Query/Response flag
94     */
95    const QR_QUERY              = 0;        // RFC 1035
96    const QR_RESPONSE           = 1;        // RFC 1035
97
98    /*
99     * DNS Op Codes
100     */
101    const OPCODE_QUERY          = 0;        // RFC 1035
102    const OPCODE_IQUERY         = 1;        // RFC 1035, RFC 3425
103    const OPCODE_STATUS         = 2;        // RFC 1035
104    const OPCODE_NOTIFY         = 4;        // RFC 1996
105    const OPCODE_UPDATE         = 5;        // RFC 2136
106
107    /*
108     * Resource Record Classes
109     */
110    const RR_CLASS_IN           = 1;        // RFC 1035
111    const RR_CLASS_CH           = 3;        // RFC 1035
112    const RR_CLASS_HS           = 4;        // RFC 1035
113    const RR_CLASS_NONE         = 254;      // RFC 2136
114    const RR_CLASS_ANY          = 255;      // RFC 1035
115
116    /*
117     * DNS Response Codes
118     */
119    const RCODE_NOERROR         = 0;        // RFC 1035
120    const RCODE_FORMERR         = 1;        // RFC 1035
121    const RCODE_SERVFAIL        = 2;        // RFC 1035
122    const RCODE_NXDOMAIN        = 3;        // RFC 1035
123    const RCODE_NOTIMP          = 4;        // RFC 1035
124    const RCODE_REFUSED         = 5;        // RFC 1035
125    const RCODE_YXDOMAIN        = 6;        // RFC 2136
126    const RCODE_YXRRSET         = 7;        // RFC 2136
127    const RCODE_NXRRSET         = 8;        // RFC 2136
128    const RCODE_NOTAUTH         = 9;        // RFC 2136
129    const RCODE_NOTZONE         = 10;       // RFC 2136
130
131    // 11-15 reserved
132
133    const RCODE_BADSIG          = 16;       // RFC 2845
134    const RCODE_BADVERS         = 16;       // RFC 6891
135    const RCODE_BADKEY          = 17;       // RFC 2845
136    const RCODE_BADTIME         = 18;       // RFC 2845
137    const RCODE_BADMODE         = 19;       // RFC 2930
138    const RCODE_BADNAME         = 20;       // RFC 2930
139    const RCODE_BADALG          = 21;       // RFC 2930
140    const RCODE_BADTRUNC        = 22;       // RFC 4635
141    const RCODE_BADCOOKIE       = 23;       // RFC 7873
142
143    /*
144     * internal errors codes returned by the exceptions class
145     */
146    const E_NONE                = 0;
147    const E_DNS_FORMERR         = self::RCODE_FORMERR;
148    const E_DNS_SERVFAIL        = self::RCODE_SERVFAIL;
149    const E_DNS_NXDOMAIN        = self::RCODE_NXDOMAIN;
150    const E_DNS_NOTIMP          = self::RCODE_NOTIMP;
151    const E_DNS_REFUSED         = self::RCODE_REFUSED;
152    const E_DNS_YXDOMAIN        = self::RCODE_YXDOMAIN;
153    const E_DNS_YXRRSET         = self::RCODE_YXRRSET;
154    const E_DNS_NXRRSET         = self::RCODE_NXRRSET;
155    const E_DNS_NOTAUTH         = self::RCODE_NOTAUTH;
156    const E_DNS_NOTZONE         = self::RCODE_NOTZONE;
157
158    // 11-15 reserved
159
160    const E_DNS_BADSIG          = self::RCODE_BADSIG;
161    const E_DNS_BADKEY          = self::RCODE_BADKEY;
162    const E_DNS_BADTIME         = self::RCODE_BADTIME;
163    const E_DNS_BADMODE         = self::RCODE_BADMODE;
164    const E_DNS_BADNAME         = self::RCODE_BADNAME;
165    const E_DNS_BADALG          = self::RCODE_BADALG;
166    const E_DNS_BADTRUNC        = self::RCODE_BADTRUNC;
167    const E_DNS_BADCOOKIE       = self::RCODE_BADCOOKIE;
168
169    // other error conditions
170
171    const E_NS_INVALID_FILE     = 200;
172    const E_NS_INVALID_ENTRY    = 201;
173    const E_NS_FAILED           = 202;
174    const E_NS_SOCKET_FAILED    = 203;
175    const E_NS_INVALID_SOCKET   = 204;
176
177    const E_PACKET_INVALID      = 300;
178    const E_PARSE_ERROR         = 301;
179    const E_HEADER_INVALID      = 302;
180    const E_QUESTION_INVALID    = 303;
181    const E_RR_INVALID          = 304;
182
183    const E_OPENSSL_ERROR       = 400;
184    const E_OPENSSL_UNAVAIL     = 401;
185    const E_OPENSSL_INV_PKEY    = 402;
186    const E_OPENSSL_INV_ALGO    = 403;
187
188    const E_CACHE_UNSUPPORTED   = 500;
189    const E_CACHE_SHM_FILE      = 501;
190    const E_CACHE_SHM_UNAVAIL   = 502;
191
192    /*
193     * EDNS0 Option Codes (OPT)
194     */
195    // 0 - Reserved
196    const EDNS0_OPT_LLQ             = 1;
197    const EDNS0_OPT_UL              = 2;
198    const EDNS0_OPT_NSID            = 3;
199    // 4 - Reserved
200    const EDNS0_OPT_DAU             = 5;
201    const EDNS0_OPT_DHU             = 6;
202    const EDNS0_OPT_N3U             = 7;
203    const EDNS0_OPT_CLIENT_SUBNET   = 8;
204    const EDNS0_OPT_EXPIRE          = 9;
205    const EDNS0_OPT_COOKIE          = 10;
206    const EDNS0_OPT_TCP_KEEPALIVE   = 11;
207    const EDNS0_OPT_PADDING         = 12;
208    const EDNS0_OPT_CHAIN           = 13;
209
210    /*
211     * DNSSEC Algorithms
212     */
213    const DNSSEC_ALGORITHM_RES                  = 0;
214    const DNSSEC_ALGORITHM_RSAMD5               = 1;
215    const DNSSEC_ALGORITHM_DH                   = 2;
216    const DNSSEC_ALGORITHM_DSA                  = 3;
217    const DNSSEC_ALGORITHM_ECC                  = 4;
218    const DNSSEC_ALGORITHM_RSASHA1              = 5;
219    const DNSSEC_ALGORITHM_DSANSEC3SHA1         = 6;
220    const DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1     = 7;
221    const DNSSEC_ALGORITHM_RSASHA256	        = 8;
222    const DNSSEC_ALGORITHM_RSASHA512            = 10;
223    const DNSSEC_ALGORITHM_ECCGOST              = 12;
224    const DNSSEC_ALGORITHM_INDIRECT             = 252;
225    const DNSSEC_ALGORITHM_PRIVATEDNS           = 253;
226    const DNSSEC_ALGORITHM_PRIVATEOID           = 254;
227
228    /*
229     * DNSSEC Digest Types
230     */
231    const DNSSEC_DIGEST_RES                     = 0;
232    const DNSSEC_DIGEST_SHA1                    = 1;
233
234    /*
235     * The packet id used when sending requests
236     */
237    public static $next_packet_id;
238
239    /*
240     * Used to map resource record types to their id's, and back
241     */
242    public static $rr_types_by_id = array();
243    public static $rr_types_by_name = array(
244
245        'SIG0'          => 0,       // RFC 2931 pseudo type
246        'A'             => 1,       // RFC 1035
247        'NS'            => 2,       // RFC 1035
248        'MD'            => 3,       // RFC 1035 - obsolete, Not implemented
249        'MF'            => 4,       // RFC 1035 - obsolete, Not implemented
250        'CNAME'         => 5,       // RFC 1035
251        'SOA'           => 6,       // RFC 1035
252        'MB'            => 7,       // RFC 1035 - obsolete, Not implemented
253        'MG'            => 8,       // RFC 1035 - obsolete, Not implemented
254        'MR'            => 9,       // RFC 1035 - obsolete, Not implemented
255        'NULL'          => 10,      // RFC 1035 - obsolete, Not implemented
256        'WKS'           => 11,      // RFC 1035
257        'PTR'           => 12,      // RFC 1035
258        'HINFO'         => 13,      // RFC 1035
259        'MINFO'         => 14,      // RFC 1035 - obsolete, Not implemented
260        'MX'            => 15,      // RFC 1035
261        'TXT'           => 16,      // RFC 1035
262        'RP'            => 17,      // RFC 1183
263        'AFSDB'         => 18,      // RFC 1183
264        'X25'           => 19,      // RFC 1183
265        'ISDN'          => 20,      // RFC 1183
266        'RT'            => 21,      // RFC 1183
267        'NSAP'          => 22,      // RFC 1706
268        'NSAP_PTR'      => 23,      // RFC 1348 - obsolete, Not implemented
269        'SIG'           => 24,      // RFC 2535
270        'KEY'           => 25,      // RFC 2535, RFC 2930
271        'PX'            => 26,      // RFC 2163
272        'GPOS'          => 27,      // RFC 1712 - Not implemented
273        'AAAA'          => 28,      // RFC 3596
274        'LOC'           => 29,      // RFC 1876
275        'NXT'           => 30,      // RFC 2065, obsoleted by by RFC 3755
276        'EID'           => 31,      // [Patton][Patton1995]
277        'NIMLOC'        => 32,      // [Patton][Patton1995]
278        'SRV'           => 33,      // RFC 2782
279        'ATMA'          => 34,      // Windows only
280        'NAPTR'         => 35,      // RFC 2915
281        'KX'            => 36,      // RFC 2230
282        'CERT'          => 37,      // RFC 4398
283        'A6'            => 38,      // downgraded to experimental by RFC 3363
284        'DNAME'         => 39,      // RFC 2672
285        'SINK'          => 40,      // Not implemented
286        'OPT'           => 41,      // RFC 2671
287        'APL'           => 42,      // RFC 3123
288        'DS'            => 43,      // RFC 4034
289        'SSHFP'         => 44,      // RFC 4255
290        'IPSECKEY'      => 45,      // RFC 4025
291        'RRSIG'         => 46,      // RFC 4034
292        'NSEC'          => 47,      // RFC 4034
293        'DNSKEY'        => 48,      // RFC 4034
294        'DHCID'         => 49,      // RFC 4701
295        'NSEC3'         => 50,      // RFC 5155
296        'NSEC3PARAM'    => 51,      // RFC 5155
297        'TLSA'          => 52,      // RFC 6698
298        'SMIMEA'        => 53,      // draft-ietf-dane-smime-10
299
300                                    // 54 unassigned
301
302        'HIP'           => 55,      // RFC 5205
303        'NINFO'         => 56,      // Not implemented
304        'RKEY'          => 57,      // Not implemented
305        'TALINK'        => 58,      //
306        'CDS'           => 59,      // RFC 7344
307        'CDNSKEY'       => 60,      // RFC 7344
308        'OPENPGPKEY'    => 61,      // RFC 7929
309        'CSYNC'         => 62,      // RFC 7477
310
311                                    // 63 - 98 unassigned
312
313        'SPF'           => 99,      // RFC 4408
314        'UINFO'         => 100,     // no RFC, Not implemented
315        'UID'           => 101,     // no RFC, Not implemented
316        'GID'           => 102,     // no RFC, Not implemented
317        'UNSPEC'        => 103,     // no RFC, Not implemented
318        'NID'           => 104,     // RFC 6742
319        'L32'           => 105,     // RFC 6742
320        'L64'           => 106,     // RFC 6742
321        'LP'            => 107,     // RFC 6742
322        'EUI48'         => 108,     // RFC 7043
323        'EUI64'         => 109,     // RFC 7043
324
325                                    // 110 - 248 unassigned
326
327        'TKEY'          => 249,     // RFC 2930
328        'TSIG'          => 250,     // RFC 2845
329        'IXFR'          => 251,     // RFC 1995 - only a full (AXFR) is supported
330        'AXFR'          => 252,     // RFC 1035
331        'MAILB'         => 253,     // RFC 883, Not implemented
332        'MAILA'         => 254,     // RFC 973, Not implemented
333        'ANY'           => 255,     // RFC 1035 - we support both 'ANY' and '*'
334        'URI'           => 256,     // tools.ietf.org/html/draft-faltstrom-uri-06
335        'CAA'           => 257,     // tools.ietf.org/html/draft-ietf-pkix-caa-03
336        'AVC'           => 258,     // Application Visibility and Control
337
338                                    // 259 - 32767 unassigned
339
340        'TA'            => 32768,   // same as DS
341        'DLV'           => 32769    // RFC 4431
342    );
343
344    /*
345     * Qtypes and Metatypes - defined in RFC2929 section 3.1
346     */
347    public static $rr_qtypes_by_id = array();
348    public static $rr_qtypes_by_name = array(
349
350        'IXFR'          => 251,     // RFC 1995 - only a full (AXFR) is supported
351        'AXFR'          => 252,     // RFC 1035
352        'MAILB'         => 253,     // RFC 883, Not implemented
353        'MAILA'         => 254,     // RFC 973, Not implemented
354        'ANY'           => 255      // RFC 1035 - we support both 'ANY' and '*'
355    );
356
357    public static $rr_metatypes_by_id = array();
358    public static $rr_metatypes_by_name = array(
359
360        'OPT'           => 41,      // RFC 2671
361        'TKEY'          => 249,     // RFC 2930
362        'TSIG'          => 250      // RFC 2845
363    );
364
365    /*
366     * used to map resource record id's to RR class names
367     */
368    public static $rr_types_class_to_id = array();
369    public static $rr_types_id_to_class = array(
370
371        1           => 'Net_DNS2_RR_A',
372        2           => 'Net_DNS2_RR_NS',
373        5           => 'Net_DNS2_RR_CNAME',
374        6           => 'Net_DNS2_RR_SOA',
375        11          => 'Net_DNS2_RR_WKS',
376        12          => 'Net_DNS2_RR_PTR',
377        13          => 'Net_DNS2_RR_HINFO',
378        15          => 'Net_DNS2_RR_MX',
379        16          => 'Net_DNS2_RR_TXT',
380        17          => 'Net_DNS2_RR_RP',
381        18          => 'Net_DNS2_RR_AFSDB',
382        19          => 'Net_DNS2_RR_X25',
383        20          => 'Net_DNS2_RR_ISDN',
384        21          => 'Net_DNS2_RR_RT',
385        22          => 'Net_DNS2_RR_NSAP',
386        24          => 'Net_DNS2_RR_SIG',
387        25          => 'Net_DNS2_RR_KEY',
388        26          => 'Net_DNS2_RR_PX',
389        28          => 'Net_DNS2_RR_AAAA',
390        29          => 'Net_DNS2_RR_LOC',
391        31          => 'Net_DNS2_RR_EID',
392        32          => 'Net_DNS2_RR_NIMLOC',
393        33          => 'Net_DNS2_RR_SRV',
394        34          => 'Net_DNS2_RR_ATMA',
395        35          => 'Net_DNS2_RR_NAPTR',
396        36          => 'Net_DNS2_RR_KX',
397        37          => 'Net_DNS2_RR_CERT',
398        39          => 'Net_DNS2_RR_DNAME',
399        41          => 'Net_DNS2_RR_OPT',
400        42          => 'Net_DNS2_RR_APL',
401        43          => 'Net_DNS2_RR_DS',
402        44          => 'Net_DNS2_RR_SSHFP',
403        45          => 'Net_DNS2_RR_IPSECKEY',
404        46          => 'Net_DNS2_RR_RRSIG',
405        47          => 'Net_DNS2_RR_NSEC',
406        48          => 'Net_DNS2_RR_DNSKEY',
407        49          => 'Net_DNS2_RR_DHCID',
408        50          => 'Net_DNS2_RR_NSEC3',
409        51          => 'Net_DNS2_RR_NSEC3PARAM',
410        52          => 'Net_DNS2_RR_TLSA',
411        53          => 'Net_DNS2_RR_SMIMEA',
412        55          => 'Net_DNS2_RR_HIP',
413        58          => 'Net_DNS2_RR_TALINK',
414        59          => 'Net_DNS2_RR_CDS',
415        60          => 'Net_DNS2_RR_CDNSKEY',
416        61          => 'Net_DNS2_RR_OPENPGPKEY',
417        62          => 'Net_DNS2_RR_CSYNC',
418        99          => 'Net_DNS2_RR_SPF',
419        104         => 'Net_DNS2_RR_NID',
420        105         => 'Net_DNS2_RR_L32',
421        106         => 'Net_DNS2_RR_L64',
422        107         => 'Net_DNS2_RR_LP',
423        108         => 'Net_DNS2_RR_EUI48',
424        109         => 'Net_DNS2_RR_EUI64',
425
426        249         => 'Net_DNS2_RR_TKEY',
427        250         => 'Net_DNS2_RR_TSIG',
428
429    //    251            - IXFR - handled as a full zone transfer (252)
430    //    252            - AXFR - handled as a function call
431
432        255         => 'Net_DNS2_RR_ANY',
433        256         => 'Net_DNS2_RR_URI',
434        257         => 'Net_DNS2_RR_CAA',
435        258         => 'Net_DNS2_RR_AVC',
436        32768       => 'Net_DNS2_RR_TA',
437        32769       => 'Net_DNS2_RR_DLV'
438    );
439
440    /*
441     * used to map resource record class names to their id's, and back
442     */
443    public static $classes_by_id = array();
444    public static $classes_by_name = array(
445
446        'IN'    => self::RR_CLASS_IN,        // RFC 1035
447        'CH'    => self::RR_CLASS_CH,        // RFC 1035
448        'HS'    => self::RR_CLASS_HS,        // RFC 1035
449        'NONE'  => self::RR_CLASS_NONE,      // RFC 2136
450        'ANY'   => self::RR_CLASS_ANY        // RFC 1035
451    );
452
453    /*
454     * maps response codes to error messages
455     */
456    public static $result_code_messages = array(
457
458        self::RCODE_NOERROR     => 'The request completed successfully.',
459        self::RCODE_FORMERR     => 'The name server was unable to interpret the query.',
460        self::RCODE_SERVFAIL    => 'The name server was unable to process this query due to a problem with the name server.',
461        self::RCODE_NXDOMAIN    => 'The domain name referenced in the query does not exist.',
462        self::RCODE_NOTIMP      => 'The name server does not support the requested kind of query.',
463        self::RCODE_REFUSED     => 'The name server refuses to perform the specified operation for policy reasons.',
464        self::RCODE_YXDOMAIN    => 'Name Exists when it should not.',
465        self::RCODE_YXRRSET     => 'RR Set Exists when it should not.',
466        self::RCODE_NXRRSET     => 'RR Set that should exist does not.',
467        self::RCODE_NOTAUTH     => 'Server Not Authoritative for zone.',
468        self::RCODE_NOTZONE     => 'Name not contained in zone.',
469
470        self::RCODE_BADSIG      => 'TSIG Signature Failure.',
471        self::RCODE_BADKEY      => 'Key not recognized.',
472        self::RCODE_BADTIME     => 'Signature out of time window.',
473        self::RCODE_BADMODE     => 'Bad TKEY Mode.',
474        self::RCODE_BADNAME     => 'Duplicate key name.',
475        self::RCODE_BADALG      => 'Algorithm not supported.',
476        self::RCODE_BADTRUNC    => 'Bad truncation.'
477    );
478
479    /*
480     * maps DNS SEC alrorithms to their mnemonics
481     */
482    public static $algorithm_name_to_id = array();
483    public static $algorithm_id_to_name = array(
484
485        self::DNSSEC_ALGORITHM_RES                  => 'RES',
486        self::DNSSEC_ALGORITHM_RSAMD5               => 'RSAMD5',
487        self::DNSSEC_ALGORITHM_DH                   => 'DH',
488        self::DNSSEC_ALGORITHM_DSA                  => 'DSA',
489        self::DNSSEC_ALGORITHM_ECC                  => 'ECC',
490        self::DNSSEC_ALGORITHM_RSASHA1              => 'RSASHA1',
491        self::DNSSEC_ALGORITHM_DSANSEC3SHA1         => 'DSA-NSEC3-SHA1',
492        self::DSNSEC_ALGORITHM_RSASHA1NSEC3SHA1     => 'RSASHA1-NSEC3-SHA1',
493        self::DNSSEC_ALGORITHM_RSASHA256            => 'RSASHA256',
494        self::DNSSEC_ALGORITHM_RSASHA512            => 'RSASHA512',
495        self::DNSSEC_ALGORITHM_ECCGOST              => 'ECC-GOST',
496        self::DNSSEC_ALGORITHM_INDIRECT             => 'INDIRECT',
497        self::DNSSEC_ALGORITHM_PRIVATEDNS           => 'PRIVATEDNS',
498        self::DNSSEC_ALGORITHM_PRIVATEOID           => 'PRIVATEOID'
499    );
500
501    /*
502     * maps DNSSEC digest types to their mnemonics
503     */
504    public static $digest_name_to_id = array();
505    public static $digest_id_to_name = array(
506
507        self::DNSSEC_DIGEST_RES         => 'RES',
508        self::DNSSEC_DIGEST_SHA1        => 'SHA-1'
509    );
510
511    /*
512     * Protocols names - RFC 1010
513     */
514    public static $protocol_by_id = array();
515    public static $protocol_by_name = array(
516
517        'ICMP'          => 1,
518        'IGMP'          => 2,
519        'GGP'           => 3,
520        'ST'            => 5,
521        'TCP'           => 6,
522        'UCL'           => 7,
523        'EGP'           => 8,
524        'IGP'           => 9,
525        'BBN-RCC-MON'   => 10,
526        'NVP-II'        => 11,
527        'PUP'           => 12,
528        'ARGUS'         => 13,
529        'EMCON'         => 14,
530        'XNET'          => 15,
531        'CHAOS'         => 16,
532        'UDP'           => 17,
533        'MUX'           => 18,
534        'DCN-MEAS'      => 19,
535        'HMP'           => 20,
536        'PRM'           => 21,
537        'XNS-IDP'       => 22,
538        'TRUNK-1'       => 23,
539        'TRUNK-2'       => 24,
540        'LEAF-1'        => 25,
541        'LEAF-2'        => 26,
542        'RDP'           => 27,
543        'IRTP'          => 28,
544        'ISO-TP4'       => 29,
545        'NETBLT'        => 30,
546        'MFE-NSP'       => 31,
547        'MERIT-INP'     => 32,
548        'SEP'           => 33,
549        // 34 - 60      - Unassigned
550        // 61           - any host internal protocol
551        'CFTP'          => 62,
552        // 63           - any local network
553        'SAT-EXPAK'     => 64,
554        'MIT-SUBNET'    => 65,
555        'RVD'           => 66,
556        'IPPC'          => 67,
557        // 68           - any distributed file system
558        'SAT-MON'       => 69,
559        // 70           - Unassigned
560        'IPCV'          => 71,
561        // 72 - 75      - Unassigned
562        'BR-SAT-MON'    => 76,
563        // 77           - Unassigned
564        'WB-MON'        => 78,
565        'WB-EXPAK'      => 79
566        // 80 - 254     - Unassigned
567        // 255          - Reserved
568    );
569}
570
571/*
572 * Local variables:
573 * tab-width: 4
574 * c-basic-offset: 4
575 * c-hanging-comment-ender-p: nil
576 * End:
577 */
578?>
579