X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter%2Fcodec%2Ffunctions.cpp;h=a58372dc8bdb37b25de82af19d55ba595163618b;hb=c82a3818b279727e943a76343f3cf1a278ac9e19;hp=3e8ce1fa5ca5c4722de671f823ace0a09ddf1599;hpb=93366a0bda79e6fd6e7dad6316bfcf8cc82f5731;p=anna.git diff --git a/source/diameter/codec/functions.cpp b/source/diameter/codec/functions.cpp index 3e8ce1f..a58372d 100644 --- a/source/diameter/codec/functions.cpp +++ b/source/diameter/codec/functions.cpp @@ -80,14 +80,34 @@ anna::diameter::CommandId functions::getCommandId(const anna::DataBlock & db) th return (anna::diameter::CommandId(code, (flags & Message::RBitMask) != 0x00)); } - -bool functions::isRequest(const anna::DataBlock & db) throw(anna::RuntimeException) { +bool functions::requestBit(const anna::DataBlock & db) throw(anna::RuntimeException) { if(db.getSize() < Message::HeaderLength) throw anna::RuntimeException("Not enough bytes to cover command header length", ANNA_FILE_LOCATION); return (((db.getData())[4] & Message::RBitMask) != 0x00); } +bool functions::proxiableBit(const anna::DataBlock & db) throw(anna::RuntimeException) { + if(db.getSize() < Message::HeaderLength) + throw anna::RuntimeException("Not enough bytes to cover command header length", ANNA_FILE_LOCATION); + + return (((db.getData())[4] & Message::PBitMask) != 0x00); +} + +bool functions::errorBit(const anna::DataBlock & db) throw(anna::RuntimeException) { + if(db.getSize() < Message::HeaderLength) + throw anna::RuntimeException("Not enough bytes to cover command header length", ANNA_FILE_LOCATION); + + return (((db.getData())[4] & Message::EBitMask) != 0x00); +} + +bool functions::potentiallyReTransmittedMessageBit(const anna::DataBlock & db) throw(anna::RuntimeException) { + if(db.getSize() < Message::HeaderLength) + throw anna::RuntimeException("Not enough bytes to cover command header length", ANNA_FILE_LOCATION); + + return (((db.getData())[4] & Message::TBitMask) != 0x00); +} + anna::diameter::ApplicationId functions::getApplicationId(const anna::DataBlock & db) throw(anna::RuntimeException) { if(db.getSize() < Message::HeaderLength) throw anna::RuntimeException("Not enough bytes to cover command header length", ANNA_FILE_LOCATION); @@ -279,4 +299,15 @@ void functions::setEndToEnd(anna::DataBlock & db, diameter::EndToEnd ete) throw( memcpy((char *)(db.getData() + 16), source, 4); } +void functions::setPotentiallyReTransmittedMessageBit(const anna::DataBlock & db, bool activate) throw(anna::RuntimeException) { + if(db.getSize() < Message::HeaderLength) { + throw anna::RuntimeException("Not enough bytes to cover command header length", ANNA_FILE_LOCATION); + } + + static char flags[1]; + flags[0] = *(db.getData() + 4); + if(activate) flags[0] |= Message::TBitMask; else flags[0] &= (~Message::TBitMask); + memcpy((char *)(db.getData() + 4), flags, 1); +} +