Correctly deal with the packed form of calledpointcode.

Filter incoming ISUP and BICC messages by remote Point Code.
Added an inequality operator for SS7PointCode.


git-svn-id: http://voip.null.ro/svn/yate@3273 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2010-05-03 13:06:41 +00:00
parent 66c1838b1a
commit 7b9d11ccf0
2 changed files with 18 additions and 5 deletions

View File

@ -2705,7 +2705,7 @@ SignallingCall* SS7ISUP::call(SignallingMessage* msg, String& reason)
break;
}
String pc = msg->params().getValue("calledpointcode");
if (!(dest.assign(pc) && dest.pack(m_type))) {
if (!(dest.assign(pc,m_type) && dest.pack(m_type))) {
if (!m_remotePoint) {
Debug(this,DebugNote,
"Destination point code is missing (calledpointcode=%s)",pc.safe());
@ -3293,10 +3293,8 @@ bool SS7ISUP::encodeMessage(DataBlock& buf, SS7MsgISUP::Type msgType, SS7PointCo
bool SS7ISUP::receivedMSU(const SS7MSU& msu, const SS7Label& label, SS7Layer3* network, int sls)
{
if (msu.getSIF() != SS7MSU::ISUP || !hasPointCode(label.dpc())) {
DDebug(this,DebugAll,"Refusing MSU: %s",msu.getSIF()!=SS7MSU::ISUP?"not ISUP":"invalid point code");
if (msu.getSIF() != SS7MSU::ISUP || !hasPointCode(label.dpc()) || !handlesRemotePC(label.opc()))
return false;
}
// we should have at least 2 bytes CIC and 1 byte message type
const unsigned char* s = msu.getData(label.length()+1,3);
if (!s)
@ -3981,7 +3979,7 @@ SS7MSU* SS7BICC::createMSU(SS7MsgISUP::Type type, unsigned char ssf,
bool SS7BICC::receivedMSU(const SS7MSU& msu, const SS7Label& label, SS7Layer3* network, int sls)
{
if (msu.getSIF() != SS7MSU::BICC || !hasPointCode(label.dpc()))
if (msu.getSIF() != SS7MSU::BICC || !hasPointCode(label.dpc()) || !handlesRemotePC(label.opc()))
return false;
// we should have at least 4 bytes CIC and 1 byte message type
const unsigned char* s = msu.getData(label.length()+1,5);

View File

@ -3235,6 +3235,13 @@ public:
inline bool operator==(const SS7PointCode& original) const
{ return m_network == original.network() && m_cluster == original.cluster() && m_member == original.member(); }
/**
* Inequality operator
* @param original Code point to be compared with
*/
inline bool operator!=(const SS7PointCode& original) const
{ return m_network != original.network() || m_cluster != original.cluster() || m_member != original.member(); }
/**
* Check if the point code is compatible with a packing type
* @return True if the Network and Member fit in the packing format
@ -6096,6 +6103,14 @@ public:
*/
SS7PointCode* hasPointCode(const SS7PointCode& pc);
/**
* Check if this controller should handle a remote point code
* @param pc The remote point code to check
* @return True if pc matches the remote or there is no remote set
*/
inline bool handlesRemotePC(const SS7PointCode& pc) const
{ return !m_remotePoint || (pc == *m_remotePoint); }
/**
* Set a routing label to be used for outgoing messages
* @param label Routing label to set