~ubuntu-branches/ubuntu/utopic/php-net-dns2/utopic-proposed

« back to all changes in this revision

Viewing changes to Net_DNS2-1.3.2/Net/DNS2/Updater.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2014-02-21 16:59:58 UTC
  • Revision ID: package-import@ubuntu.com-20140221165958-tyc92gchfhho9660
Tags: upstream-1.3.2
ImportĀ upstreamĀ versionĀ 1.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: Updater.php 198 2013-05-26 05:05:22Z mike.pultz $
 
47
 * @link      http://pear.php.net/package/Net_DNS2
 
48
 * @since     File available since Release 0.6.0
 
49
 *
 
50
 */
 
51
 
 
52
/**
 
53
 * The main dynamic DNS updater class.
 
54
 *
 
55
 * This class provices functions to handle all defined dynamic DNS update 
 
56
 * requests as defined by RFC 2136.
 
57
 *
 
58
 * This is separate from the Net_DNS2_Resolver class, as while the underlying
 
59
 * protocol is the same, the functionality is completely different.
 
60
 *
 
61
 * Generally, query (recursive) lookups are done against caching server, while
 
62
 * update requests are done against authoratative servers.
 
63
 * 
 
64
 * @category Networking
 
65
 * @package  Net_DNS2
 
66
 * @author   Mike Pultz <mike@mikepultz.com>
 
67
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
 
68
 * @link     http://pear.php.net/package/Net_DNS2
 
69
 * @see      Net_DNS2
 
70
 *
 
71
 */
 
72
class Net_DNS2_Updater extends Net_DNS2
 
73
{
 
74
    /*
 
75
     * a Net_DNS2_Packet_Request object used for the update request
 
76
     */
 
77
    private $_packet;
 
78
 
 
79
    /**
 
80
     * Constructor - builds a new Net_DNS2_Updater objected used for doing 
 
81
     * dynamic DNS updates
 
82
     *
 
83
     * @param string $zone    the domain name to use for DNS updates
 
84
     * @param mixed  $options an array of config options or null
 
85
     *
 
86
     * @throws Net_DNS2_Exception
 
87
     * @access public
 
88
     *
 
89
     */
 
90
    public function __construct($zone, array $options = null)
 
91
    {
 
92
        parent::__construct($options);
 
93
 
 
94
        //
 
95
        // create the packet
 
96
        //
 
97
        $this->_packet = new Net_DNS2_Packet_Request(
 
98
            strtolower(trim($zone, " \n\r\t.")), 'SOA', 'IN'
 
99
        );
 
100
 
 
101
        //
 
102
        // make sure the opcode on the packet is set to UPDATE
 
103
        //
 
104
        $this->_packet->header->opcode = Net_DNS2_Lookups::OPCODE_UPDATE;
 
105
    }
 
106
 
 
107
    /**
 
108
     * checks that the given name matches the name for the zone we're updating
 
109
     *
 
110
     * @param string $name The name to be checked.
 
111
     *
 
112
     * @return boolean
 
113
     * @throws Net_DNS2_Exception
 
114
     * @access private
 
115
     *
 
116
     */
 
117
    private function _checkName($name)
 
118
    {
 
119
        if (!preg_match('/' . $this->_packet->question[0]->qname . '$/', $name)) {
 
120
            
 
121
            throw new Net_DNS2_Exception(
 
122
                'name provided (' . $name . ') does not match zone name (' .
 
123
                $this->_packet->question[0]->qname . ')',
 
124
                Net_DNS2_Lookups::E_PACKET_INVALID
 
125
            );
 
126
        }
 
127
    
 
128
        return true;
 
129
    }
 
130
 
 
131
    /**
 
132
     * add a signature to the request for authentication 
 
133
     *
 
134
     * @param string $keyname   the key name to use for the TSIG RR
 
135
     * @param string $signature the key to sign the request.
 
136
     *
 
137
     * @return     boolean
 
138
     * @access     public
 
139
     * @see        Net_DNS2::signTSIG()
 
140
     * @deprecated function deprecated in 1.1.0
 
141
     *
 
142
     */
 
143
    public function signature($keyname, $signature)
 
144
    {
 
145
        return $this->signTSIG($keyname, $signature);
 
146
    }
 
147
 
 
148
    /**
 
149
     *   2.5.1 - Add To An RRset
 
150
     *
 
151
     *   RRs are added to the Update Section whose NAME, TYPE, TTL, RDLENGTH
 
152
     *   and RDATA are those being added, and CLASS is the same as the zone
 
153
     *   class.  Any duplicate RRs will be silently ignored by the primary
 
154
     *   master.
 
155
     *
 
156
     * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be added to the zone
 
157
     *
 
158
     * @return boolean
 
159
     * @throws Net_DNS2_Exception
 
160
     * @access public
 
161
     *
 
162
     */
 
163
    public function add(Net_DNS2_RR $rr)
 
164
    {
 
165
        $this->_checkName($rr->name);
 
166
 
 
167
        //
 
168
        // add the RR to the "update" section
 
169
        //
 
170
        if (!in_array($rr, $this->_packet->authority)) {
 
171
            $this->_packet->authority[] = $rr;
 
172
        }
 
173
 
 
174
        return true;
 
175
    }
 
176
 
 
177
    /**
 
178
     *   2.5.4 - Delete An RR From An RRset
 
179
     *
 
180
     *   RRs to be deleted are added to the Update Section.  The NAME, TYPE,
 
181
     *   RDLENGTH and RDATA must match the RR being deleted.  TTL must be
 
182
     *   specified as zero (0) and will otherwise be ignored by the primary
 
183
     *   master.  CLASS must be specified as NONE to distinguish this from an
 
184
     *   RR addition.  If no such RRs exist, then this Update RR will be
 
185
     *   silently ignored by the primary master.
 
186
     *
 
187
     * @param Net_DNS2_RR $rr the Net_DNS2_RR object to be deleted from the zone
 
188
     *
 
189
     * @return boolean
 
190
     * @throws Net_DNS2_Exception
 
191
     * @access public
 
192
     *
 
193
     */
 
194
    public function delete(Net_DNS2_RR $rr)
 
195
    {
 
196
        $this->_checkName($rr->name);
 
197
 
 
198
        $rr->ttl    = 0;
 
199
        $rr->class  = 'NONE';
 
200
 
 
201
        //
 
202
        // add the RR to the "update" section
 
203
        //
 
204
        if (!in_array($rr, $this->_packet->authority)) {
 
205
            $this->_packet->authority[] = $rr;
 
206
        }
 
207
 
 
208
        return true;
 
209
    }
 
210
 
 
211
    /**
 
212
     *   2.5.2 - Delete An RRset
 
213
     *
 
214
     *   One RR is added to the Update Section whose NAME and TYPE are those
 
215
     *   of the RRset to be deleted.  TTL must be specified as zero (0) and is
 
216
     *   otherwise not used by the primary master.  CLASS must be specified as
 
217
     *   ANY.  RDLENGTH must be zero (0) and RDATA must therefore be empty.
 
218
     *   If no such RRset exists, then this Update RR will be silently ignored
 
219
     *   by the primary master
 
220
     *
 
221
     * @param string $name the RR name to be removed from the zone
 
222
     * @param string $type the RR type to be removed from the zone
 
223
     *
 
224
     * @return boolean
 
225
     * @throws Net_DNS2_Exception
 
226
     * @access public
 
227
     *
 
228
     */
 
229
    public function deleteAny($name, $type)
 
230
    {
 
231
        $this->_checkName($name);
 
232
 
 
233
        $class = Net_DNS2_Lookups::$rr_types_id_to_class[
 
234
            Net_DNS2_Lookups::$rr_types_by_name[$type]
 
235
        ];
 
236
        if (!isset($class)) {
 
237
 
 
238
            throw new Net_DNS2_Exception(
 
239
                'unknown or un-supported resource record type: ' . $type,
 
240
                Net_DNS2_Lookups::E_RR_INVALID
 
241
            );
 
242
        }
 
243
    
 
244
        $rr = new $class;
 
245
 
 
246
        $rr->name       = $name;
 
247
        $rr->ttl        = 0;
 
248
        $rr->class      = 'ANY';
 
249
        $rr->rdlength   = -1;
 
250
        $rr->rdata      = '';    
 
251
 
 
252
        //
 
253
        // add the RR to the "update" section
 
254
        //
 
255
        if (!in_array($rr, $this->_packet->authority)) {
 
256
            $this->_packet->authority[] = $rr;
 
257
        }
 
258
 
 
259
        return true;
 
260
    }
 
261
 
 
262
    /**
 
263
     *   2.5.3 - Delete All RRsets From A Name
 
264
     *
 
265
     *   One RR is added to the Update Section whose NAME is that of the name
 
266
     *   to be cleansed of RRsets.  TYPE must be specified as ANY.  TTL must
 
267
     *   be specified as zero (0) and is otherwise not used by the primary
 
268
     *   master.  CLASS must be specified as ANY.  RDLENGTH must be zero (0)
 
269
     *   and RDATA must therefore be empty.  If no such RRsets exist, then
 
270
     *   this Update RR will be silently ignored by the primary master.
 
271
     *
 
272
     * @param string $name the RR name to be removed from the zone
 
273
     *
 
274
     * @return boolean
 
275
     * @throws Net_DNS2_Exception
 
276
     * @access public
 
277
     *
 
278
     */
 
279
    public function deleteAll($name)
 
280
    {
 
281
        $this->_checkName($name);
 
282
 
 
283
        //
 
284
        // the Net_DNS2_RR_ANY class is just an empty stub class used for these
 
285
        // cases only
 
286
        //
 
287
        $rr = new Net_DNS2_RR_ANY;
 
288
 
 
289
        $rr->name       = $name;
 
290
        $rr->ttl        = 0;
 
291
        $rr->type       = 'ANY';
 
292
        $rr->class      = 'ANY';
 
293
        $rr->rdlength   = -1;
 
294
        $rr->rdata      = '';
 
295
 
 
296
        //
 
297
        // add the RR to the "update" section
 
298
        //
 
299
        if (!in_array($rr, $this->_packet->authority)) {
 
300
            $this->_packet->authority[] = $rr;
 
301
        }
 
302
 
 
303
        return true;
 
304
    }
 
305
 
 
306
    /**
 
307
     *   2.4.1 - RRset Exists (Value Independent)
 
308
     *
 
309
     *   At least one RR with a specified NAME and TYPE (in the zone and class
 
310
     *   specified in the Zone Section) must exist.
 
311
     *
 
312
     *   For this prerequisite, a requestor adds to the section a single RR
 
313
     *   whose NAME and TYPE are equal to that of the zone RRset whose
 
314
     *   existence is required.  RDLENGTH is zero and RDATA is therefore
 
315
     *   empty.  CLASS must be specified as ANY to differentiate this
 
316
     *   condition from that of an actual RR whose RDLENGTH is naturally zero
 
317
     *   (0) (e.g., NULL).  TTL is specified as zero (0).
 
318
     *
 
319
     * @param string $name the RR name for the prerequisite
 
320
     * @param string $type the RR type for the prerequisite
 
321
     *
 
322
     * @return boolean
 
323
     * @throws Net_DNS2_Exception
 
324
     * @access public
 
325
     *
 
326
     */
 
327
    public function checkExists($name, $type)
 
328
    {
 
329
        $this->_checkName($name);
 
330
        
 
331
        $class = Net_DNS2_Lookups::$rr_types_id_to_class[
 
332
            Net_DNS2_Lookups::$rr_types_by_name[$type]
 
333
        ];
 
334
        if (!isset($class)) {
 
335
 
 
336
            throw new Net_DNS2_Exception(
 
337
                'unknown or un-supported resource record type: ' . $type,
 
338
                Net_DNS2_Lookups::E_RR_INVALID
 
339
            );
 
340
        }
 
341
    
 
342
        $rr = new $class;
 
343
 
 
344
        $rr->name       = $name;
 
345
        $rr->ttl        = 0;
 
346
        $rr->class      = 'ANY';
 
347
        $rr->rdlength   = -1;
 
348
        $rr->rdata      = '';    
 
349
 
 
350
        //
 
351
        // add the RR to the "prerequisite" section
 
352
        //
 
353
        if (!in_array($rr, $this->_packet->answer)) {
 
354
            $this->_packet->answer[] = $rr;
 
355
        }
 
356
 
 
357
        return true;
 
358
    }
 
359
 
 
360
    /**
 
361
     *   2.4.2 - RRset Exists (Value Dependent)
 
362
     *
 
363
     *   A set of RRs with a specified NAME and TYPE exists and has the same
 
364
     *   members with the same RDATAs as the RRset specified here in this
 
365
     *   section.  While RRset ordering is undefined and therefore not
 
366
     *   significant to this comparison, the sets be identical in their
 
367
     *   extent.
 
368
     *
 
369
     *   For this prerequisite, a requestor adds to the section an entire
 
370
     *   RRset whose preexistence is required.  NAME and TYPE are that of the
 
371
     *   RRset being denoted.  CLASS is that of the zone.  TTL must be
 
372
     *   specified as zero (0) and is ignored when comparing RRsets for
 
373
     *   identity.
 
374
     *
 
375
     * @param Net_DNS2_RR $rr the RR object to be used as a prerequisite
 
376
     *
 
377
     * @return boolean
 
378
     * @throws Net_DNS2_Exception
 
379
     * @access public
 
380
     *
 
381
     */
 
382
    public function checkValueExists(Net_DNS2_RR $rr)
 
383
    {
 
384
        $this->_checkName($rr->name);
 
385
 
 
386
        $rr->ttl = 0;
 
387
 
 
388
        //
 
389
        // add the RR to the "prerequisite" section
 
390
        //
 
391
        if (!in_array($rr, $this->_packet->answer)) {
 
392
            $this->_packet->answer[] = $rr;
 
393
        }
 
394
 
 
395
        return true;
 
396
    }
 
397
 
 
398
    /**
 
399
     *   2.4.3 - RRset Does Not Exist
 
400
     *
 
401
     *   No RRs with a specified NAME and TYPE (in the zone and class denoted
 
402
     *   by the Zone Section) can exist.
 
403
     *
 
404
     *   For this prerequisite, a requestor adds to the section a single RR
 
405
     *   whose NAME and TYPE are equal to that of the RRset whose nonexistence
 
406
     *   is required.  The RDLENGTH of this record is zero (0), and RDATA
 
407
     *   field is therefore empty.  CLASS must be specified as NONE in order
 
408
     *   to distinguish this condition from a valid RR whose RDLENGTH is
 
409
     *   naturally zero (0) (for example, the NULL RR).  TTL must be specified
 
410
     *   as zero (0).
 
411
     *
 
412
     * @param string $name the RR name for the prerequisite
 
413
     * @param string $type the RR type for the prerequisite
 
414
     *
 
415
     * @return boolean
 
416
     * @throws Net_DNS2_Exception
 
417
     * @access public
 
418
     *
 
419
     */
 
420
    public function checkNotExists($name, $type)
 
421
    {
 
422
        $this->_checkName($name);
 
423
 
 
424
        $class = Net_DNS2_Lookups::$rr_types_id_to_class[
 
425
            Net_DNS2_Lookups::$rr_types_by_name[$type]
 
426
        ];
 
427
        if (!isset($class)) {
 
428
 
 
429
            throw new Net_DNS2_Exception(
 
430
                'unknown or un-supported resource record type: ' . $type,
 
431
                Net_DNS2_Lookups::E_RR_INVALID
 
432
            );
 
433
        }
 
434
    
 
435
        $rr = new $class;
 
436
 
 
437
        $rr->name       = $name;
 
438
        $rr->ttl        = 0;
 
439
        $rr->class      = 'NONE';
 
440
        $rr->rdlength   = -1;
 
441
        $rr->rdata      = '';    
 
442
 
 
443
        //
 
444
        // add the RR to the "prerequisite" section
 
445
        //
 
446
        if (!in_array($rr, $this->_packet->answer)) {
 
447
            $this->_packet->answer[] = $rr;
 
448
        }
 
449
 
 
450
        return true;
 
451
    }
 
452
 
 
453
    /**
 
454
     *   2.4.4 - Name Is In Use
 
455
     *
 
456
     *   Name is in use.  At least one RR with a specified NAME (in the zone
 
457
     *   and class specified by the Zone Section) must exist.  Note that this
 
458
     *   prerequisite is NOT satisfied by empty nonterminals.
 
459
     *
 
460
     *   For this prerequisite, a requestor adds to the section a single RR
 
461
     *   whose NAME is equal to that of the name whose ownership of an RR is
 
462
     *   required.  RDLENGTH is zero and RDATA is therefore empty.  CLASS must
 
463
     *   be specified as ANY to differentiate this condition from that of an
 
464
     *   actual RR whose RDLENGTH is naturally zero (0) (e.g., NULL).  TYPE
 
465
     *   must be specified as ANY to differentiate this case from that of an
 
466
     *   RRset existence test.  TTL is specified as zero (0).
 
467
     *
 
468
     * @param string $name the RR name for the prerequisite
 
469
     *
 
470
     * @return boolean
 
471
     * @throws Net_DNS2_Exception
 
472
     * @access public
 
473
     *
 
474
     */
 
475
    public function checkNameInUse($name)
 
476
    {
 
477
        $this->_checkName($name);
 
478
 
 
479
        //
 
480
        // the Net_DNS2_RR_ANY class is just an empty stub class used for these
 
481
        // cases only
 
482
        //
 
483
        $rr = new Net_DNS2_RR_ANY;
 
484
 
 
485
        $rr->name       = $name;
 
486
        $rr->ttl        = 0;
 
487
        $rr->type       = 'ANY';
 
488
        $rr->class      = 'ANY';
 
489
        $rr->rdlength   = -1;
 
490
        $rr->rdata      = '';
 
491
 
 
492
        //
 
493
        // add the RR to the "prerequisite" section
 
494
        //
 
495
        if (!in_array($rr, $this->_packet->answer)) {
 
496
            $this->_packet->answer[] = $rr;
 
497
        }
 
498
 
 
499
        return true;
 
500
    }
 
501
 
 
502
    /**
 
503
     *   2.4.5 - Name Is Not In Use
 
504
     *
 
505
     *   Name is not in use.  No RR of any type is owned by a specified NAME.
 
506
     *   Note that this prerequisite IS satisfied by empty nonterminals.
 
507
     *
 
508
     *   For this prerequisite, a requestor adds to the section a single RR
 
509
     *   whose NAME is equal to that of the name whose nonownership of any RRs
 
510
     *   is required.  RDLENGTH is zero and RDATA is therefore empty.  CLASS
 
511
     *   must be specified as NONE.  TYPE must be specified as ANY.  TTL must
 
512
     *   be specified as zero (0).
 
513
     *
 
514
     * @param string $name the RR name for the prerequisite
 
515
     *
 
516
     * @return boolean
 
517
     * @throws Net_DNS2_Exception
 
518
     * @access public
 
519
     *
 
520
     */
 
521
    public function checkNameNotInUse($name)
 
522
    {
 
523
        $this->_checkName($name);
 
524
 
 
525
        //
 
526
        // the Net_DNS2_RR_ANY class is just an empty stub class used for these
 
527
        // cases only
 
528
        //
 
529
        $rr = new Net_DNS2_RR_ANY;
 
530
 
 
531
        $rr->name       = $name;
 
532
        $rr->ttl        = 0;
 
533
        $rr->type       = 'ANY';
 
534
        $rr->class      = 'NONE';
 
535
        $rr->rdlength   = -1;
 
536
        $rr->rdata      = '';
 
537
 
 
538
        //
 
539
        // add the RR to the "prerequisite" section
 
540
        //
 
541
        if (!in_array($rr, $this->_packet->answer)) {
 
542
            $this->_packet->answer[] = $rr;
 
543
        }
 
544
 
 
545
        return true;
 
546
    }
 
547
 
 
548
    /**
 
549
     * returns the current internal packet object.
 
550
     *
 
551
     * @return Net_DNS2_Packet_Request
 
552
     * @access public
 
553
     #
 
554
     */
 
555
    public function packet()
 
556
    {
 
557
        //
 
558
        // take a copy
 
559
        //
 
560
        $p = $this->_packet;
 
561
 
 
562
        //
 
563
        // check for an authentication method; either TSIG or SIG
 
564
        //
 
565
        if (   ($this->auth_signature instanceof Net_DNS2_RR_TSIG) 
 
566
            || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
 
567
        ) {
 
568
            $p->additional[] = $this->auth_signature;
 
569
        }
 
570
 
 
571
        //
 
572
        // update the counts
 
573
        //
 
574
        $p->header->qdcount = count($p->question);
 
575
        $p->header->ancount = count($p->answer);
 
576
        $p->header->nscount = count($p->authority);
 
577
        $p->header->arcount = count($p->additional);
 
578
 
 
579
        return $p;
 
580
    }
 
581
 
 
582
    /**
 
583
     * executes the update request with the object informaton
 
584
     *
 
585
     * @param Net_DNS2_Packet_Response &$response ref to the response object
 
586
     *
 
587
     * @return boolean
 
588
     * @throws Net_DNS2_Exception
 
589
     * @access public
 
590
     *
 
591
     */
 
592
    public function update(&$response = null)
 
593
    {
 
594
        //
 
595
        // make sure we have some name servers set
 
596
        //
 
597
        $this->checkServers(Net_DNS2::RESOLV_CONF);
 
598
 
 
599
        //
 
600
        // check for an authentication method; either TSIG or SIG
 
601
        //
 
602
        if (   ($this->auth_signature instanceof Net_DNS2_RR_TSIG) 
 
603
            || ($this->auth_signature instanceof Net_DNS2_RR_SIG)
 
604
        ) {
 
605
            $this->_packet->additional[] = $this->auth_signature;
 
606
        }
 
607
 
 
608
        //
 
609
        // update the counts
 
610
        //
 
611
        $this->_packet->header->qdcount = count($this->_packet->question);
 
612
        $this->_packet->header->ancount = count($this->_packet->answer);
 
613
        $this->_packet->header->nscount = count($this->_packet->authority);
 
614
        $this->_packet->header->arcount = count($this->_packet->additional);
 
615
 
 
616
        //
 
617
        // make sure we have some data to send
 
618
        //
 
619
        if (   ($this->_packet->header->qdcount == 0) 
 
620
            || ($this->_packet->header->nscount == 0) 
 
621
        ) {
 
622
            throw new Net_DNS2_Exception(
 
623
                'empty headers- nothing to send!',
 
624
                Net_DNS2_Lookups::E_PACKET_INVALID
 
625
            );
 
626
        }
 
627
 
 
628
        //
 
629
        // send the packet and get back the response
 
630
        //
 
631
        $response = $this->sendPacket($this->_packet, $this->use_tcp);
 
632
 
 
633
        //
 
634
        // clear the internal packet so if we make another request, we don't have
 
635
        // old data being sent.
 
636
        //
 
637
        $this->_packet->reset();
 
638
 
 
639
        //
 
640
        // for updates, we just need to know it worked- we don't actualy need to
 
641
        // return the response object
 
642
        //
 
643
        return true;
 
644
    }
 
645
}
 
646
 
 
647
/*
 
648
 * Local variables:
 
649
 * tab-width: 4
 
650
 * c-basic-offset: 4
 
651
 * c-hanging-comment-ender-p: nil
 
652
 * End:
 
653
 */
 
654
?>