reSIProcate/rutil  9694
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
resip::RRList Class Reference

#include <RRList.hxx>

Inheritance diagram for resip::RRList:
Inheritance graph
[legend]
Collaboration diagram for resip::RRList:
Collaboration graph
[legend]

List of all members.

Classes

class  Protocol
struct  RecordItem

Public Types

typedef std::vector
< DnsResourceRecord * > 
Records
typedef IntrusiveListElement
< RRList * > 
LruList
typedef std::vector< RROverlay >
::const_iterator 
Itr
typedef std::vector< DataDataArr

Public Member Functions

 RRList ()
 RRList (const Data &key, const int rrtype, int ttl, int status)
 RRList (const Data &key, int rrtype)
 ~RRList ()
 RRList (const RRFactoryBase *factory, const Data &key, const int rrType, Itr begin, Itr end, int ttl)
 RRList (const DnsHostRecord &record, int ttl)
void update (const DnsHostRecord &record, int ttl)
void update (const RRFactoryBase *factory, Itr begin, Itr end, int ttl)
Records records (const int protocol)
const Datakey () const
int status () const
int rrType () const
UInt64 absoluteExpiry () const
UInt64absoluteExpiry ()
void log ()
EncodeStream & encodeRRList (EncodeStream &strm)

Private Types

typedef std::vector< RecordItemRecordArr
typedef RecordArr::iterator RecordItr

Private Member Functions

RecordItr find (const Data &)
void clear ()
EncodeStream & encodeRecordItem (RRList::RecordItem &item, EncodeStream &strm)

Private Attributes

RecordArr mRecords
Data mKey
int mRRType
int mStatus
UInt64 mAbsoluteExpiry

Detailed Description

Definition at line 14 of file RRList.hxx.


Member Typedef Documentation

typedef std::vector<Data> resip::RRList::DataArr

Definition at line 31 of file RRList.hxx.

typedef std::vector<RROverlay>::const_iterator resip::RRList::Itr

Definition at line 30 of file RRList.hxx.

Definition at line 29 of file RRList.hxx.

typedef std::vector<RecordItem> resip::RRList::RecordArr [private]

Definition at line 66 of file RRList.hxx.

typedef RecordArr::iterator resip::RRList::RecordItr [private]

Definition at line 67 of file RRList.hxx.

Definition at line 28 of file RRList.hxx.


Constructor & Destructor Documentation

RRList::RRList ( )

Definition at line 39 of file RRList.cxx.

: mRRType(0), mStatus(0), mAbsoluteExpiry(ULONG_MAX) {}
RRList::RRList ( const Data key,
const int  rrtype,
int  ttl,
int  status 
) [explicit]

Definition at line 41 of file RRList.cxx.

References resip::Timer::getTimeSecs(), and mAbsoluteExpiry.

   : mKey(key), mRRType(rrtype), mStatus(status)
{
   mAbsoluteExpiry = ttl + Timer::getTimeSecs();
}

Here is the call graph for this function:

RRList::RRList ( const Data key,
int  rrtype 
) [explicit]

Definition at line 66 of file RRList.cxx.

   : mKey(key), mRRType(rrtype), mStatus(0), mAbsoluteExpiry(ULONG_MAX)
{}
RRList::~RRList ( )

Definition at line 70 of file RRList.cxx.

References clear().

{
   this->clear();
}

Here is the call graph for this function:

RRList::RRList ( const RRFactoryBase factory,
const Data key,
const int  rrType,
Itr  begin,
Itr  end,
int  ttl 
)

Definition at line 75 of file RRList.cxx.

References update().

   : mKey(key), mRRType(rrType), mStatus(0)
{
   update(factory, begin, end, ttl);
}

Here is the call graph for this function:

RRList::RRList ( const DnsHostRecord record,
int  ttl 
)

Definition at line 50 of file RRList.cxx.

References update().

   : mKey(record.name()), mRRType(T_A), mStatus(0), mAbsoluteExpiry(ULONG_MAX)
{
   update(record, ttl);
}

Here is the call graph for this function:


Member Function Documentation

UInt64 resip::RRList::absoluteExpiry ( ) const [inline]

Definition at line 53 of file RRList.hxx.

References mAbsoluteExpiry.

{ return mAbsoluteExpiry; }
UInt64& resip::RRList::absoluteExpiry ( ) [inline]

Definition at line 54 of file RRList.hxx.

References mAbsoluteExpiry.

{ return mAbsoluteExpiry; }
void RRList::clear ( ) [private]

Definition at line 141 of file RRList.cxx.

References mRecords.

Referenced by update(), and ~RRList().

{
   for (RecordArr::iterator it = mRecords.begin(); it != mRecords.end(); ++it)
   {
      delete (*it).record;
   }
   mRecords.clear();
}
EncodeStream & RRList::encodeRecordItem ( RRList::RecordItem item,
EncodeStream &  strm 
) [private]

Definition at line 151 of file RRList.cxx.

References resip::DnsCnameRecord::cname(), resip::DnsNaptrRecord::flags(), resip::Timer::getTimeSecs(), resip::DnsHostRecord::host(), resip::DnsUtil::inet_ntop(), mAbsoluteExpiry, mKey, mRRType, mStatus, resip::DnsResourceRecord::name(), resip::DnsHostRecord::name(), resip::DnsAAAARecord::name(), resip::DnsCnameRecord::name(), resip::DnsSrvRecord::name(), resip::DnsNaptrRecord::name(), resip::DnsNaptrRecord::order(), resip::DnsSrvRecord::port(), resip::DnsNaptrRecord::preference(), resip::DnsSrvRecord::priority(), resip::RRList::RecordItem::record, resip::DnsNaptrRecord::regexp(), resip::DnsNaptrRecord::replacement(), resip::DnsNaptrRecord::service(), T_A, T_AAAA, T_NAPTR, T_SRV, resip::DnsSrvRecord::target(), and resip::DnsSrvRecord::weight().

Referenced by encodeRRList(), and log().

{
   strm << "DNSCACHE: Type=";

   switch(mRRType)
   {
   case T_CNAME:
      {
         DnsCnameRecord* record = dynamic_cast<DnsCnameRecord*>(item.record);
         assert(record);         
         strm << "CNAME: " << record->name() << " -> " << record->cname();
         break;
      }

   case T_NAPTR:
      {
         DnsNaptrRecord* record = dynamic_cast<DnsNaptrRecord*>(item.record);
         assert(record);
         strm << "NAPTR: " << record->name() << " -> repl=" << record->replacement() << " service=" << record->service() 
            << " order=" << record->order() << " pref=" << record->preference() << " flags=" << record->flags() 
            << " regexp=" << record->regexp().regexp();
         break;
      }

   case T_SRV:
      {
         DnsSrvRecord* record = dynamic_cast<DnsSrvRecord*>(item.record);
         assert(record);
         strm << "SRV: " << record->name() << " -> " << record->target() << ":" << record->port() 
            << " priority=" << record->priority() << " weight=" << record->weight();               
         break;
      }

#ifdef USE_IPV6
   case T_AAAA:
      {
         DnsAAAARecord* record = dynamic_cast<DnsAAAARecord*>(item.record);
         assert(record);
         strm << "AAAA(Host): " << record->name() << " -> " << DnsUtil::inet_ntop(record->v6Address());
         break;
      }
#endif

   case T_A:
      {
         DnsHostRecord* record = dynamic_cast<DnsHostRecord*>(item.record);
         assert(record);
         strm << "A(Host): " << record->name() << " -> " << record->host();
         break;
      }
   default:
      strm << "UNKNOWN(" << mRRType << ")" << " key=" << mKey << " name=" << item.record->name();
      break;
   }

   strm << " secsToExpirey=" << (mAbsoluteExpiry - Timer::getTimeSecs()) << " status=" << mStatus;
   strm.flush();
   return strm;
}

Here is the call graph for this function:

EncodeStream & RRList::encodeRRList ( EncodeStream &  strm)

Definition at line 224 of file RRList.cxx.

References encodeRecordItem(), and mRecords.

{
   for (RecordArr::iterator it = mRecords.begin(); it != mRecords.end(); ++it)
   {
      encodeRecordItem(*it, strm);
      strm << endl;
   }
   return strm;
}

Here is the call graph for this function:

RRList::RecordItr RRList::find ( const Data value) [private]

Definition at line 129 of file RRList.cxx.

References mRecords.

{
   for (RecordItr it = mRecords.begin(); it != mRecords.end(); ++it)
   {
      if ((*it).record->isSameValue(value))
      {
         return it;
      }
   }
   return mRecords.end();
}
const Data& resip::RRList::key ( ) const [inline]

Definition at line 50 of file RRList.hxx.

References mKey.

Referenced by resip::RRCache::CompareT::operator()().

{ return mKey; }
void RRList::log ( )

Definition at line 211 of file RRList.cxx.

References encodeRecordItem(), mRecords, and WarningLog.

{
   for (RecordArr::iterator it = mRecords.begin(); it != mRecords.end(); ++it)
   {
      Data buffer;
      DataStream strm(buffer);

      encodeRecordItem(*it, strm);
      WarningLog( << buffer);
   }
}

Here is the call graph for this function:

RRList::Records RRList::records ( const int  protocol)

Definition at line 117 of file RRList.cxx.

References mRecords.

{
   Records records;
   if (mRecords.empty()) return records;

   for (std::vector<RecordItem>::iterator it = mRecords.begin(); it != mRecords.end(); ++it)
   {
      records.push_back((*it).record);
   }
   return records;
}
int resip::RRList::rrType ( ) const [inline]

Definition at line 52 of file RRList.hxx.

References mRRType.

Referenced by resip::RRCache::CompareT::operator()().

{ return mRRType; }
int resip::RRList::status ( ) const [inline]

Definition at line 51 of file RRList.hxx.

References mStatus.

{ return mStatus; }
void RRList::update ( const DnsHostRecord record,
int  ttl 
)

Definition at line 56 of file RRList.cxx.

References clear(), resip::Timer::getTimeSecs(), mAbsoluteExpiry, mRecords, and resip::RRList::RecordItem::record.

Referenced by RRList().

{
   this->clear();

   RecordItem item;
   item.record = new DnsHostRecord(record);
   mRecords.push_back(item);
   mAbsoluteExpiry = Timer::getTimeSecs() + ttl;
}

Here is the call graph for this function:

void RRList::update ( const RRFactoryBase factory,
Itr  begin,
Itr  end,
int  ttl 
)

Definition at line 86 of file RRList.cxx.

References clear(), resip::RRFactoryBase::create(), resip::IntrusiveListElement< RRList * >::end(), ErrLog, resip::BaseException::getMessage(), resip::Timer::getTimeSecs(), mAbsoluteExpiry, mRecords, and resip::RRList::RecordItem::record.

{
   this->clear();
   mAbsoluteExpiry = ULONG_MAX;
   
   for (Itr it = begin; it != end; it++)
   {
      try
      {
         RecordItem item;
         item.record = factory->create(*it);
         mRecords.push_back(item);
         if ((UInt64)it->ttl() < mAbsoluteExpiry)
         {
            mAbsoluteExpiry = it->ttl();
         }
      }
      catch (BaseException& e)
      {
         ErrLog(<< e.getMessage() << endl);
      }
   }

   if (mAbsoluteExpiry < (UInt64)ttl)
   {
      mAbsoluteExpiry = ttl;
   }

   mAbsoluteExpiry += Timer::getTimeSecs();
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 75 of file RRList.hxx.

Referenced by absoluteExpiry(), encodeRecordItem(), RRList(), and update().

Definition at line 71 of file RRList.hxx.

Referenced by encodeRecordItem(), and key().

Definition at line 69 of file RRList.hxx.

Referenced by clear(), encodeRRList(), find(), log(), records(), and update().

int resip::RRList::mRRType [private]

Definition at line 72 of file RRList.hxx.

Referenced by encodeRecordItem(), and rrType().

int resip::RRList::mStatus [private]

Definition at line 74 of file RRList.hxx.

Referenced by encodeRecordItem(), and status().


The documentation for this class was generated from the following files: