Changeset 1123

Show
Ignore:
Timestamp:
01/01/08 21:48:54 (2 years ago)
Author:
ahu
Message:

implement EDNS0 support in the PowerDNS Authoritative Server

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/dnspacket.cc

    r1029 r1123  
    11/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2001 - 2007  PowerDNS.COM BV 
     3    Copyright (C) 2001 - 2008  PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    8888  qclass=orig.qclass; 
    8989  qdomain=orig.qdomain; 
    90  
     90  d_maxreplylen = orig.d_maxreplylen; 
    9191  rrs=orig.rrs; 
    9292 
     
    381381  r->qdomain = qdomain; 
    382382  r->qtype = qtype; 
     383  r->d_maxreplylen = d_maxreplylen; 
    383384  return r; 
    384385} 
     
    407408    return -1; 
    408409  } 
    409   MOADNSParser mdp(string(mesg, length)); 
     410  MOADNSParser mdp(stringbuffer); 
     411  MOADNSParser::EDNSOpts edo; 
     412  if(mdp.getEDNSOpts(&edo)) { 
     413    d_maxreplylen=edo.d_packetsize; 
     414  } 
     415  else 
     416    d_maxreplylen=512; 
    410417 
    411418  memcpy((void *)&d,(const void *)stringbuffer.c_str(),12); 
     
    429436} 
    430437 
     438int DNSPacket::getMaxReplyLen() 
     439{ 
     440  return d_maxreplylen; 
     441} 
     442 
    431443//! Use this to set where this packet was received from or should be sent to 
    432444void DNSPacket::setRemote(const ComboAddress *s) 
  • trunk/pdns/pdns/dnspacket.hh

    r972 r1123  
    139139 
    140140  void commitD(); //!< copies 'd' into the stringbuffer 
    141  
     141  int getMaxReplyLen(); //!< retrieve the maximum length of the packet we should send in response 
    142142  //////// DATA ! 
    143143 
     
    162162 
    163163  string stringbuffer; // this is where everything lives 4 
    164  
     164  int d_maxreplylen; 
    165165  vector<DNSResourceRecord> rrs; // 4 
    166166}; 
  • trunk/pdns/pdns/nameserver.cc

    r1080 r1123  
    4343 
    4444    \section copyright Copyright and License 
    45     PowerDNS is (C) 2005 PowerDNS.COM BV. It is distributed according to the terms of the General Public License version 2. 
     45    PowerDNS is (C) 2001-2008 PowerDNS.COM BV. It is distributed according to the terms of the General Public License version 2. 
    4646 
    4747    \section overview High level overview 
     
    181181  const char *buffer=p->getData(); 
    182182  DLOG(L<<Logger::Notice<<"Sending a packet to "<< p->remote.toString() <<" ("<<p->len<<" octets)"<<endl); 
    183   if(p->len>512) { 
     183  if(p->len > p->getMaxReplyLen()) { 
    184184    shared_ptr<DNSPacket> sharedp(new DNSPacket(*p)); 
    185     sharedp->truncate(512); 
     185    sharedp->truncate(p->getMaxReplyLen()); 
    186186    buffer=sharedp->getData(); 
    187187    if(sendto(sharedp->getSocket(),buffer,sharedp->len,0,(struct sockaddr *)(&sharedp->remote), sharedp->remote.getSocklen())<0)