X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;ds=sidebyside;f=source%2Fdiameter%2Fcodec%2Ffunctions.cpp;h=767d9605d59b7fdbab8647d9645f4a3546004957;hb=4c3f0a4d7e4db76996404d80c6f939548fca656f;hp=a58372dc8bdb37b25de82af19d55ba595163618b;hpb=c82a3818b279727e943a76343f3cf1a278ac9e19;p=anna.git diff --git a/source/diameter/codec/functions.cpp b/source/diameter/codec/functions.cpp index a58372d..767d960 100644 --- a/source/diameter/codec/functions.cpp +++ b/source/diameter/codec/functions.cpp @@ -214,9 +214,11 @@ void functions::decodeAVP(const char *start, diameter::AvpId & id, char & flags, ); } -const char * functions::nextAVP(const anna::DataBlock & avpsDB, const char *start) throw(anna::RuntimeException) { +const char * functions::nextAVP(const char *avpsDB, int avpsLen, const char *start) throw(anna::RuntimeException) { if(start == NULL) throw anna::RuntimeException("NULL provided start pointer", ANNA_FILE_LOCATION); + if(avpsDB == NULL) + throw anna::RuntimeException("NULL provided avpsDB pointer", ANNA_FILE_LOCATION); const char *result; // LOGDEBUG( @@ -227,18 +229,21 @@ const char * functions::nextAVP(const anna::DataBlock & avpsDB, const char *star //int avpLength = (start[5] << 16) + (start[6] << 8) + start[7]; // AVP Length int avpLength = DECODE3BYTES_INDX_VALUETYPE(start, 5, int); result = start + 4 * REQUIRED_WORDS(avpLength); - const char * first = avpsDB.getData(); - int offset = (result - first); + int offset = (result - avpsDB); - if(offset > (avpsDB.getSize() - 1)) - //throw anna::RuntimeException("Start pointer out of boundaries for DataBlock", ANNA_FILE_LOCATION); + if(offset > (avpsLen - 1)) + //throw anna::RuntimeException("Start pointer out of boundaries for block(avpsDB, avpsLen)", ANNA_FILE_LOCATION); return NULL; // (*) return result; } -const char * functions::findAVP(const anna::DataBlock & avpsDB, const diameter::AvpId & id, int n) throw(anna::RuntimeException) { - const char * result = avpsDB.getData(); // first avp +//const char * functions::nextAVP(const anna::DataBlock & avpsDB, const char *start) throw(anna::RuntimeException) { +// return nextAVP(avpsDB.getData(), avpsDB.getSize(), start); +//} + +const char * functions::findAVP(const char *avpsDB, int avpsLen, const diameter::AvpId & id, int n) throw(anna::RuntimeException) { + const char *result = avpsDB; // first avp int positives = 0; // Decoded avp information: diameter::AvpId _id; @@ -250,7 +255,7 @@ const char * functions::findAVP(const anna::DataBlock & avpsDB, const diameter:: if(_id == id) positives++; while((_id != id) || (positives != n)) { // next search if not found or not ocurrence number reached - result = nextAVP(avpsDB, result); + result = nextAVP(avpsDB, avpsLen, result); if(result == NULL) { // (*) LOGDEBUG( @@ -270,6 +275,9 @@ const char * functions::findAVP(const anna::DataBlock & avpsDB, const diameter:: return result; } +//const char * functions::findAVP(const anna::DataBlock & avpsDB, const diameter::AvpId & id, int n) throw(anna::RuntimeException) { +// return findAVP(avpsDB.getData(), avpsDB.getSize(), id, n); +//} // modifiers void functions::setHopByHop(anna::DataBlock & db, diameter::HopByHop hbh) throw(anna::RuntimeException) {