[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Dec 20 13:25:16 CST 2011
branch "master" has been updated
via fb4c184ad83d54886cfe7c50f01e2fb726592a8c (commit)
via 71b8947e8a8c78340a498139339e3940280078bd (commit)
via a19f5bae3e04bba3c314643a66e8cf94545cf57f (commit)
via 3dcea8b184feec0f4e8b6f45835135c2d9d00fa8 (commit)
via 0d797e41516ab19f437456fe7714425d441382d3 (commit)
via 9a5e2f42a121488eb42ae79b59856d0481bf459c (commit)
from 44a2f27c3a9ed47cb881c88c02ea6f91b3ee3084 (commit)
Summary of changes:
.../SipSessionManager/SipStateReplicationIf.ice | 2 +-
src/PJSipRegistrarModule.cpp | 78 ++++++++++++--------
src/PJSipRegistrarModule.h | 7 +-
src/PJSipRegistrarModuleConstruction.cpp | 7 +--
src/SipRegistrarListener.cpp | 2 +-
src/SipStateReplicatorListener.cpp | 6 +-
6 files changed, 55 insertions(+), 47 deletions(-)
- Log -----------------------------------------------------------------
commit fb4c184ad83d54886cfe7c50f01e2fb726592a8c
Merge: 44a2f27 71b8947
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Dec 20 13:14:11 2011 -0600
Merge branch 'registrar-bugs'
commit 71b8947e8a8c78340a498139339e3940280078bd
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Dec 19 11:47:58 2011 -0600
Use proper priority for the registrar module.
diff --git a/src/PJSipRegistrarModuleConstruction.cpp b/src/PJSipRegistrarModuleConstruction.cpp
index a42e6ee..47754f0 100644
--- a/src/PJSipRegistrarModuleConstruction.cpp
+++ b/src/PJSipRegistrarModuleConstruction.cpp
@@ -86,12 +86,7 @@ PJSipRegistrarModule::PJSipRegistrarModule(
{
registrarModule = this;
mModule.name = pj_str(registrarModuleName);
- // This is the highest priority module. We do this
- // so that on outgoing messages, the transport information
- // will have been filled in by the transport layer. This way
- // what we log is exactly the same as what goes out over the
- // wire.
- mModule.priority = 0;
+ mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
mModule.load = registrarLoad;
mModule.start = registrarStart;
mModule.stop = registrarStop;
commit a19f5bae3e04bba3c314643a66e8cf94545cf57f
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Dec 14 17:36:12 2011 -0600
Address review feedback
* Use a const_iterator where I can.
* Change the equality operators back to how they were. Turns out that I did not
need to alter them at all. The '*' comparison only needed to be used in one place
and it's a place I had failed to alter.
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index c8447b8..99704d1 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -98,12 +98,12 @@ BindingWrapper::BindingWrapper(
bool BindingWrapper::operator==(const BindingWrapper& rhs)
{
- return (mBinding->contact == rhs.mBinding->contact) || rhs.mBinding->contact == "*" || mBinding->contact == "*";
+ return (mBinding->contact == rhs.mBinding->contact);
}
bool BindingWrapper::operator==(const BindingPtr& rhs)
{
- return (mBinding->contact == rhs->contact) || rhs->contact == "*" || mBinding->contact == "*";
+ return (mBinding->contact == rhs->contact);
}
void BindingWrapper::cancelRegistrationExpiration()
@@ -638,7 +638,7 @@ BindingWrapperSeq::iterator PJSipRegistrarModule::findMatchingBinding(pjsip_cont
for (BindingWrapperSeq::iterator iter = bindings.begin(); iter != bindings.end(); ++iter)
{
lg(Debug) << "Comparing REGISTER contact " << contactURIStr << " with binding contact " << (*iter)->mBinding->contact;
- if (contactURIStr == (*iter)->mBinding->contact)
+ if (contactURIStr == (*iter)->mBinding->contact || contactURIStr == "*")
{
lg(Debug) << "Found matching binding " << (*iter)->mBinding->contact;
return iter;
commit 3dcea8b184feec0f4e8b6f45835135c2d9d00fa8
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Dec 8 15:59:56 2011 -0600
s/BindingDict/BindingsDict/g
diff --git a/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice b/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
index f9eab87..4e3467d 100644
--- a/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
@@ -179,7 +179,7 @@ module V1
/**
* The bindings whose states are being set/removed
*/
- AsteriskSCF::SIP::Registration::V1::BindingDict bindings;
+ AsteriskSCF::SIP::Registration::V1::BindingsDict bindings;
/**
* In the case of setting state, this distinguishes if
* the bindings are new. If not, then the bindings are
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index 188d682..c8447b8 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -243,12 +243,12 @@ public:
void execute()
{
- BindingDict returnedBindings;
+ BindingsDict returnedBindings;
//XXX
//This is suboptimal. What may work better is to maintain
//parallel maps of BindingWrappers and Bindings so that
//we can quickly return the appropriate information instead of
- //having to construct a BindingDict on each call.
+ //having to construct a BindingsDict on each call.
BindingWrapperDict& regBindings = mRegistrar->getBindings();
for (BindingWrapperDict::iterator iter = regBindings.begin();
@@ -360,7 +360,7 @@ ContactDict RegistrarI::createContactDict(const BindingWrapperDict& bindings)
return dict;
}
-BindingDict RegistrarI::createBindingDict(const std::string& aor, const BindingWrapperSeq& bindings)
+BindingsDict RegistrarI::createBindingsDict(const std::string& aor, const BindingWrapperSeq& bindings)
{
BindingSeq returnedBindings;
for (BindingWrapperSeq::const_iterator seqIter = bindings.begin();
@@ -368,7 +368,7 @@ BindingDict RegistrarI::createBindingDict(const std::string& aor, const BindingW
{
returnedBindings.push_back((*seqIter)->mBinding);
}
- BindingDict dict;
+ BindingsDict dict;
dict.insert(make_pair(aor, returnedBindings));
return dict;
}
@@ -412,7 +412,7 @@ public:
{
if (!mNewBindings.empty())
{
- BindingDict newDict = mRegistrar->createBindingDict(mAOR, mNewBindings);
+ BindingsDict newDict = mRegistrar->createBindingsDict(mAOR, mNewBindings);
SipRegistrarStateItemPtr newItem(new SipRegistrarStateItem(mAOR, mAOR, newDict, true));
SipStateItemSeq items;
items.push_back(newItem);
@@ -421,7 +421,7 @@ public:
if (!mExistingBindings.empty())
{
- BindingDict existingDict = mRegistrar->createBindingDict(mAOR, mExistingBindings);
+ BindingsDict existingDict = mRegistrar->createBindingsDict(mAOR, mExistingBindings);
SipRegistrarStateItemPtr existingItem(new SipRegistrarStateItem(mAOR, mAOR, existingDict, false));
SipStateItemSeq items;
items.push_back(existingItem);
@@ -430,7 +430,7 @@ public:
if (!mRemovedBindings.empty())
{
- BindingDict removedDict = mRegistrar->createBindingDict(mAOR, mRemovedBindings);
+ BindingsDict removedDict = mRegistrar->createBindingsDict(mAOR, mRemovedBindings);
SipRegistrarStateItemPtr removedItem(new SipRegistrarStateItem(mAOR, mAOR, removedDict, false));
SipStateItemSeq items;
items.push_back(removedItem);
diff --git a/src/PJSipRegistrarModule.h b/src/PJSipRegistrarModule.h
index d64ec6d..0d5d4e4 100644
--- a/src/PJSipRegistrarModule.h
+++ b/src/PJSipRegistrarModule.h
@@ -77,7 +77,7 @@ public:
BindingWrapperSeq& bindings);
- AsteriskSCF::SIP::Registration::V1::BindingDict createBindingDict(const std::string& aor, const BindingWrapperSeq& bindings);
+ AsteriskSCF::SIP::Registration::V1::BindingsDict createBindingsDict(const std::string& aor, const BindingWrapperSeq& bindings);
AsteriskSCF::SIP::Registration::V1::ContactDict createContactDict(const BindingWrapperDict& bindings);
std::vector<AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx>& getListeners();
diff --git a/src/SipStateReplicatorListener.cpp b/src/SipStateReplicatorListener.cpp
index 7f5e01b..1a0ff69 100644
--- a/src/SipStateReplicatorListener.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -111,7 +111,7 @@ public:
const PJSipRegistrarModulePtr& regModule,
const SipRegistrarStateItemPtr& regItem)
{
- for (BindingDict::iterator dictIter = regItem->bindings.begin();
+ for (BindingsDict::iterator dictIter = regItem->bindings.begin();
dictIter != regItem->bindings.end(); ++dictIter)
{
BindingSeq bindings = dictIter->second;
@@ -217,7 +217,7 @@ public:
{
//For new registrations, we need to create a sequence of BindingWrappers and call the registrar's
//addAndRemoveBindings() function.
- for (BindingDict::iterator dictIter = regItem->bindings.begin();
+ for (BindingsDict::iterator dictIter = regItem->bindings.begin();
dictIter != regItem->bindings.end(); ++dictIter)
{
BindingSeq bindings = dictIter->second;
@@ -235,7 +235,7 @@ public:
void setExistingRegistrationState(const PJSipRegistrarModulePtr& regModule, const SipRegistrarStateItemPtr& regItem)
{
- for (BindingDict::iterator dictIter = regItem->bindings.begin();
+ for (BindingsDict::iterator dictIter = regItem->bindings.begin();
dictIter != regItem->bindings.end(); ++dictIter)
{
BindingWrapperSeq& bindings = regModule->getRegistrar()->getAORBindingWrappers(dictIter->first);
commit 0d797e41516ab19f437456fe7714425d441382d3
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Dec 8 15:19:18 2011 -0600
ASTSCF-400: Use an IceUtil::TimerTask in the registrar.
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index e7494ab..188d682 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -42,12 +42,17 @@ namespace AsteriskSCF
namespace SipSessionManager
{
-class RegistrationExpired : public Work
+class RegistrationExpired : public Work, public IceUtil::TimerTask
{
public:
RegistrationExpired(const BindingWrapperPtr& wrapper)
: mWrapper(wrapper) { }
+ void runTimerTask()
+ {
+ mWrapper->mRegModule->getRegistrar()->getQueue()->enqueueWork(this);
+ }
+
void execute()
{
lg(Debug) << "Detected expiration of binding " << mWrapper->mBinding->contact;
@@ -79,32 +84,18 @@ private:
BindingWrapperPtr mWrapper;
};
-static void registrationExpired(pj_timer_heap_t *, struct pj_timer_entry *entry)
-{
- BindingWrapper *wrapper = static_cast<BindingWrapper *>(entry->user_data);
- wrapper->mRegModule->getRegistrar()->getQueue()->enqueueWork(new RegistrationExpired(wrapper));
-}
-
-static int expirationId;
-
BindingWrapper::BindingWrapper(
int expiration,
const BindingPtr& binding,
const PJSipRegistrarModulePtr& regModule,
pjsip_endpoint *endpt,
const std::string& aor)
- : mRegModule(regModule), mBinding(binding), mEndpoint(endpt), mAOR(aor)
+ : mRegModule(regModule), mBinding(binding), mEndpoint(endpt), mAOR(aor), mTimer(new IceUtil::Timer)
{
- pj_timer_entry_init(&mEntry, expirationId++, this, registrationExpired);
lg(Debug) << "Scheduling binding " << mBinding->contact << " for expiration in " << expiration << " seconds.";
scheduleRegistrationExpiration(expiration);
}
-BindingWrapper::~BindingWrapper()
-{
- cancelRegistrationExpiration();
-}
-
bool BindingWrapper::operator==(const BindingWrapper& rhs)
{
return (mBinding->contact == rhs.mBinding->contact) || rhs.mBinding->contact == "*" || mBinding->contact == "*";
@@ -117,13 +108,14 @@ bool BindingWrapper::operator==(const BindingPtr& rhs)
void BindingWrapper::cancelRegistrationExpiration()
{
- pjsip_endpt_cancel_timer(mEndpoint, &mEntry);
+ mTimer->cancel(mTimerTask);
+ mTimerTask = 0;
}
void BindingWrapper::scheduleRegistrationExpiration(int expiration)
{
- pj_time_val delay = {expiration, 0};
- pjsip_endpt_schedule_timer(mEndpoint, &mEntry, &delay);
+ mTimerTask = new RegistrationExpired(this);
+ mTimer->schedule(mTimerTask, IceUtil::Time::seconds(expiration));
}
class UpdateBinding : public Work
@@ -344,6 +336,7 @@ void RegistrarI::removeBinding(BindingWrapperSeq& currentBindings, BindingWrappe
{
lg(Debug) << "Removing binding " << wrapper->mBinding->contact;
currentBindings.erase(std::remove(currentBindings.begin(), currentBindings.end(), wrapper), currentBindings.end());
+ wrapper->cancelRegistrationExpiration();
}
void RegistrarI::removeAOR(const std::string& aor)
@@ -707,11 +700,9 @@ public:
: mTsx(tsx), mTdata(tdata), mAOR(aor), mRegistrar(registrar) { }
void execute()
{
- lg(Debug) << "In the Response thing";
BindingWrapperSeq wrappers = mRegistrar->getAORBindingWrappers(mAOR);
for (BindingWrapperSeq::const_iterator iter = wrappers.begin(); iter != wrappers.end(); ++iter)
{
- lg(Debug) << "Should be adding contact " << (*iter)->mBinding->contact;
pjsip_contact_hdr *contact = pjsip_contact_hdr_create(mTdata->pool);
contact->uri = pjsip_parse_uri(mTdata->pool, (char*) (*iter)->mBinding->contact.c_str(), (*iter)->mBinding->contact.size(), PJSIP_URI_IN_FROMTO_HDR);
contact->expires = (*iter)->mBinding->expiration - time(0);
diff --git a/src/PJSipRegistrarModule.h b/src/PJSipRegistrarModule.h
index b86edf2..d64ec6d 100644
--- a/src/PJSipRegistrarModule.h
+++ b/src/PJSipRegistrarModule.h
@@ -177,8 +177,6 @@ public:
pjsip_endpoint *endpt,
const std::string& aor);
- ~BindingWrapper();
-
/**
* Called when a binding expires.
*/
@@ -204,8 +202,9 @@ public:
PJSipRegistrarModulePtr mRegModule;
AsteriskSCF::SIP::Registration::V1::BindingPtr mBinding;
pjsip_endpoint *mEndpoint;
- pj_timer_entry mEntry;
const std::string mAOR;
+ IceUtil::TimerPtr mTimer;
+ IceUtil::TimerTaskPtr mTimerTask;
};
void registrarAuthTimeout(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry);
diff --git a/src/SipRegistrarListener.cpp b/src/SipRegistrarListener.cpp
index be963a2..4400925 100644
--- a/src/SipRegistrarListener.cpp
+++ b/src/SipRegistrarListener.cpp
@@ -102,7 +102,7 @@ void SipDefaultRegistrarListener::contactsRemoved(const BindingUpdateSeq& contac
for (SipEndpointSeq::iterator endpointIter = endpoints.begin();
endpointIter != endpoints.end(); ++endpointIter)
{
- lg(Debug) << "Removing contacts " << " from AoR " << iter->aor;
+ lg(Debug) << "Removing contacts from AoR " << iter->aor;
//Setting the endpoint's target address to be empty is the method we currently use
//to make the endpoint inaccessible. Once endpoints can support multiple addresses,
//it'll be a bit less hacky since we can just remove a specific contact from the list.
commit 9a5e2f42a121488eb42ae79b59856d0481bf459c
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Dec 8 11:04:21 2011 -0600
Fixes for ASTSCF-403, ASTSCF-402, and ASTSCF-401
* Add Contact header(s) to outgoing 200 OK responses
* Match a '*' contact to all stored contacts.
* Notify RegistrarListeners of bindings removed due to expiration.
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index f25624e..e7494ab 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -59,6 +59,17 @@ public:
{
registrar->removeAOR(mWrapper->mAOR);
}
+
+ BindingWrapperSeq wrappers(1, mWrapper);
+ BindingUpdateSeq removedBindingUpdateSeq(registrar->createBindingUpdateSeq(mWrapper->mAOR, wrappers));
+ std::vector<RegistrarListenerPrx>& listeners = registrar->getListeners();
+ for (std::vector<RegistrarListenerPrx>::iterator iter = listeners.begin();
+ iter != listeners.end(); ++iter)
+ {
+ lg(Debug) << "Alerting listener " << (*iter)->ice_getIdentity().name << " about removal of binding due to expiration.";
+ (*iter)->contactsRemoved(removedBindingUpdateSeq);
+ }
+
BindingWrapperSeq emptySeq;
BindingWrapperSeq toRemove;
toRemove.push_back(mWrapper);
@@ -96,12 +107,12 @@ BindingWrapper::~BindingWrapper()
bool BindingWrapper::operator==(const BindingWrapper& rhs)
{
- return mBinding->contact == rhs.mBinding->contact;
+ return (mBinding->contact == rhs.mBinding->contact) || rhs.mBinding->contact == "*" || mBinding->contact == "*";
}
bool BindingWrapper::operator==(const BindingPtr& rhs)
{
- return mBinding->contact == rhs->contact;
+ return (mBinding->contact == rhs->contact) || rhs->contact == "*" || mBinding->contact == "*";
}
void BindingWrapper::cancelRegistrationExpiration()
@@ -692,15 +703,27 @@ BindingWrapperPtr PJSipRegistrarModule::createNewBinding(pjsip_contact_hdr *cont
class Response : public Work
{
public:
- Response(pjsip_transaction *tsx, pjsip_tx_data *tdata)
- : mTsx(tsx), mTdata(tdata) { }
+ Response(pjsip_transaction *tsx, pjsip_tx_data *tdata, const std::string& aor, const RegistrarIPtr& registrar)
+ : mTsx(tsx), mTdata(tdata), mAOR(aor), mRegistrar(registrar) { }
void execute()
{
+ lg(Debug) << "In the Response thing";
+ BindingWrapperSeq wrappers = mRegistrar->getAORBindingWrappers(mAOR);
+ for (BindingWrapperSeq::const_iterator iter = wrappers.begin(); iter != wrappers.end(); ++iter)
+ {
+ lg(Debug) << "Should be adding contact " << (*iter)->mBinding->contact;
+ pjsip_contact_hdr *contact = pjsip_contact_hdr_create(mTdata->pool);
+ contact->uri = pjsip_parse_uri(mTdata->pool, (char*) (*iter)->mBinding->contact.c_str(), (*iter)->mBinding->contact.size(), PJSIP_URI_IN_FROMTO_HDR);
+ contact->expires = (*iter)->mBinding->expiration - time(0);
+ pjsip_msg_add_hdr(mTdata->msg, (pjsip_hdr*) contact);
+ }
pjsip_tsx_send_msg(mTsx, mTdata);
}
private:
pjsip_transaction *mTsx;
pjsip_tx_data *mTdata;
+ const std::string mAOR;
+ RegistrarIPtr mRegistrar;
};
bool PJSipRegistrarModule::checkAuth(pjsip_rx_data *rdata, pjsip_transaction *tsx, RequestType type)
@@ -811,7 +834,7 @@ pj_bool_t PJSipRegistrarModule::on_rx_request(pjsip_rx_data *rdata)
// our internal bindings.
pjsip_tx_data *tdata;
pjsip_endpt_create_response(tsx->endpt, rdata, 200, NULL, &tdata);
- mRegistrar->getQueue()->enqueueWork(new Response(tsx, tdata));
+ mRegistrar->getQueue()->enqueueWork(new Response(tsx, tdata, aor, mRegistrar));
replicateState(aor, existingBindings, newBindings, removedBindings);
-----------------------------------------------------------------------
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list