X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter%2Fcodec%2FMessage.cpp;fp=source%2Fdiameter%2Fcodec%2FMessage.cpp;h=4938a031e04f68c8ffe77490e2c0f3b03b850702;hb=ad7fdc865803176f1dd1696960073f616cfa3fda;hp=6f906f85fe6750a00cd38070efba59475c093a51;hpb=66ca2e4491aa9a96bb11ce3aacde339b64681761;p=anna.git diff --git a/source/diameter/codec/Message.cpp b/source/diameter/codec/Message.cpp index 6f906f8..4938a03 100644 --- a/source/diameter/codec/Message.cpp +++ b/source/diameter/codec/Message.cpp @@ -227,6 +227,20 @@ void Message::setId(const char *name) throw(anna::RuntimeException) { } +//------------------------------------------------------------------------------ +//-------------------------------------------------- Message::setApplicationId() +//------------------------------------------------------------------------------ +void Message::setApplicationId(U32 aid) throw() { + a_applicationId = aid; + + // Default behaviour: + if (!getEngine()->selectStackWithApplicationId()) return; + + // Adapts for Application-ID stack identifier: + getEngine()->setDictionary(aid); +} + + //------------------------------------------------------------------------------ //------------------------------------------------------------ Message::addAvp() //------------------------------------------------------------------------------ @@ -294,7 +308,7 @@ void Message::decode(const anna::DataBlock &db, Message *ptrAnswer) throw(anna:: // // VALIDATION PHASE // Launch exception on first validation error (validateAll == false), or log warning reporting all validation errors when - // complete validation is desired (validateAll == true, engine default) launching a final exception like "decoded an invalid message". + // complete validation is desired (validateAll == true, engine default) launching a final exception like "the decoded message is invalid". // OAM OamModule &oamModule = OamModule::instantiate(); @@ -331,9 +345,10 @@ void Message::decode(const anna::DataBlock &db, Message *ptrAnswer) throw(anna:: U24 code = DECODE3BYTES_INDX_VALUETYPE(buffer, 5, U24); - setId(CommandId(code, requestBit() /* based on a_flags */)); + // This is called before setId, and in general before any operation which needs to know about the stack elements. + setApplicationId(DECODE4BYTES_INDX_VALUETYPE(buffer, 8, U32)); // centralize set, because it could be used for stack selection. - a_applicationId = DECODE4BYTES_INDX_VALUETYPE(buffer, 8, U32); + setId(CommandId(code, requestBit() /* based on a_flags */)); a_hopByHop = DECODE4BYTES_INDX_VALUETYPE(buffer, 12, U32); @@ -409,7 +424,7 @@ void Message::decode(const anna::DataBlock &db, Message *ptrAnswer) throw(anna:: if((vmode == Engine::ValidationMode::AfterDecoding) || (vmode == Engine::ValidationMode::Always)) if(!valid(answer)) - throw anna::RuntimeException("Decoded an invalid message. See previous report on warning-level traces", ANNA_FILE_LOCATION); + throw anna::RuntimeException("The decoded message is invalid. See previous report on warning-level traces", ANNA_FILE_LOCATION); } @@ -768,6 +783,10 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc a_version = i_aux; } + // Application-id + // This is called before setId, and in general before any operation which needs to know about the stack elements. + setApplicationId(appid->getIntegerValue()); // this could set the dictionary... + // Dictionary const stack::Dictionary * dictionary = getEngine()->getDictionary(); const stack::Command *stackCommand = NULL; @@ -853,19 +872,6 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc a_flags = flagsBCK; } - // Application-id - u_aux = appid->getIntegerValue(); - - /* - if(u_aux < 0) { - std::string msg = "Error processing command getValue(); - msg += "': negative values are not allowed"; - throw anna::RuntimeException(msg, ANNA_FILE_LOCATION); - } - */ - - setApplicationId(u_aux); - // Hob-by-hop-id if(hbh) { u_aux = hbh->getIntegerValue();