Ejemplo n.º 1
0
    /**
     * returns the rdata portion of the DNS packet
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
     *                                 compressed names
     *
     * @return mixed                   either returns a binary packed
     *                                 string or null on failure
     * @access protected
     *
     */
    protected function rrGet(Net_DNS2_Packet &$packet)
    {
        if (strlen($this->map822) > 0) {
            
            $data = pack('n', $this->preference);
            $packet->offset += 2;

            $data .= $packet->compress($this->map822, $packet->offset);
            $data .= $packet->compress($this->mapx400, $packet->offset);

            return $data;
        }

        return null;
    }
Ejemplo n.º 2
0
    /**
     * returns the rdata portion of the DNS packet
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
     *                                 compressed names
     *
     * @return mixed                   either returns a binary packed
     *                                 string or null on failure
     * @access protected
     *
     */
    protected function rrGet(Net_DNS2_Packet &$packet)
    {
        if ( (strlen($this->hit) > 0) && (strlen($this->public_key) > 0) ) {

            //
            // pack the length, algorithm and HIT values
            //
            $data = pack(
                'CCnH*', 
                $this->hit_length, 
                $this->pk_algorithm, 
                $this->pk_length,
                $this->hit                
            );
            
            //
            // add the public key
            //
            $data .= base64_decode($this->public_key);

            //
            // add the offset
            //
            $packet->offset += strlen($data);

            //
            // add each rendezvous server
            //
            foreach ($this->rendezvous_servers as $index => $server) {

                $data .= $packet->compress($server, $packet->offset);
            }

            return $data;
        }

        return null;
    }
Ejemplo n.º 3
0
    /**
     * returns the rdata portion of the DNS packet
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
     *                                 compressed names
     *
     * @return mixed                   either returns a binary packed
     *                                 string or null on failure
     * @access protected
     *
     */
    protected function rrGet(Net_DNS2_Packet &$packet)
    {
        if (strlen($this->next_domain_name) > 0) {

            $data = $packet->compress($this->next_domain_name, $packet->offset);
            $bitmap = Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps);
    
            $packet->offset += strlen($bitmap);

            return $data . $bitmap;
        }

        return null;
    }
Ejemplo n.º 4
0
 /**
  * returns the rdata portion of the DNS packet
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
  *                                 compressed names
  *
  * @return mixed                   either returns a binary packed
  *                                 string or null on failure
  * @access protected
  *
  */
 protected function rrGet(Net_DNS2_Packet &$packet)
 {
     if (strlen($this->mname) > 0) {
         $data = $packet->compress($this->mname, $packet->offset);
         $data .= $packet->compress($this->rname, $packet->offset);
         $data .= pack('N5', $this->serial, $this->refresh, $this->retry, $this->expire, $this->minimum);
         $packet->offset += 20;
         return $data;
     }
     return null;
 }
Ejemplo n.º 5
0
 /**
  * returns a binary packed Net_DNS2_Question object
  *
  * @param Net_DNS2_Packet &$packet the Net_DNS2_Packet object this question is
  *                                 part of. This needs to be passed in so that
  *                                 the compressed qname value can be packed in
  *                                 with the names of the other parts of the
  *                                 packet.
  *
  * @return string
  * @throws Net_DNS2_Exception
  * @access public
  *
  */
 public function get(Net_DNS2_Packet &$packet)
 {
     //
     // validate the type and class
     //
     $type = Net_DNS2_Lookups::$rr_types_by_name[$this->qtype];
     $class = Net_DNS2_Lookups::$classes_by_name[$this->qclass];
     if (!isset($type) || !isset($class)) {
         throw new Net_DNS2_Exception('invalid question section: invalid type (' . $this->qtype . ') or class (' . $this->qclass . ') specified.', Net_DNS2_Lookups::E_QUESTION_INVALID);
     }
     $data = $packet->compress($this->qname, $packet->offset);
     $data .= chr($type << 8) . chr($type) . chr($class << 8) . chr($class);
     $packet->offset += 4;
     return $data;
 }
Ejemplo n.º 6
0
 /**
  * returns the rdata portion of the DNS packet
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
  *                                 compressed names
  *
  * @return mixed                   either returns a binary packed
  *                                 string or null on failure
  * @access protected
  *
  */
 protected function rrGet(Net_DNS2_Packet &$packet)
 {
     if (strlen($this->target) > 0) {
         $data = pack('nn', $this->priority, $this->weight);
         $packet->offset += 4;
         $data .= $packet->compress(trim($this->target, '"'), $packet->offset);
         return $data;
     }
     return null;
 }
Ejemplo n.º 7
0
 /**
  * returns the rdata portion of the DNS packet
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
  *                                 compressed names
  *
  * @return mixed                   either returns a binary packed
  *                                 string or null on failure
  * @access protected
  *
  */
 protected function rrGet(Net_DNS2_Packet &$packet)
 {
     if (strlen($this->intermediatehost) > 0) {
         $data = pack('n', $this->preference);
         $packet->offset += 2;
         $data .= $packet->compress($this->intermediatehost, $packet->offset);
         return $data;
     }
     return null;
 }
Ejemplo n.º 8
0
    /**
     * returns the rdata portion of the DNS packet
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
     *                                 compressed names
     *
     * @return mixed                   either returns a binary packed
     *                                 string or null on failure
     * @access protected
     *
     */
    protected function rrGet(Net_DNS2_Packet &$packet)
    {
        if (strlen($this->mboxdname) > 0) {

            return $packet->compress($this->mboxdname, $packet->offset) .
                $packet->compress($this->txtdname, $packet->offset);
        }

        return null;
    }
Ejemplo n.º 9
0
    /**
     * returns the rdata portion of the DNS packet
     *
     * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
     *                                 compressed names
     *
     * @return mixed                   either returns a binary packed
     *                                 string or null on failure
     * @access protected
     *
     */
    protected function rrGet(Net_DNS2_Packet &$packet)
    {
        if ( (isset($this->order)) && (strlen($this->services) > 0) ) {
            
            $data = pack('nn', $this->order, $this->preference);

            $data .= chr(strlen($this->flags)) . $this->flags;
            $data .= chr(strlen($this->services)) . $this->services;
            $data .= chr(strlen($this->regexp)) . $this->regexp;

            $packet->offset += strlen($data);

            $data .= $packet->compress($this->replacement, $packet->offset);

            return $data;
        }

        return null;
    }
Ejemplo n.º 10
0
 /**
  * returns a binary packed DNS RR object
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet used for
  *                                 compressing names
  *
  * @return string
  * @throws Net_DNS2_Exception
  * @access public
  *
  */
 public function get(Net_DNS2_Packet &$packet)
 {
     $data = '';
     $rdata = '';
     //
     // pack the name
     //
     $data = $packet->compress($this->name, $packet->offset);
     //
     // pack the main values
     //
     if ($this->type == 'OPT') {
         //
         // pre-build the TTL value
         //
         $this->preBuild();
         //
         // the class value is different for OPT types
         //
         $data .= pack('nnN', Net_DNS2_Lookups::$rr_types_by_name[$this->type], $this->class, $this->ttl);
     } else {
         $data .= pack('nnN', Net_DNS2_Lookups::$rr_types_by_name[$this->type], Net_DNS2_Lookups::$classes_by_name[$this->class], $this->ttl);
     }
     //
     // increase the offset, and allow for the rdlength
     //
     $packet->offset += 10;
     //
     // get the RR specific details
     //
     if ($this->rdlength != -1) {
         $rdata = $this->rrGet($packet);
     }
     //
     // add the RR
     //
     $data .= pack('n', strlen($rdata)) . $rdata;
     return $data;
 }
Ejemplo n.º 11
0
 /**
  * returns the rdata portion of the DNS packet
  *
  * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for
  *                                 compressed names
  *
  * @return mixed                   either returns a binary packed
  *                                 string or null on failure
  * @access protected
  *
  */
 protected function rrGet(Net_DNS2_Packet &$packet)
 {
     if (strlen($this->hostname) > 0) {
         $data = pack('n', $this->subtype);
         $packet->offset += 2;
         $data .= $packet->compress($this->hostname, $packet->offset);
         return $data;
     }
     return null;
 }