OverlayKey Class Reference

A common overlay key class. More...

#include <OverlayKey.h>

Inheritance diagram for OverlayKey:
P2pns::OverlayKeyObject

List of all members.

Public Member Functions

 OverlayKey ()
 Default constructor.
 OverlayKey (uint32_t num)
 Constructs an overlay key initialized with a common integer.
 OverlayKey (const unsigned char *buffer, uint32_t size)
 Constructs a key out of a buffer.
 OverlayKey (const std::string &str, uint32_t base=16)
 Constructs a key out of a string number.
 OverlayKey (const OverlayKey &rhs)
 Copy constructor.
 ~OverlayKey ()
 Default destructor.
std::string toString (uint32_t base=16) const
 Returns a string representation of this key.
bool isUnspecified () const
 Returns true, if the key is unspecified.
bool operator< (const OverlayKey &compKey) const
 compares this to a given OverlayKey
bool operator> (const OverlayKey &compKey) const
 compares this to a given OverlayKey
bool operator<= (const OverlayKey &compKey) const
 compares this to a given OverlayKey
bool operator>= (const OverlayKey &compKey) const
 compares this to a given OverlayKey
bool operator== (const OverlayKey &compKey) const
 compares this to a given OverlayKey
bool operator!= (const OverlayKey &compKey) const
 compares this to a given OverlayKey
int compareTo (const OverlayKey &compKey) const
 Unifies all compare operations in one method.
OverlayKeyoperator= (const OverlayKey &rhs)
 assigns OverlayKey of rhs to this->key
OverlayKeyoperator-- ()
 substracts 1 from this->key
OverlayKeyoperator++ ()
 adds 1 to this->key
OverlayKeyoperator+= (const OverlayKey &rhs)
 adds rhs->key to this->key
OverlayKeyoperator-= (const OverlayKey &rhs)
 substracts rhs->key from this->key
OverlayKey operator+ (const OverlayKey &rhs) const
 adds rhs->key to this->key
OverlayKey operator- (const OverlayKey &rhs) const
 substracts rhs->key from this->key
OverlayKey operator-- (int)
 substracts 1 from this->key
OverlayKey operator++ (int)
 adds 1 to this->key
OverlayKey operator>> (uint32_t num) const
 bitwise shift right
OverlayKey operator<< (uint32_t num) const
 bitwise shift left
OverlayKey operator& (const OverlayKey &rhs) const
 bitwise AND of rhs->key and this->key
OverlayKey operator| (const OverlayKey &rhs) const
 bitwise OR of rhs->key and this->key
OverlayKey operator^ (const OverlayKey &rhs) const
 bitwise XOR of rhs->key and this->key
OverlayKey operator~ () const
 bitwise NOT of this->key
OverlayKeyBit operator[] (uint32_t n)
 returns the n-th bit of this->key
OverlayKeysetBit (uint32_t pos, bool value)
 sets a bit of this->key
uint32_t getBitRange (uint32_t p, uint32_t n) const
 Returns a sub integer at position p with n-bits.
double toDouble () const
bool getBit (uint32_t p) const
size_t hash () const
 Returns a hash value for the key.
int log_2 () const
 Returns the position of the msb in this key, which represents just the logarithm to base 2.
OverlayKey randomSuffix (uint32_t pos) const
 Fills the suffix starting at pos with random bits to lsb.
OverlayKey randomPrefix (uint32_t pos) const
 Fills the prefix starting at pos with random bits to msb.
uint32_t sharedPrefixLength (const OverlayKey &compKey, uint32_t bitsPerDigit=1) const
 Calculates the number of equal bits (digits) from the left with another Key (shared prefix length).
bool isBetween (const OverlayKey &keyA, const OverlayKey &keyB) const
 Returns true, if this key is element of the interval (keyA, keyB) on the ring.
bool isBetweenR (const OverlayKey &keyA, const OverlayKey &keyB) const
 Returns true, if this key is element of the interval (keyA, keyB] on the ring.
bool isBetweenL (const OverlayKey &keyA, const OverlayKey &keyB) const
 Returns true, if this key is element of the interval [keyA, keyB) on the ring.
bool isBetweenLR (const OverlayKey &keyA, const OverlayKey &keyB) const
 Returns true, if this key is element of the interval [keyA, keyB] on the ring.
void netPack (cCommBuffer *b)
 serializes the object into a buffer
void netUnpack (cCommBuffer *b)
 deserializes the object from a buffer

Static Public Member Functions

static void setKeyLength (uint32_t length)
 Set the length of an OverlayKey.
static uint32_t getLength ()
 Returns the length in number of bits.
static OverlayKey random ()
 Returns a random key.
static OverlayKey getMax ()
 Returns the maximum key, i.e.
static OverlayKey sha1 (const BinaryValue &value)
 Returns a key with the SHA1 cryptographic hash of a BinaryValue.
static OverlayKey pow2 (uint32_t exponent)
 Returns a key 2^exponent.
static void test ()
 A pseudo regression test method.

Static Public Attributes

static const OverlayKey UNSPECIFIED_KEY
 OverlayKey without defined key.
static const OverlayKey ZERO
 OverlayKey with key initialized as 0.
static const OverlayKey ONE
 OverlayKey with key initialized as 1.

Private Member Functions

void trim ()
 trims key after key operations
void clear ()
 set this->key to 0 and isUnspec to false

Private Attributes

bool isUnspec
 is this->key unspecified?
mp_limb_t key [MAX_KEYLENGTH/(8 *sizeof(mp_limb_t))+(MAX_KEYLENGTH%(8 *sizeof(mp_limb_t))!=0?1:0)]
 the overlay key this object represents

Static Private Attributes

static const uint32_t MAX_KEYLENGTH = 160
 maximum length of the key
static uint32_t keyLength = MAX_KEYLENGTH
 actual length of the key
static uint32_t aSize
 number of needed machine words to hold the key
static mp_limb_t GMP_MSB_MASK
 bits to fill up if key does not exactly fit in one or more machine words

Friends

std::ostream & operator<< (std::ostream &os, const OverlayKey &c)
 Common stdc++ console output method.

Detailed Description

A common overlay key class.

Wraps common functions from Gnu MP library.

Author:
Sebastian Mies.

Definition at line 46 of file OverlayKey.h.


Constructor & Destructor Documentation

OverlayKey::OverlayKey (  ) 

Default constructor.

Contructs an unspecified overlay key

Definition at line 67 of file OverlayKey.cc.

Referenced by sha1().

00068 {
00069     isUnspec = true;
00070 }

OverlayKey::OverlayKey ( uint32_t  num  ) 

Constructs an overlay key initialized with a common integer.

Parameters:
num The integer to initialize this key with

Definition at line 73 of file OverlayKey.cc.

00074 {
00075     clear();
00076     key[0] = num;
00077     trim();
00078 }

OverlayKey::OverlayKey ( const unsigned char *  buffer,
uint32_t  size 
)

Constructs a key out of a buffer.

Parameters:
buffer Source buffer
size Buffer size (in bytes)

Definition at line 81 of file OverlayKey.cc.

00082 {
00083     int trimSize, offset;
00084     clear();
00085     trimSize = (int)min((uint32_t) (aSize * sizeof(mp_limb_t)), size);
00086     offset = aSize * sizeof(mp_limb_t) - trimSize;
00087     memcpy( ((char*)key) + offset, buf, trimSize);
00088     trim();
00089 }

OverlayKey::OverlayKey ( const std::string &  str,
uint32_t  base = 16 
)

Constructs a key out of a string number.

Definition at line 92 of file OverlayKey.cc.

00093 {
00094     if ((base < 2) || (base > 16)) {
00095         throw cRuntimeError("OverlayKey::OverlayKey(): Invalid base!");
00096     }
00097 
00098     string s(str);
00099     clear();
00100 
00101     for (uint32_t i=0; i<s.size(); i++) {
00102         if ((s[i] >= '0') && (s[i] <= '9')) {
00103             s[i] -= '0';
00104         } else if ((s[i] >= 'a') && (s[i] <= 'f')) {
00105             s[i] -= ('a' - 10);
00106         } else if ((s[i] >= 'A') & (s[i] <= 'F')) {
00107             s[i] -= ('A' - 10);
00108         } else {
00109             throw cRuntimeError("OverlayKey::OverlayKey(): "
00110                                     "Invalid character in string!");
00111         }
00112     }
00113 
00114     mpn_set_str ((mp_limb_t*)this->key, (const unsigned char*)s.c_str(),
00115                  str.size(), base);
00116     trim();
00117 }

OverlayKey::OverlayKey ( const OverlayKey rhs  ) 

Copy constructor.

Parameters:
rhs The key to copy.

Definition at line 120 of file OverlayKey.cc.

00121 {
00122     (*this) = rhs;
00123 }

OverlayKey::~OverlayKey (  ) 

Default destructor.

Does nothing ATM.

Definition at line 126 of file OverlayKey.cc.

00127 {}


Member Function Documentation

void OverlayKey::clear (  )  [inline, private]

set this->key to 0 and isUnspec to false

Definition at line 817 of file OverlayKey.cc.

Referenced by OverlayKey().

00818 {
00819     memset( key, 0, aSize * sizeof(mp_limb_t) );
00820     isUnspec = false;
00821 }

int OverlayKey::compareTo ( const OverlayKey compKey  )  const

Unifies all compare operations in one method.

Parameters:
compKey key to compare with
Returns:
int -1 if smaller, 0 if equal, 1 if greater

Definition at line 809 of file OverlayKey.cc.

Referenced by IterativeLookup::compare(), KademliaPRComparator::compare(), operator!=(), operator<(), NodeHandle::operator<(), operator<=(), operator==(), operator>(), NodeHandle::operator>(), operator>=(), and sharedPrefixLength().

00810 {
00811     if (compKey.isUnspec || isUnspec)
00812         opp_error("OverlayKey::compareTo(): key is unspecified!");
00813     return mpn_cmp(key,compKey.key,aSize);
00814 }

bool OverlayKey::getBit ( uint32_t  p  )  const [inline]

Definition at line 335 of file OverlayKey.h.

Referenced by Bamboo::doGlobalTuning(), oversim::Koorde::findDeBruijnHop(), Broose::findNode(), operator[](), and toString().

00336     {
00337         return getBitRange(p, 1);
00338     };

uint32_t OverlayKey::getBitRange ( uint32_t  p,
uint32_t  n 
) const

Returns a sub integer at position p with n-bits.

p is counted starting from the least significant bit of the key as bit 0. Bit p of the key becomes bit 0 of the returned integer.

Parameters:
p the position of the sub-integer
n the number of bits to be returned (max.32)
Returns:
The sub-integer.

Definition at line 424 of file OverlayKey.cc.

Referenced by PastryRoutingTable::digitAt(), Bamboo::doGlobalTuning(), getBit(), XmlRpcInterface::handleReadyMessage(), Kademlia::routingBucketIndex(), test(), toDouble(), and toString().

00425 {
00426     int i = p / GMP_LIMB_BITS,      // index of starting bit
00427         f = p % GMP_LIMB_BITS,      // position of starting bit
00428         f2 = f + n - GMP_LIMB_BITS; // how many bits to take from next index
00429 
00430     if ((p + n > OverlayKey::keyLength) || (n > 32)) {
00431         throw cRuntimeError("OverlayKey::get:  Invalid range");
00432     }
00433     if (GMP_LIMB_BITS < 32) {
00434         throw cRuntimeError("OverlayKey::get:  GMP_LIMB_BITS too small!");
00435     }
00436 
00437     return ((key[i] >> f) |                                     // get the bits of key[i]
00438             (f2 > 0 ? (key[i+1] << (GMP_LIMB_BITS - f)) : 0)) & // the extra bits from key[i+1]
00439         (((uint32_t)(~0)) >> (GMP_LIMB_BITS - n));              // delete unused bits
00440 }

uint32_t OverlayKey::getLength (  )  [static]
OverlayKey OverlayKey::getMax (  )  [static]

Returns the maximum key, i.e.

a key filled with bit 1

Returns:
The maximum key, i.e. a key filled with bit 1

Definition at line 628 of file OverlayKey.cc.

Referenced by PastryStateObject::keyDist(), and test().

00629 {
00630     OverlayKey newKey;
00631 
00632     for (uint32_t i=0; i<aSize; i++) {
00633         newKey.key[i] = ~0;
00634     }
00635     newKey.isUnspec = false;
00636     newKey.trim();
00637 
00638     return newKey;
00639 }

size_t OverlayKey::hash (  )  const

Returns a hash value for the key.

Returns:
size_t The hash value

Definition at line 550 of file OverlayKey.cc.

00551 {
00552     return (size_t)key[0];
00553 }

bool OverlayKey::isBetween ( const OverlayKey keyA,
const OverlayKey keyB 
) const

Returns true, if this key is element of the interval (keyA, keyB) on the ring.

Parameters:
keyA The left border of the interval
keyB The right border of the interval
Returns:
True, if the key is element of the interval (keyA, keyB)

Definition at line 556 of file OverlayKey.cc.

Referenced by oversim::Chord::closestPreceedingNode(), oversim::Koorde::findDeBruijnHop(), oversim::Chord::handleRpcStabilizeResponse(), PastryLeafSet::mergeNode(), oversim::Chord::rpcNotify(), and test().

00558 {
00559     if (isUnspec || keyA.isUnspec || keyB.isUnspec)
00560         return false;
00561 
00562     if (*this == keyA)
00563         return false;
00564     else if (keyA < keyB)
00565         return ((*this > keyA) && (*this < keyB));
00566     else
00567         return ((*this > keyA) || (*this < keyB));
00568 }

bool OverlayKey::isBetweenL ( const OverlayKey keyA,
const OverlayKey keyB 
) const

Returns true, if this key is element of the interval [keyA, keyB) on the ring.

Parameters:
keyA The left border of the interval
keyB The right border of the interval
Returns:
True, if the key is element of the interval [keyA, keyB)

Definition at line 586 of file OverlayKey.cc.

Referenced by test().

00588 {
00589     if (isUnspec || keyA.isUnspec || keyB.isUnspec)
00590         return false;
00591 
00592     if ((keyA == keyB) && (*this == keyA))
00593         return true;
00594     else if (keyA <= keyB)
00595         return ((*this >= keyA) && (*this < keyB));
00596     else
00597         return ((*this >= keyA) || (*this < keyB));
00598 }

bool OverlayKey::isBetweenLR ( const OverlayKey keyA,
const OverlayKey keyB 
) const

Returns true, if this key is element of the interval [keyA, keyB] on the ring.

Parameters:
keyA The left border of the interval
keyB The right border of the interval
Returns:
True, if the key is element of the interval [keyA, keyB]

Definition at line 601 of file OverlayKey.cc.

Referenced by oversim::Chord::closestPreceedingNode(), PastryLeafSet::getDestinationNode(), oversim::ChordFingerTable::getFinger(), and oversim::ChordSuccessorList::updateList().

00603 {
00604     if (isUnspec || keyA.isUnspec || keyB.isUnspec)
00605         return false;
00606 
00607     if ((keyA == keyB) && (*this == keyA))
00608         return true;
00609     else if (keyA <= keyB)
00610         return ((*this >= keyA) && (*this <= keyB));
00611     else
00612         return ((*this >= keyA) || (*this <= keyB));
00613 }

bool OverlayKey::isBetweenR ( const OverlayKey keyA,
const OverlayKey keyB 
) const

Returns true, if this key is element of the interval (keyA, keyB] on the ring.

Parameters:
keyA The left border of the interval
keyB The right border of the interval
Returns:
True, if the key is element of the interval (keyA, keyB]

Definition at line 571 of file OverlayKey.cc.

Referenced by oversim::Chord::closestPreceedingNode(), oversim::Koorde::findNode(), oversim::Chord::findNode(), oversim::Koorde::handleDeBruijnTimerExpired(), oversim::Chord::isSiblingFor(), test(), oversim::Koorde::walkDeBruijnList(), and oversim::Koorde::walkSuccessorList().

00573 {
00574     if (isUnspec || keyA.isUnspec || keyB.isUnspec)
00575         return false;
00576 
00577     if ((keyA == keyB) && (*this == keyA))
00578         return true;
00579     else if (keyA <= keyB)
00580         return ((*this > keyA) && (*this <= keyB));
00581     else
00582         return ((*this > keyA) || (*this <= keyB));
00583 }

bool OverlayKey::isUnspecified (  )  const
int OverlayKey::log_2 (  )  const

Returns the position of the msb in this key, which represents just the logarithm to base 2.

Returns:
The logarithm to base 2 of this key.

Definition at line 527 of file OverlayKey.cc.

Referenced by oversim::Koorde::findStartKey().

00528 {
00529     int16_t i = aSize-1;
00530 
00531     while (i>=0 && key[i]==0) {
00532         i--;
00533     }
00534 
00535     if (i<0) {
00536         return -1;
00537     }
00538 
00539     mp_limb_t j = key[i];
00540     i *= GMP_LIMB_BITS;
00541     while (j!=0) {
00542         j >>= 1;
00543         i++;
00544     }
00545 
00546     return i-1;
00547 }

void OverlayKey::netPack ( cCommBuffer *  b  ) 

serializes the object into a buffer

Parameters:
b the buffer

Definition at line 844 of file OverlayKey.cc.

Referenced by doPacking().

00845 {
00846     doPacking(b,(GMP_TYPE*)this->key, MAX_KEYLENGTH / (8*sizeof(mp_limb_t)) +
00847               (MAX_KEYLENGTH % (8*sizeof(mp_limb_t))!=0 ? 1 : 0));
00848     doPacking(b,this->isUnspec);
00849 }

void OverlayKey::netUnpack ( cCommBuffer *  b  ) 

deserializes the object from a buffer

Parameters:
b the buffer

Definition at line 851 of file OverlayKey.cc.

Referenced by doUnpacking().

00852 {
00853     doUnpacking(b,(GMP_TYPE*)this->key, MAX_KEYLENGTH / (8*sizeof(mp_limb_t)) +
00854                 (MAX_KEYLENGTH % (8*sizeof(mp_limb_t))!=0 ? 1 : 0));
00855     doUnpacking(b,this->isUnspec);
00856 
00857 }

bool OverlayKey::operator!= ( const OverlayKey compKey  )  const

compares this to a given OverlayKey

Parameters:
compKey the the OverlayKey to compare this to
Returns:
true if compKey->key is not equal to this->key, else false

Definition at line 301 of file OverlayKey.cc.

00302 {
00303     return compareTo(compKey) !=0;
00304 }

OverlayKey OverlayKey::operator& ( const OverlayKey rhs  )  const

bitwise AND of rhs->key and this->key

Parameters:
rhs the OverlayKey AND is calculated with
Returns:
this OverlayKey object

Definition at line 329 of file OverlayKey.cc.

00330 {
00331     OverlayKey result = *this;
00332     for (uint32_t i=0; i<aSize; i++) {
00333         result.key[i] &= rhs.key[i];
00334     }
00335 
00336     return result;
00337 }

OverlayKey OverlayKey::operator+ ( const OverlayKey rhs  )  const

adds rhs->key to this->key

Parameters:
rhs the OverlayKey with the defined key
Returns:
this OverlayKey object

Definition at line 265 of file OverlayKey.cc.

00266 {
00267     OverlayKey result = *this;
00268     result += rhs;
00269     return result;
00270 }

OverlayKey OverlayKey::operator++ ( int   ) 

adds 1 to this->key

Returns:
this OverlayKey object

Definition at line 239 of file OverlayKey.cc.

00240 {
00241     OverlayKey clone = *this;
00242     *this += ONE;
00243     return clone;
00244 }

OverlayKey & OverlayKey::operator++ (  ) 

adds 1 to this->key

Returns:
this OverlayKey object

Definition at line 233 of file OverlayKey.cc.

00234 {
00235     return (*this += ONE);
00236 }

OverlayKey & OverlayKey::operator+= ( const OverlayKey rhs  ) 

adds rhs->key to this->key

Parameters:
rhs the OverlayKey with the defined key
Returns:
this OverlayKey object

Definition at line 247 of file OverlayKey.cc.

00248 {
00249     mpn_add_n((mp_limb_t*)key, (mp_limb_t*)key, (mp_limb_t*)rhs.key, aSize);
00250     trim();
00251     isUnspec = false;
00252     return *this;
00253 }

OverlayKey OverlayKey::operator- ( const OverlayKey rhs  )  const

substracts rhs->key from this->key

Parameters:
rhs the OverlayKey with the defined key
Returns:
this OverlayKey object

Definition at line 273 of file OverlayKey.cc.

00274 {
00275     OverlayKey result = *this;
00276     result -= rhs;
00277     return result;
00278 }

OverlayKey OverlayKey::operator-- ( int   ) 

substracts 1 from this->key

Returns:
this OverlayKey object

Definition at line 225 of file OverlayKey.cc.

00226 {
00227     OverlayKey clone = *this;
00228     *this -= ONE;
00229     return clone;
00230 }

OverlayKey & OverlayKey::operator-- (  ) 

substracts 1 from this->key

Returns:
this OverlayKey object

Definition at line 219 of file OverlayKey.cc.

00220 {
00221     return (*this -= ONE);
00222 }

OverlayKey & OverlayKey::operator-= ( const OverlayKey rhs  ) 

substracts rhs->key from this->key

Parameters:
rhs the OverlayKey with the defined key
Returns:
this OverlayKey object

Definition at line 256 of file OverlayKey.cc.

00257 {
00258     mpn_sub_n((mp_limb_t*)key, (mp_limb_t*)key, (mp_limb_t*)rhs.key, aSize);
00259     trim();
00260     isUnspec = false;
00261     return *this;
00262 }

bool OverlayKey::operator< ( const OverlayKey compKey  )  const

compares this to a given OverlayKey

Parameters:
compKey the the OverlayKey to compare this to
Returns:
true if compKey->key is smaller than this->key, else false

Definition at line 281 of file OverlayKey.cc.

00282 {
00283     return compareTo(compKey) < 0;
00284 }

OverlayKey OverlayKey::operator<< ( uint32_t  num  )  const

bitwise shift left

Parameters:
num number of bits to shift
Returns:
this OverlayKey object

Definition at line 373 of file OverlayKey.cc.

00374 {
00375     OverlayKey result = ZERO;
00376     int i = num/GMP_LIMB_BITS;
00377 
00378     num %= GMP_LIMB_BITS;
00379 
00380     if (i>=(int)aSize)
00381         return result;
00382 
00383     for (int j=0; j<(int)aSize-i; j++) {
00384         result.key[j+i] = key[j];
00385     }
00386     mpn_lshift(result.key,result.key,aSize,num);
00387     result.isUnspec = false;
00388     result.trim();
00389 
00390     return result;
00391 }

bool OverlayKey::operator<= ( const OverlayKey compKey  )  const

compares this to a given OverlayKey

Parameters:
compKey the the OverlayKey to compare this to
Returns:
true if compKey->key is smaller than or equal to this->key, else false

Definition at line 289 of file OverlayKey.cc.

00290 {
00291     return compareTo(compKey) <=0;
00292 }

OverlayKey & OverlayKey::operator= ( const OverlayKey rhs  ) 

assigns OverlayKey of rhs to this->key

Parameters:
rhs the OverlayKey with the defined key
Returns:
this OverlayKey object

Definition at line 211 of file OverlayKey.cc.

00212 {
00213     isUnspec = rhs.isUnspec;
00214     memcpy( key, rhs.key, aSize*sizeof(mp_limb_t) );
00215     return *this;
00216 }

bool OverlayKey::operator== ( const OverlayKey compKey  )  const

compares this to a given OverlayKey

Parameters:
compKey the the OverlayKey to compare this to
Returns:
true if compKey->key is equal to this->key, else false

Definition at line 297 of file OverlayKey.cc.

00298 {
00299     return compareTo(compKey) ==0;
00300 }

bool OverlayKey::operator> ( const OverlayKey compKey  )  const

compares this to a given OverlayKey

Parameters:
compKey the the OverlayKey to compare this to
Returns:
true if compKey->key is greater than this->key, else false

Definition at line 285 of file OverlayKey.cc.

00286 {
00287     return compareTo(compKey) > 0;
00288 }

bool OverlayKey::operator>= ( const OverlayKey compKey  )  const

compares this to a given OverlayKey

Parameters:
compKey the the OverlayKey to compare this to
Returns:
true if compKey->key is greater than or equal to this->key, else false

Definition at line 293 of file OverlayKey.cc.

00294 {
00295     return compareTo(compKey) >=0;
00296 }

OverlayKey OverlayKey::operator>> ( uint32_t  num  )  const

bitwise shift right

Parameters:
num number of bits to shift
Returns:
this OverlayKey object

Definition at line 352 of file OverlayKey.cc.

00353 {
00354     OverlayKey result = ZERO;
00355     int i = num/GMP_LIMB_BITS;
00356 
00357     num %= GMP_LIMB_BITS;
00358 
00359     if (i>=(int)aSize)
00360         return result;
00361 
00362     for (int j=0; j<(int)aSize-i; j++) {
00363         result.key[j] = key[j+i];
00364     }
00365     mpn_rshift(result.key,result.key,aSize,num);
00366     result.isUnspec = false;
00367     result.trim();
00368 
00369     return result;
00370 }

OverlayKeyBit OverlayKey::operator[] ( uint32_t  n  ) 

returns the n-th bit of this->key

Parameters:
n the position of the returned bit
Returns:
the bit on position n in this->key

Definition at line 394 of file OverlayKey.cc.

00395 {
00396     return OverlayKeyBit(getBit(n), n, this);
00397 }

OverlayKey OverlayKey::operator^ ( const OverlayKey rhs  )  const

bitwise XOR of rhs->key and this->key

Parameters:
rhs the OverlayKey XOR is calculated with
Returns:
this OverlayKey object

Definition at line 307 of file OverlayKey.cc.

00308 {
00309     OverlayKey result = *this;
00310     for (uint32_t i=0; i<aSize; i++) {
00311         result.key[i] ^= rhs.key[i];
00312     }
00313 
00314     return result;
00315 }

OverlayKey OverlayKey::operator| ( const OverlayKey rhs  )  const

bitwise OR of rhs->key and this->key

Parameters:
rhs the OverlayKey OR is calculated with
Returns:
this OverlayKey object

Definition at line 318 of file OverlayKey.cc.

00319 {
00320     OverlayKey result = *this;
00321     for (uint32_t i=0; i<aSize; i++) {
00322         result.key[i] |= rhs.key[i];
00323     }
00324 
00325     return result;
00326 }

OverlayKey OverlayKey::operator~ (  )  const

bitwise NOT of this->key

Returns:
this OverlayKey object

Definition at line 340 of file OverlayKey.cc.

00341 {
00342     OverlayKey result = *this;
00343     for (uint32_t i=0; i<aSize; i++) {
00344         result.key[i] = ~key[i];
00345     }
00346     result.trim();
00347 
00348     return result;
00349 }

OverlayKey OverlayKey::pow2 ( uint32_t  exponent  )  [static]

Returns a key 2^exponent.

Parameters:
exponent The exponent.
Returns:
Key=2^exponent.

Definition at line 673 of file OverlayKey.cc.

Referenced by oversim::Koorde::findStartKey(), oversim::Chord::handleFixFingersTimerExpired(), oversim::Chord::handleStabilizeTimerExpired(), and test().

00674 {
00675     if (exponent >= keyLength) {
00676         throw cRuntimeError("OverlayKey::pow2(): "
00677                                 "exponent >= keyLength!");
00678     }
00679 
00680     OverlayKey newKey = ZERO;
00681 
00682     newKey.key[exponent/GMP_LIMB_BITS] =
00683         (mp_limb_t)1 << (exponent % GMP_LIMB_BITS);
00684 
00685     return newKey;
00686 }

OverlayKey OverlayKey::random (  )  [static]
OverlayKey OverlayKey::randomPrefix ( uint32_t  pos  )  const

Fills the prefix starting at pos with random bits to msb.

Parameters:
pos 
Returns:
OverlayKey

Definition at line 477 of file OverlayKey.cc.

Referenced by CoordBasedRouting::getNodeId(), and test().

00478 {
00479     OverlayKey newKey = *this;
00480     int i = pos/GMP_LIMB_BITS, j = pos%GMP_LIMB_BITS;
00481     mp_limb_t m = ((mp_limb_t)1 << j)-1;
00482     mp_limb_t rnd;
00483 
00484     //  mpn_random(&rnd,1);
00485     omnet_random(&rnd,1);
00486 
00487     newKey.key[i] &= m;
00488     newKey.key[i] |= (rnd&~m);
00489     for (int k=aSize-1; k!=i; k--) {
00490         //        mpn_random( &newKey.key[k], 1 );
00491         omnet_random( &newKey.key[k], 1 );
00492     }
00493     newKey.trim();
00494 
00495     return newKey;
00496 }

OverlayKey OverlayKey::randomSuffix ( uint32_t  pos  )  const

Fills the suffix starting at pos with random bits to lsb.

Parameters:
pos 
Returns:
OverlayKey

Definition at line 458 of file OverlayKey.cc.

Referenced by CoordBasedRouting::getNodeId(), and test().

00459 {
00460     OverlayKey newKey = *this;
00461     int i = pos/GMP_LIMB_BITS, j = pos%GMP_LIMB_BITS;
00462     mp_limb_t m = ((mp_limb_t)1 << j)-1;
00463     mp_limb_t rnd;
00464 
00465     //  mpn_random(&rnd,1);
00466     omnet_random(&rnd,1);
00467     newKey.key[i] &= ~m;
00468     newKey.key[i] |= (rnd&m);
00469     //  mpn_random(newKey.key,i);
00470     omnet_random(newKey.key,i);
00471     newKey.trim();
00472 
00473     return newKey;
00474 }

OverlayKey & OverlayKey::setBit ( uint32_t  pos,
bool  value 
)

sets a bit of this->key

Parameters:
pos the position of the bit to set
value new value for bit at position pos
Returns:
*this

Definition at line 399 of file OverlayKey.cc.

Referenced by OverlayKeyBit::operator=(), and OverlayKeyBit::operator^=().

00400 {
00401     if (pos >= keyLength) {
00402         throw cRuntimeError("OverlayKey::setBitAt(): "
00403                                 "pos >= keyLength!");
00404     }
00405 
00406     mp_limb_t digit = 1;
00407     digit = digit << (pos % GMP_LIMB_BITS);
00408 
00409     if (value) {
00410         key[pos / GMP_LIMB_BITS] |= digit;
00411     } else {
00412         //key[pos / GMP_LIMB_BITS] = key[pos / GMP_LIMB_BITS] & ~digit;
00413         key[pos / GMP_LIMB_BITS] &= ~digit;
00414     }
00415 
00416     return *this;
00417 };

void OverlayKey::setKeyLength ( uint32_t  length  )  [static]

Set the length of an OverlayKey.

Parameters:
length keylength in bits

Definition at line 133 of file OverlayKey.cc.

Referenced by BaseOverlay::initialize().

00134 {
00135     if ((length < 1) || (length > OverlayKey::keyLength)) {
00136         opp_error("OverlayKey::setKeyLength(): length must be <= %i "
00137                   "and setKeyLength() must not be called twice "
00138                   "with different length!", MAX_KEYLENGTH);
00139     }
00140 
00141     keyLength = length;
00142 
00143     aSize = keyLength / (8*sizeof(mp_limb_t)) +
00144         (keyLength % (8*sizeof(mp_limb_t))!=0 ? 1 : 0);
00145 
00146     GMP_MSB_MASK = (keyLength % GMP_LIMB_BITS)
00147         != 0 ? (((mp_limb_t)1 << (keyLength % GMP_LIMB_BITS))-1)
00148         : (mp_limb_t)-1;
00149 }

OverlayKey OverlayKey::sha1 ( const BinaryValue value  )  [static]

Returns a key with the SHA1 cryptographic hash of a BinaryValue.

Parameters:
value A BinaryValue object.
Returns:
SHA1 of value

Definition at line 654 of file OverlayKey.cc.

Referenced by XmlRpcInterface::get(), CBRDHT::handleGetCAPIRequest(), SimMud::handleMove(), CBRDHT::handlePutCAPIRequest(), DHTTestApp::handleTraceMessage(), RealWorldTestApp::handleUpperMessage(), XmlRpcInterface::joinOverlay(), XmlRpcInterface::localLookup(), XmlRpcInterface::lookup(), P2pns::p2pnsRegisterRpc(), P2pns::p2pnsResolveRpc(), XmlRpcInterface::put(), P2pns::registerId(), and test().

00655 {
00656     OverlayKey newKey = OverlayKey();
00657     uint8_t temp[20];
00658     CSHA1 sha1;
00659 
00660     sha1.Reset();
00661     sha1.Update((uint8_t*)(&(*input.begin())), input.size());
00662     sha1.Final();
00663     sha1.GetHash(temp);
00664     mpn_set_str(newKey.key, (const uint8_t*)temp,
00665                 (int)std::min((uint32_t)(aSize * sizeof(mp_limb_t)), 20U), 256);
00666     newKey.isUnspec = false;
00667     newKey.trim();
00668 
00669     return newKey;
00670 }

uint32_t OverlayKey::sharedPrefixLength ( const OverlayKey compKey,
uint32_t  bitsPerDigit = 1 
) const

Calculates the number of equal bits (digits) from the left with another Key (shared prefix length).

Parameters:
compKey the Key to compare with
bitsPerDigit optional number of bits per digit, default is 1
Returns:
length of shared prefix

Definition at line 499 of file OverlayKey.cc.

Referenced by KeyPrefixMetric::distance(), PastryRoutingTable::findCloserNode(), oversim::Koorde::findStartKey(), Broose::getRoutingDistance(), PastryRoutingTable::lookupNextHop(), PastryRoutingTable::mergeNode(), PastryStateObject::specialCloserCondition(), and test().

00501 {
00502     if (compareTo(compKey) == 0) return keyLength;
00503 
00504     uint32_t length = 0;
00505     int i;
00506     uint32_t j;
00507     bool msb = true;
00508 
00509     // count equal limbs first:
00510     for (i=aSize-1; i>=0; --i) {
00511         if (this->key[i] != compKey.key[i]) {
00512             // XOR first differing limb for easy counting of the bits:
00513             mp_limb_t d = this->key[i] ^ compKey.key[i];
00514             if (msb) d <<= ( GMP_LIMB_BITS - (keyLength % GMP_LIMB_BITS) );
00515             for (j = GMP_LIMB_BITS-1; d >>= 1; --j);
00516             length += j;
00517             break;
00518         }
00519         length += GMP_LIMB_BITS;
00520         msb = false;
00521     }
00522 
00523     return length / bitsPerDigit;
00524 }

void OverlayKey::test (  )  [static]

A pseudo regression test method.

Outputs report to standard output.

Definition at line 689 of file OverlayKey.cc.

00690 {
00691     // add test
00692     cout << endl << "--- Add test ..." << endl;
00693     OverlayKey key = 123456789;
00694     cout << "    key=" << key << endl;
00695     cout << "    key += 987654321 = " << (key+=987654321) << endl;
00696     cout << "    prefix++  : " << (++key) << endl;
00697     cout << "    postfix++ : " << (key++) << endl;
00698     cout << "    key=" << key << endl;
00699 
00700     OverlayKey k1 = 256, k2 = 10, k3 = 3;
00701 
00702     // compare test
00703     cout << endl << "--- Compare test ..." << endl;
00704     cout << "    256 < 10 = "<< (k1 < k2) << " k1="<<k1<<endl;
00705     cout << "    256 > 10 = "<< (k1 > k2) << " k2="<<k2<<endl;
00706 
00707     cout << "    10 isBetween(3, 256)=" << k2.isBetween(k3, k1) << endl;
00708     cout << "    3 isBetween(10, 256)=" << k3.isBetween(k2, k1) << endl;
00709     cout << "    256 isBetween(10, 256)=" << k1.isBetween(k2, k1) << endl;
00710     cout << "    256 isBetweenR(10, 256)=" << k1.isBetweenR(k2, k1) << endl;
00711     cout << "    max isBetween(max-1,0)=" << OverlayKey::getMax().isBetween(
00712                                                                          OverlayKey::getMax()-1, OverlayKey::ZERO) << endl;
00713     cout << "    max-1 isBetween(max,1)=" << (OverlayKey::getMax()-1).isBetween(
00714                                                                              OverlayKey::getMax(), OverlayKey::ONE) << endl;
00715     cout << "    max-1 isBetweenL(max-1,1)=" << (OverlayKey::getMax()-1).
00716         isBetweenL(OverlayKey::getMax()-1, OverlayKey::ONE) << endl;
00717     cout << "    1 isBetweenL(max-1,1)=" << (OverlayKey::ONE).isBetweenL(
00718                                                                          OverlayKey::getMax()-1, OverlayKey::ONE) << endl;
00719     cout << "    1 isBetweenR(max-1,1)=" << OverlayKey::ONE.isBetweenR(
00720                                                                        OverlayKey::getMax()-1, OverlayKey::ONE) << endl;
00721     cout << "    1 isBetween(max-1,1)=" << OverlayKey::ONE.isBetween(
00722                                                                      OverlayKey::getMax()-1, OverlayKey::ONE) << endl;
00723     cout << "    1 isBetween(max-1,0)=" << OverlayKey::ONE.isBetween(
00724                                                                      OverlayKey::getMax()-1, OverlayKey::ZERO) << endl;
00725     cout << "    256 sharedPrefixLength(3)=" << k1.sharedPrefixLength(k3)
00726          << endl;
00727     cout << "    256 sharedPrefixLength(256)=" << k1.sharedPrefixLength(k1)
00728          << endl;
00729 
00730     // wrap around test
00731     cout << endl << "--- Warp around test ..." << endl;
00732 
00733     k1 = OverlayKey::getMax();
00734     cout << "k1=max= " << k1.toString(16) << endl;
00735     cout << "k1+1 = " << (k1 + 1).toString(16) << endl;
00736     cout << "k1+2 = " << (k1 + 2).toString(16) << endl;
00737 
00738     k1 = OverlayKey::ZERO;
00739     cout << "k1=0= " << k1.toString(16) << endl;
00740     cout << "k1-1 = " << (k1 - 1).toString(16) << endl;
00741     cout << "k1-2 = " << (k1 - 2).toString(16) << endl;
00742 
00743     cout << "max > ONE=" << (OverlayKey::getMax() > OverlayKey::ONE) << endl;
00744     cout << "max < ONE=" << (OverlayKey::getMax() < OverlayKey::ONE) << endl;
00745 
00746     // distance test
00747     cout << endl << "--- Distance test ..." << endl;
00748 
00749     cout << "KeyRingMetric::distance(1, max)="
00750          <<  KeyRingMetric().distance(OverlayKey::ONE, OverlayKey::getMax()) << endl;
00751     cout << "KeyUniRingMetric::distance(1, max)="
00752          <<  KeyUniRingMetric().distance(OverlayKey::ONE, OverlayKey::getMax()) << endl;
00753     cout << "KeyRingMetric::distance(max, 1)="
00754          <<  KeyRingMetric().distance(OverlayKey::getMax(), OverlayKey::ONE) << endl;
00755     cout << "KeyUniRingMetric::distance(max, 1)="
00756          <<  KeyUniRingMetric().distance(OverlayKey::getMax(), OverlayKey::ONE) << endl;
00757 
00758     // suffix and log2 test
00759     cout << endl << "--- RandomSuffix and log2 test ..." << endl;
00760     k1 = OverlayKey::ZERO;
00761     for (uint32_t i=0; i<k1.getLength(); i++) {
00762         k2=k1.randomSuffix(i);
00763         cout << "    " << k2.toString(16) << " log2=" << k2.log_2() << endl;
00764     }
00765     cout << endl << "--- RandomPrefix and log2 test ..." << endl;
00766     k1 = OverlayKey::getMax();
00767     for (uint32_t i=0; i<k1.getLength(); i++) {
00768         k2=k1.randomPrefix(i);
00769         cout << "    " << k2.toString(16) << " log2=" << k2.log_2() << endl;
00770     }
00771 
00772     cout << endl << "--- pow2 test..." << endl;
00773     for (uint32_t i=0; i<k1.getLength(); i++) {
00774         k2=pow2(i);
00775         cout << " 2^" << i << " = " << k2.toString(16) << "   log2="
00776              << k2.log_2() << endl;
00777     }
00778 
00779     cout << endl << "--- Bits test ..." << endl << "    ";
00780     const char* BITS[] = { "000","001","010","011","100","101","110","111" };
00781     k1 = OverlayKey::random();
00782     for (int i=k1.getLength()-1; i>=0; i--)
00783         cout << k1[i];
00784     cout << " = " << endl << "    ";
00785     for (int i=k1.getLength()-3; i>=0; i-=3)
00786         cout << BITS[k1.getBitRange(i,3)];
00787     cout << endl;
00788 
00789     cout << endl << "--- SHA1 test ... (verified with test vectors)" << endl;
00790     cout << "    Empty string: " << OverlayKey::sha1("").toString(16)
00791          << " = da39a3ee5e6b4b0d3255bfef95601890afd80709" << endl;
00792     cout << "    'Hello World' string: "
00793          << OverlayKey::sha1("Hello World").toString(16)
00794          << " = 0a4d55a8d778e5022fab701977c5d840bbc486d0" << endl;
00795 }

double OverlayKey::toDouble (  )  const

Definition at line 442 of file OverlayKey.cc.

00443 {
00444     double result = 0;
00445     uint8_t range = 32, length = getLength();
00446     for (uint8_t i = 0; i < length; i += 32) {
00447         /*std::cout << (int)i << " "
00448                   << getBitRange(i, 32) << " "
00449                   << (getBitRange(i, 32) * pow(2, i + 1)) << ", ";*/
00450         if ((length - i) < 32) range = length - i;
00451         result += (getBitRange(i, range) * pow(2, i));
00452     }
00453     //std::cout << result << " " << std::endl;
00454     return result;
00455 }

std::string OverlayKey::toString ( uint32_t  base = 16  )  const

Returns a string representation of this key.

Returns:
String representation of this key

Definition at line 163 of file OverlayKey.cc.

Referenced by IterativeLookup::addSibling(), Quon::addSite(), BasePastry::baseInit(), BaseOverlay::bindToPort(), BaseApp::callRoute(), BaseOverlay::callUpdate(), Vast::changeState(), Quon::changeState(), oversim::Chord::changeState(), Pastry::checkProxCache(), oversim::Chord::closestPreceedingNode(), Nps::coordsReqRpcResponse(), Quon::deleteSite(), KBRTestApp::deliver(), Broose::displayBucketState(), Bamboo::doLocalTuning(), Pastry::doRoutingTableMaintenance(), Pastry::doSecondStage(), BaseOverlay::findNodeRpc(), oversim::Koorde::findStartKey(), CoordBasedRouting::getEuclidianDistanceByKeyAndCoords(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleAdoptChildResponse(), Vast::handleAppMessage(), Quon::handleAppMessage(), BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), Pastry::handleFailedNode(), CBRDHT::handleGetCAPIRequest(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), KBRTestApp::handleLookupResponse(), BootstrapList::handleLookupResponse(), XmlRpcInterface::handleMessage(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), PubSubMMOG::handleMoveMessage(), Vast::handleNodeLeaveNotification(), PubSubMMOG::handlePingCall(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), CBRDHT::handlePutCAPIRequest(), BasePastry::handleRequestMessage(), oversim::Koorde::handleRpcCall(), oversim::Chord::handleRpcCall(), oversim::Chord::handleRpcNotifyResponse(), Scribe::handleRpcResponse(), PubSubMMOG::handleRpcResponse(), oversim::Koorde::handleRpcResponse(), KBRTestApp::handleRpcResponse(), oversim::Chord::handleRpcResponse(), Broose::handleRpcResponse(), BootstrapList::handleRpcResponse(), PubSubMMOG::handleRpcTimeout(), PubSubLobby::handleRpcTimeout(), oversim::Koorde::handleRpcTimeout(), Kademlia::handleRpcTimeout(), oversim::Chord::handleRpcTimeout(), Broose::handleRpcTimeout(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), Scribe::handleTimerEvent(), Pastry::handleTimerEvent(), DHTTestApp::handleTimerEvent(), DHT::handleTimerEvent(), CBRDHT::handleTimerEvent(), Bamboo::handleTimerEvent(), Vast::handleUDPMessage(), Quon::handleUDPMessage(), Pastry::handleUDPMessage(), Bamboo::handleUDPMessage(), Scribe::handleUpperMessage(), SimpleGameClient::initializeApp(), BaseRpc::internalHandleRpcMessage(), Kademlia::isSiblingFor(), MessageObserver::leftGroup(), IterativeLookup::lookup(), SendToKeyListener::lookupFinished(), BaseOverlay::lookupRpc(), Pastry::mergeState(), BasePastry::newLeafs(), operator<<(), BrooseBucket::output(), P2pns::p2pnsRegisterRpc(), BasePastry::pingNodes(), Pastry::pingResponse(), oversim::Chord::pingResponse(), BasePastry::pingResponse(), oversim::Chord::pingTimeout(), BasePastry::pingTimeout(), BasePastry::proxCallback(), Quon::purgeSites(), BaseOverlay::route(), Vast::sendDiscardNode(), Vast::sendMessage(), Quon::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), IterativePathLookup::sendRpc(), BasePastry::sendStateTables(), Vast::sendToApp(), Quon::sendToApp(), BaseOverlay::sendToKey(), PubSubMMOG::startTimer(), IterativeLookup::stop(), Scribe::subscribeToGroup(), test(), DHT::update(), NeighborCache::updateNcsInfo(), NeighborCache::updateNode(), and Quon::updateThisSite().

00164 {
00165     if ((base != 2) && (base != 16)) {
00166         throw cRuntimeError("OverlayKey::OverlayKey(): Invalid base!");
00167     }
00168 
00169     if (isUnspec)
00170         return std::string("<unspec>");
00171     else {
00172         char temp[MAX_KEYLENGTH+1];
00173 
00174         if (base==16) {
00175             int k=0;
00176             for (int i=(keyLength-1)/4; i>=0; i--, k++)
00177                 temp[k] = HEX[this->getBitRange
00178                               (4*i,4)];
00179 
00180             temp[k] = 0;
00181             return std::string((const char*)temp);
00182         } else if (base==2) {
00183             int k=0;
00184             for (int i=keyLength-1; i>=0; i-=1, k++)
00185                 temp[k] = HEX[this->getBit(i)];
00186             temp[k] = 0;
00187             return std::string((const char*)temp);
00188         } else {
00189             throw cRuntimeError("OverlayKey::OverlayKey(): Invalid base!");
00190         }
00191 
00192 // the following native libgmp code doesn't work with leading zeros
00193 #if 0
00194         mp_size_t last = mpn_get_str((unsigned char*)temp, base,
00195                                      (mp_limb_t*)this->key, aSize);
00196         for (int i=0; i<last; i++) {
00197             temp[i] = HEX[temp[i]];
00198         }
00199         temp[last] = 0;
00200         return std::string((const char*)temp);
00201 #endif
00202 
00203     }
00204 }

void OverlayKey::trim (  )  [inline, private]

trims key after key operations

Definition at line 802 of file OverlayKey.cc.

Referenced by getMax(), operator+=(), operator-=(), operator<<(), operator>>(), operator~(), OverlayKey(), random(), randomPrefix(), randomSuffix(), and sha1().

00803 {
00804     key[aSize-1] &= GMP_MSB_MASK;
00805 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const OverlayKey c 
) [friend]

Common stdc++ console output method.

Definition at line 621 of file OverlayKey.cc.

00622 {
00623     os << c.toString(16);
00624     return os;
00625 };


Member Data Documentation

uint32_t OverlayKey::aSize [static, private]
Initial value:
 OverlayKey::keyLength / (8*sizeof(mp_limb_t)) +
    (OverlayKey::keyLength % (8*sizeof(mp_limb_t))
     != 0 ? 1 : 0)

number of needed machine words to hold the key

Definition at line 482 of file OverlayKey.h.

Referenced by clear(), compareTo(), getMax(), log_2(), operator&(), operator+=(), operator-=(), operator<<(), operator=(), operator>>(), operator^(), operator|(), operator~(), OverlayKey(), random(), randomPrefix(), setKeyLength(), sha1(), sharedPrefixLength(), toString(), and trim().

mp_limb_t OverlayKey::GMP_MSB_MASK [static, private]
Initial value:
 (OverlayKey::keyLength % GMP_LIMB_BITS)
    != 0 ? (((mp_limb_t)1 << (OverlayKey::keyLength % GMP_LIMB_BITS))-1)
    : (mp_limb_t) - 1

bits to fill up if key does not exactly fit in one or more machine words

Definition at line 483 of file OverlayKey.h.

Referenced by setKeyLength(), and trim().

bool OverlayKey::isUnspec [private]
mp_limb_t OverlayKey::key[MAX_KEYLENGTH/(8 *sizeof(mp_limb_t))+(MAX_KEYLENGTH%(8 *sizeof(mp_limb_t))!=0?1:0)] [private]
uint32_t OverlayKey::keyLength = MAX_KEYLENGTH [static, private]

actual length of the key

Definition at line 481 of file OverlayKey.h.

Referenced by getBitRange(), getLength(), pow2(), setBit(), setKeyLength(), sharedPrefixLength(), and toString().

const uint32_t OverlayKey::MAX_KEYLENGTH = 160 [static, private]

maximum length of the key

Definition at line 480 of file OverlayKey.h.

Referenced by netPack(), netUnpack(), setKeyLength(), and toString().

const OverlayKey OverlayKey::ONE [static]
const OverlayKey OverlayKey::ZERO [static]

OverlayKey with key initialized as 0.

Definition at line 54 of file OverlayKey.h.

Referenced by operator<<(), operator>>(), pow2(), random(), and test().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:18 2010 for OverSim by  doxygen 1.6.3