Example #1
0
 function data($packet, $offset)
 {
     $data = $packet->dn_comp($this->qname, $offset);
     $data .= pack('n', Net_DNS::typesbyname(strtoupper($this->qtype)));
     $data .= pack('n', Net_DNS::classesbyname(strtoupper($this->qclass)));
     return $data;
 }
 function rr_rdata($packet, $offset)
 {
     $rdata = '';
     $sigdata = '';
     if (strlen($this->key)) {
         $key = $this->key;
         $key = ereg_replace(' ', '', $key);
         $key = base64_decode($key);
         $newpacket = $packet;
         $newoffset = $offset;
         array_pop($newpacket->additional);
         $newpacket->header->arcount--;
         $newpacket->compnames = array();
         /*
          * Add the request MAC if present (used to validate responses).
          */
         if (isset($this->request_mac)) {
             $sigdata .= pack('H*', $this->request_mac);
         }
         $sigdata .= $newpacket->data();
         /*
          * Don't compress the record (key) name.
          */
         $tmppacket = new Net_DNS_Packet();
         $sigdata .= $tmppacket->dn_comp(strtolower($this->name), 0);
         $sigdata .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));
         $sigdata .= pack('N', $this->ttl);
         /*
          * Don't compress the algorithm name.
          */
         $tmppacket->compnames = array();
         $sigdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);
         $sigdata .= pack('nN', 0, $this->time_signed);
         $sigdata .= pack('n', $this->fudge);
         $sigdata .= pack('nn', $this->error, $this->other_len);
         if (strlen($this->other_data)) {
             $sigdata .= pack('nN', 0, $this->other_data);
         }
         $this->mac = mhash(MHASH_MD5, $sigdata, $key);
         $this->mac_size = strlen($this->mac);
         /*
          * Don't compress the algorithm name.
          */
         unset($tmppacket);
         $tmppacket = new Net_DNS_Packet();
         $rdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);
         $rdata .= pack('nN', 0, $this->time_signed);
         $rdata .= pack('nn', $this->fudge, $this->mac_size);
         $rdata .= $this->mac;
         $rdata .= pack('nnn', $packet->header->id, $this->error, $this->other_len);
         if ($this->other_data) {
             $rdata .= pack('nN', 0, $this->other_data);
         }
     }
     return $rdata;
 }
Example #3
0
 function data(&$packet, $offset)
 {
     $data = $packet->dn_comp($this->name, $offset);
     $data .= pack('n', Net_DNS::typesbyname(strtoupper($this->type)));
     $data .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));
     $data .= pack('N', $this->ttl);
     $offset += strlen($data) + 2;
     // The 2 extra bytes are for rdlength
     $rdata = $this->rdata($packet, $offset);
     $data .= pack('n', strlen($rdata));
     $data .= $rdata;
     return $data;
 }