|
reSIProcate/stack
9694
|
Represents the "via-branch" parameter of the RFC 3261 grammar. More...
#include <BranchParameter.hxx>


Represents the "via-branch" parameter of the RFC 3261 grammar.
Definition at line 26 of file BranchParameter.hxx.
Definition at line 29 of file BranchParameter.hxx.
| BranchParameter::BranchParameter | ( | ParameterTypes::Type | type, |
| ParseBuffer & | pb, | ||
| const std::bitset< 256 > & | terminators | ||
| ) |
Definition at line 21 of file BranchParameter.cxx.
References resip::Data::base64decode(), resip::ParseBuffer::data(), resip::Data::empty(), resip::ParseBuffer::end(), resip::Symbols::EQUALS, resip::Random::getRandomHex(), resip::Symbols::MagicCookie, mClientData, mHasMagicCookie, mInteropMagicCookie, mIsMyBranch, mSigcompCompartment, mTransactionId, mTransportSeq, resip::ParseBuffer::position(), resip::Symbols::resipCookie, resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipN(), resip::ParseBuffer::skipToChar(), resip::ParseBuffer::skipToOneOf(), resip::ParseBuffer::skipWhitespace(), strncasecmp(), resip::Data::toBitset(), and resip::ParseBuffer::uInt32().
Referenced by clone(), and decode().
: Parameter(type), mHasMagicCookie(false), mIsMyBranch(false), mTransactionId(), mTransportSeq(1), mClientData(), mInteropMagicCookie(0), mSigcompCompartment() { try { pb.skipWhitespace(); pb.skipChar(Symbols::EQUALS[0]); pb.skipWhitespace(); if(memcmp(pb.position(), Symbols::MagicCookie, 7) == 0) { mHasMagicCookie=true; pb.skipN(7); } // !bwc! This no-case comparison is expensive; only do it if the case- // sensitive comparison fails. else if(strncasecmp(pb.position(), Symbols::MagicCookie, 7) == 0) { mHasMagicCookie=true; mInteropMagicCookie = new Data(pb.position(), 7); pb.skipN(7); } const char* start = pb.position(); static std::bitset<256> delimiter=Data::toBitset("\r\n\t ;=?>"); if (mHasMagicCookie && (pb.end() - start > 8) && // look for prefix cookie (maybe make this bigger?) memcmp(start, Symbols::resipCookie, 8) == 0) { // ?bwc? Wrap this stuff in try/catch, just in case of false positives? const char* curr=start; mIsMyBranch = true; pb.skipN(8); mTransportSeq=pb.uInt32(); curr=pb.skipChar('-'); pb.skipToChar('-'); Data encoded; pb.data(encoded, curr); if(!encoded.empty()) { // !bwc! Expensive! Also, Base64 isn't case-insensitive. mClientData = encoded.base64decode(); } curr=pb.skipChar('-'); pb.skipToChar('-'); pb.data(encoded,curr); if(!encoded.empty()) { // !bwc! Expensive! Also, Base64 isn't case-insensitive. mSigcompCompartment = encoded.base64decode(); } start=pb.skipChar('-'); } pb.skipToOneOf(delimiter); pb.data(mTransactionId, start); } catch(resip::ParseException& e) { mTransactionId=Random::getRandomHex(8); throw e; } }

| BranchParameter::BranchParameter | ( | ParameterTypes::Type | type | ) | [explicit] |
Definition at line 98 of file BranchParameter.cxx.
: Parameter(type), mHasMagicCookie(true), mIsMyBranch(true), mTransactionId(Random::getRandomHex(8)), mTransportSeq(1), mInteropMagicCookie(0), mSigcompCompartment() { }
| BranchParameter::~BranchParameter | ( | ) |
Definition at line 128 of file BranchParameter.cxx.
References mInteropMagicCookie.
{
delete mInteropMagicCookie;
}
| BranchParameter::BranchParameter | ( | const BranchParameter & | other | ) |
Definition at line 109 of file BranchParameter.cxx.
References mInteropMagicCookie.
: Parameter(other), mHasMagicCookie(other.mHasMagicCookie), mIsMyBranch(other.mIsMyBranch), mTransactionId(other.mTransactionId), mTransportSeq(other.mTransportSeq), mClientData(other.mClientData), mSigcompCompartment(other.mSigcompCompartment) { if (other.mInteropMagicCookie) { mInteropMagicCookie = new Data(*other.mInteropMagicCookie); } else { mInteropMagicCookie = 0; } }
| Data & BranchParameter::clientData | ( | ) |
| const Data & BranchParameter::clientData | ( | ) | const |
| Parameter * BranchParameter::clone | ( | ) | const [virtual] |
Implements resip::Parameter.
Definition at line 252 of file BranchParameter.cxx.
References BranchParameter().
{
return new BranchParameter(*this);
}

| static Parameter* resip::BranchParameter::decode | ( | ParameterTypes::Type | type, |
| ParseBuffer & | pb, | ||
| const std::bitset< 256 > & | terminators, | ||
| PoolBase * | pool | ||
| ) | [inline, static] |
Definition at line 57 of file BranchParameter.hxx.
References BranchParameter().
{
return new (pool) BranchParameter(type, pb, terminators);
}

| EncodeStream & BranchParameter::encode | ( | EncodeStream & | stream | ) | const [virtual] |
Implements resip::Parameter.
Definition at line 258 of file BranchParameter.cxx.
References resip::Data::base64encode(), resip::Symbols::DASH, resip::Data::empty(), resip::Symbols::EQUALS, resip::Parameter::getName(), resip::Symbols::MagicCookie, mClientData, mHasMagicCookie, mInteropMagicCookie, mIsMyBranch, mSigcompCompartment, mTransactionId, mTransportSeq, and resip::Symbols::resipCookie.
Referenced by main().
{
stream << getName() << Symbols::EQUALS;
if (mHasMagicCookie)
{
if (mInteropMagicCookie)
{
stream << *mInteropMagicCookie;
}
else
{
stream << Symbols::MagicCookie;
}
}
if (mIsMyBranch)
{
stream << Symbols::resipCookie;
stream << mTransportSeq;
stream << Symbols::DASH;
if(!mClientData.empty()) // base64encode() makes copies
{
// !bwc! We should be using hex encoding; branch params are supposed to
// be case-insensitive.
stream << mClientData.base64encode(true/*safe URL*/);
}
stream << Symbols::DASH;
if(!mSigcompCompartment.empty()) // base64encode() makes copies
{
// !bwc! We should be using hex encoding; branch params are supposed to
// be case-insensitive.
stream << mSigcompCompartment.base64encode(true);
}
stream << Symbols::DASH;
}
stream << mTransactionId;
return stream;
}

| Data BranchParameter::getSigcompCompartment | ( | ) | const |
Definition at line 225 of file BranchParameter.cxx.
References mSigcompCompartment.
{
return mSigcompCompartment;
}
| const Data & BranchParameter::getTransactionId | ( | ) | const |
Definition at line 180 of file BranchParameter.cxx.
References mTransactionId.
Referenced by main().
{
return mTransactionId;
}
| bool BranchParameter::hasMagicCookie | ( | ) | const |
Definition at line 174 of file BranchParameter.cxx.
References mHasMagicCookie.
Referenced by main().
{
return mHasMagicCookie;
}
| void BranchParameter::incrementTransportSequence | ( | ) |
Definition at line 186 of file BranchParameter.cxx.
References mIsMyBranch, and mTransportSeq.
{
assert(mIsMyBranch);
mTransportSeq++;
}
| BranchParameter & BranchParameter::operator= | ( | const BranchParameter & | other | ) |
Definition at line 134 of file BranchParameter.cxx.
References mClientData, mHasMagicCookie, mInteropMagicCookie, mIsMyBranch, mSigcompCompartment, mTransactionId, and mTransportSeq.
{
if (this != &other)
{
mHasMagicCookie = other.mHasMagicCookie;
mIsMyBranch = other.mIsMyBranch;
mTransactionId = other.mTransactionId;
mTransportSeq = other.mTransportSeq;
mClientData = other.mClientData;
mSigcompCompartment = other.mSigcompCompartment;
if (other.mInteropMagicCookie)
{
delete mInteropMagicCookie;
mInteropMagicCookie = new Data(*other.mInteropMagicCookie);
}
else
{
delete mInteropMagicCookie;
mInteropMagicCookie = 0;
}
}
return *this;
}
| bool BranchParameter::operator== | ( | const BranchParameter & | other | ) |
Definition at line 159 of file BranchParameter.cxx.
References mClientData, mHasMagicCookie, mIsMyBranch, mSigcompCompartment, mTransactionId, and mTransportSeq.
{
if (mIsMyBranch != other.mIsMyBranch ||
mHasMagicCookie != other.mHasMagicCookie ||
mTransportSeq != other.mTransportSeq ||
mTransactionId != other.mTransactionId ||
mClientData != other.mClientData ||
mSigcompCompartment != other.mSigcompCompartment)
{
return false;
}
return true;
}
| void BranchParameter::reset | ( | const Data & | transactionId = Data::Empty | ) |
Definition at line 231 of file BranchParameter.cxx.
References resip::Data::Empty, resip::Data::empty(), resip::Random::getRandomHex(), mHasMagicCookie, mInteropMagicCookie, mIsMyBranch, mSigcompCompartment, mTransactionId, and mTransportSeq.
Referenced by main().
{
mHasMagicCookie = true;
mIsMyBranch = true;
delete mInteropMagicCookie;
mInteropMagicCookie = 0;
mSigcompCompartment = Data::Empty;
mTransportSeq = 1;
if (!transactionId.empty())
{
mTransactionId = transactionId;
}
else
{
mTransactionId = Random::getRandomHex(8);
}
}

| void BranchParameter::setSigcompCompartment | ( | const Data & | id | ) |
Definition at line 208 of file BranchParameter.cxx.
References resip::Data::Empty, and mSigcompCompartment.
{
if (id.size() == 0)
{
mSigcompCompartment = Data::Empty;
}
// These will often (but not always) be UUID URNs in angle brackets;
// e.g.: <urn:uuid:fa33c72d-121f-47e8-42e2-1eb6e24aba64>
// Ideally, we would detect this, strip out everything that isn't
// hex, and convert the hex to raw data.
mSigcompCompartment = id;
}
| Type& resip::BranchParameter::value | ( | ) | [inline] |
Definition at line 72 of file BranchParameter.hxx.
{return *this;}
Data resip::BranchParameter::mClientData [private] |
Definition at line 79 of file BranchParameter.hxx.
Referenced by BranchParameter(), clientData(), encode(), operator=(), and operator==().
bool resip::BranchParameter::mHasMagicCookie [private] |
Definition at line 75 of file BranchParameter.hxx.
Referenced by BranchParameter(), encode(), hasMagicCookie(), operator=(), operator==(), and reset().
const Data* resip::BranchParameter::mInteropMagicCookie [private] |
Definition at line 81 of file BranchParameter.hxx.
Referenced by BranchParameter(), encode(), operator=(), reset(), and ~BranchParameter().
bool resip::BranchParameter::mIsMyBranch [private] |
Definition at line 76 of file BranchParameter.hxx.
Referenced by BranchParameter(), encode(), incrementTransportSequence(), operator=(), operator==(), and reset().
Definition at line 85 of file BranchParameter.hxx.
Referenced by BranchParameter(), encode(), getSigcompCompartment(), operator=(), operator==(), reset(), and setSigcompCompartment().
Data resip::BranchParameter::mTransactionId [private] |
Definition at line 77 of file BranchParameter.hxx.
Referenced by BranchParameter(), encode(), getTransactionId(), operator=(), operator==(), and reset().
unsigned int resip::BranchParameter::mTransportSeq [private] |
Definition at line 78 of file BranchParameter.hxx.
Referenced by BranchParameter(), encode(), incrementTransportSequence(), operator=(), operator==(), and reset().
1.7.5.1