X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Ftesting%2FTestCondition.cpp;h=ced5db69d40a583d8712babc1779c345aec943e9;hb=61f1340da3cae5159d2e3bc14fc47c6d4bf9453e;hp=a772ab0f736b060154f09f9ae0f365686d94bc6b;hpb=4c3f0a4d7e4db76996404d80c6f939548fca656f;p=anna.git diff --git a/example/diameter/launcher/testing/TestCondition.cpp b/example/diameter/launcher/testing/TestCondition.cpp index a772ab0..ced5db6 100644 --- a/example/diameter/launcher/testing/TestCondition.cpp +++ b/example/diameter/launcher/testing/TestCondition.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -21,7 +22,6 @@ // Process #include -#include const char* TestCondition::asText(const Type::_v type) @@ -34,7 +34,7 @@ bool TestCondition::exists() const throw() { if (a_type == Type::Generic) return (a_regexp != ""); else - return (a_code != "" || a_bitR != "" || a_resultCode != "" || a_sessionId != "" || a_hopByHop != "" || a_msisdn != "" || a_imsi != "" || a_serviceContextId != ""); + return (a_code != "" || a_bitR != "" || a_hopByHop != "" || a_applicationId != "" || a_sessionId != "" || a_resultCode != "" || a_msisdn != "" || a_imsi != "" || a_serviceContextId != ""); } bool operator==(const TestCondition &c1, const TestCondition &c2) throw() { @@ -47,9 +47,10 @@ bool operator==(const TestCondition &c1, const TestCondition &c2) throw() { else { if (c1.a_code != c2.a_code) return false; if (c1.a_bitR != c2.a_bitR) return false; - if (c1.a_resultCode != c2.a_resultCode) return false; - if (c1.a_sessionId != c2.a_sessionId) return false; if (c1.a_hopByHop != c2.a_hopByHop) return false; + if (c1.a_applicationId != c2.a_applicationId) return false; + if (c1.a_sessionId != c2.a_sessionId) return false; + if (c1.a_resultCode != c2.a_resultCode) return false; if (c1.a_msisdn != c2.a_msisdn) return false; if (c1.a_imsi != c2.a_imsi) return false; if (c1.a_serviceContextId != c2.a_serviceContextId) return false; @@ -61,15 +62,8 @@ bool operator==(const TestCondition &c1, const TestCondition &c2) throw() { bool TestCondition::comply(const anna::DataBlock &message/*, bool matchSessionId*/) const throw() { if (a_type == Type::Generic) { - Launcher& my_app = static_cast (anna::app::functions::getApp()); - static anna::diameter::codec::Message codecMsg(my_app.getCodecEngine()); - try { - codecMsg.decode(message); - } - catch (anna::RuntimeException &ex) { - ex.trace(); - } - + anna::diameter::codec::Message codecMsg; + try { codecMsg.decode(message); } catch (anna::RuntimeException &ex) { ex.trace(); } return codecMsg.isLike(a_regexp); } @@ -90,36 +84,45 @@ bool TestCondition::comply(const anna::DataBlock &message/*, bool matchSessionId } if (a_bitR != "") { - compare = (cid.first ? "1":"0"); + compare = (cid.second ? "1":"0"); if (a_bitR != compare) return false; } - if (a_resultCode != "") { + if (a_hopByHop != "") { try { - anna::U32 rc = anna::diameter::helpers::base::functions::getResultCode(message); - compare = anna::functions::asString(rc); + anna::diameter::HopByHop h = anna::diameter::codec::functions::getHopByHop(message); + compare = anna::functions::asString(h); } catch (anna::RuntimeException &) { return false; } - if (a_resultCode != compare) return false; + if (a_hopByHop != compare) return false; + } + + if (a_applicationId != "") { + try { + anna::diameter::ApplicationId a = anna::diameter::codec::functions::getApplicationId(message); + compare = anna::functions::asString(a); + } + catch (anna::RuntimeException &) { return false; } + if (a_applicationId != compare) return false; } //if (matchSessionId) { - if (a_sessionId != "") { - try { - compare = anna::diameter::helpers::base::functions::getSessionId(message); - } - catch (anna::RuntimeException &) { return false; } - if (a_sessionId != compare) return false; + if (a_sessionId != "") { + try { + compare = anna::diameter::helpers::base::functions::getSessionId(message); } + catch (anna::RuntimeException &) { return false; } + if (a_sessionId != compare) return false; + } //} - if (a_hopByHop != "") { + if (a_resultCode != "") { try { - anna::diameter::HopByHop h = anna::diameter::codec::functions::getHopByHop(message); - compare = anna::functions::asString(h); + anna::U32 rc = anna::diameter::helpers::base::functions::getResultCode(message); + compare = anna::functions::asString(rc); } catch (anna::RuntimeException &) { return false; } - if (a_hopByHop != compare) return false; + if (a_resultCode != compare) return false; } if (a_msisdn != "") { @@ -160,9 +163,10 @@ throw() { else { if (a_code != "") result->createAttribute("Code", atoi(a_code.c_str())); if (a_bitR != "") result->createAttribute("BitR", ((a_bitR == "1") ? "yes":"no")); + if (a_hopByHop != "") result->createAttribute("HopByHop", atoll(a_hopByHop.c_str())); + if (a_applicationId != "") result->createAttribute("ApplicationId", atoll(a_applicationId.c_str())); if (a_sessionId != "") result->createAttribute("SessionId", a_sessionId); if (a_resultCode != "") result->createAttribute("ResultCode", atoi(a_resultCode.c_str())); - if (a_hopByHop != "") result->createAttribute("HopByHop", atoll(a_hopByHop.c_str())); if (a_msisdn != "") result->createAttribute("Msisdn", a_msisdn); if (a_imsi != "") result->createAttribute("Imsi", a_imsi); if (a_serviceContextId != "") result->createAttribute("ServiceContextId", a_serviceContextId);