def findSimpleElementLocation(self, avpCode, msgSize):
        codeFound = False
        size = self.nwBuffer.tell() #bytes

        o_ParsedData = ParsedData()

        while (size < msgSize) and not codeFound:
            #print "DEBUG: {0} : {1} : {2}".format(size, msgSize, self.nwBuffer.tell())
            # read the AVP Code
            fmt = struct.Struct('>I')
            try:
                (avp,) = fmt.unpack(self.nwBuffer.read(4))
            except Exception, e:
                print "ERROR: Major formatting Issue {0}. Exception : {1}".format(avpCode, str(e))
                return o_ParsedData

            if avp == avpCode:
                codeFound = True

            ## Flags And Length
            [avpLen, avpFlags] = utils.getFlagAndLength(self.nwBuffer.read(4))
            avpLenPadded = avpLen + utils.calculatePadding(avpLen)

            size += 8
            if codeFound:
                o_ParsedData.isParsed = True
                o_ParsedData.avpSize  = avpLen
                o_ParsedData.padding  = utils.calculatePadding(avpLen)

                if (utils.existVendorID(avpFlags)):
                    # read vendor-id
                    (vendorID,) = fmt.unpack(self.nwBuffer.read(4))
                    o_ParsedData.vendorID = vendorID
                    size += 4
                    ## Set the network buffer to the data.
                    ## It's already set to data due to above read.
                    ## So, we can return safely from here

                codeFound = False
                return o_ParsedData
            else:
                unwanted = self.nwBuffer.read(avpLenPadded - 8)  ## (8 bytes is already read)
                size += (avpLenPadded - 8)
    def setFlags(self, avpFlags):
        if utils.existVendorID(avpFlags):
            self.avp['Vendor-ID'] = 1
        else:
            self.avp['Vendor-ID'] = 0
            self.clrVendorBit()

        if utils.existMandatory(avpFlags):
            self.avp['Mandatory'] = 1
            self.setMandatoryBit()
        else:
            self.avp['Mandatory'] = 0
            self.clrMandatoryBit()

        if utils.existPersistent(avpFlags):
            self.avp['Protected'] = 1
            self.setEncryptionBit()
        else:
            self.avp['Protected'] = 0
            self.clrEncryptionBit()