r3273 - trunk/libmsip/source
erik at minisip.org
erik at minisip.org
Wed May 9 14:48:45 CEST 2007
Author: erik
Date: 2007-05-09 14:21:51 +0200 (Wed, 09 May 2007)
New Revision: 3273
Modified:
trunk/libmsip/source/SipLayerTransaction.cxx
Log:
* Fixes to SipLayerTransaction routing of commands.
The default routing is very easy - it looks up the transaction ID that
consist of the branch and CSeq method, and send the command to that
transaction. If something fails we use the old way.
Modified: trunk/libmsip/source/SipLayerTransaction.cxx
===================================================================
--- trunk/libmsip/source/SipLayerTransaction.cxx 2007-05-09 12:17:35 UTC (rev 3272)
+++ trunk/libmsip/source/SipLayerTransaction.cxx 2007-05-09 12:21:51 UTC (rev 3273)
@@ -125,8 +125,8 @@
list<MRef<SipTransaction*> > ret;
map<string, MRef<SipTransaction*> >::iterator i;
for (i=transactions.begin(); i!=transactions.end(); i++){
- ret.push_back( (*i).second );
-
+ if ((*i).second->getCallId() == callid)
+ ret.push_back( (*i).second );
}
return ret;
}
@@ -139,40 +139,53 @@
#ifdef DEBUG_OUTPUT
mdbg << "SipLayerTransaction: handleCommand got: "<< c<<endl;
#endif
-
- // Find transaction based on branch parameter
- //
- string branch;
- string seqMethod;
- if (c.getType()==SipSMCommand::COMMAND_PACKET){
- branch = c.getCommandPacket()->getDestinationBranch();
- seqMethod = c.getCommandPacket()->getCSeqMethod();
+ string tid;
+ if (c.getType()==SipSMCommand::COMMAND_STRING){
+ tid = c.getCommandString().getDestinationId();
}
- bool hasBranch = (branch!="");
- bool hasSeqMethod = (seqMethod!="");
- if (!hasBranch){
- mdbg << "WARNING: SipLayerTransaction::handleCommand could not find branch parameter from packet - trying all transactions"<<end;
+ if (c.getType()==SipSMCommand::COMMAND_PACKET){
+ string branch = c.getCommandPacket()->getDestinationBranch();
+ if (branch.size()>0)
+ tid = branch + c.getCommandPacket()->getCSeqMethod();
}
-// cerr << "SipLayerTransaction: trying "<<transactions.size()<<" transactions"<<endl;
- map<string, MRef<SipTransaction*> >::iterator i;
- for (i=transactions.begin(); i!=transactions.end(); i++){
- if ( (!hasBranch || (*i).second->getBranch()== branch || seqMethod=="ACK") &&
- (!hasSeqMethod || (*i).second->getCSeqMethod()==seqMethod ||
- (seqMethod == "ACK" && (*i).second->getCSeqMethod() == "INVITE")) ){
-// cerr << "SipLayerTransaction: trying message with branch <"<<branch<<"> with transaction with branch <"<<transactions[i]->getBranch()<<">"<<endl;
- bool ret = (*i).second->handleCommand(c);
-// cerr << "SipLayerTransaction: transaction returned "<<ret<<endl;
-#ifdef DEBUG_OUTPUT
- if (!ret && hasBranch){
- mdbg << "WARNING: SipLayerTransaction: transaction did not handle message with matching branch id"<<end;
+
+ MRef<SipTransaction*> t;
+ if (tid.size()>0)
+ t = getTransaction(tid);
+
+ if (t){ // This should be the normal way to handle a command
+ bool ret = t->handleCommand(c);
+ if (ret)
+ return true;
+ }else{
+ // Fall back to try all transactions...
+ //
+ string branch;
+ string seqMethod;
+ if (c.getType()==SipSMCommand::COMMAND_PACKET){
+ branch = c.getCommandPacket()->getDestinationBranch();
+ seqMethod = c.getCommandPacket()->getCSeqMethod();
+ }
+ bool hasBranch = (branch!="");
+ bool hasSeqMethod = (seqMethod!="");
+
+ if (!hasBranch){
+ mdbg << "WARNING: SipLayerTransaction::handleCommand could not find branch parameter from packet - trying all transactions"<<end;
+ }
+
+ map<string, MRef<SipTransaction*> >::iterator i;
+ for (i=transactions.begin(); i!=transactions.end(); i++){
+ if ( (!hasBranch || (*i).second->getBranch()== branch || seqMethod=="ACK") &&
+ (!hasSeqMethod || (*i).second->getCSeqMethod()==seqMethod ||
+ (seqMethod == "ACK" && (*i).second->getCSeqMethod() == "INVITE")) ){
+ bool ret = (*i).second->handleCommand(c);
+ if (ret){
+ return true;
+ }
}
-#endif
- if (ret){
- return true;
- }
}
}
More information about the Minisip-devel
mailing list