ANNA Suite
2020b
Multipurpose development suite for Telco applications
|
#include <Avp.hpp>
Public Member Functions | |
Avp (Engine *engine=NULL) | |
Avp (AvpId id, Engine *engine=NULL) | |
void | setEngine (Engine *engine) |
virtual | ~Avp () |
void | clear () noexcept(false) |
void | setId (AvpId id) noexcept(false) |
void | setId (const char *name) noexcept(false) |
void | setMandatoryBit (bool activate=true) |
void | setEncryptionBit (bool activate=true) |
Avp * | addAvp (AvpId id) noexcept(false) |
Avp * | addAvp (const char *name) noexcept(false) |
Avp * | addAvp (Avp *avp) noexcept(false) |
OctetString * | getOctetString () noexcept(false) |
Integer32 * | getInteger32 () noexcept(false) |
Integer64 * | getInteger64 () noexcept(false) |
Unsigned32 * | getUnsigned32 () noexcept(false) |
Unsigned64 * | getUnsigned64 () noexcept(false) |
Float32 * | getFloat32 () noexcept(false) |
Float64 * | getFloat64 () noexcept(false) |
Address * | getAddress () noexcept(false) |
Time * | getTime () noexcept(false) |
UTF8String * | getUTF8String () noexcept(false) |
DiameterIdentity * | getDiameterIdentity () noexcept(false) |
DiameterURI * | getDiameterURI () noexcept(false) |
Enumerated * | getEnumerated () noexcept(false) |
IPFilterRule * | getIPFilterRule () noexcept(false) |
QoSFilterRule * | getQoSFilterRule () noexcept(false) |
Unknown * | getUnknown () noexcept(false) |
bool | removeAvp (AvpId id, int ocurrence=1) noexcept(false) |
bool | removeAvp (const char *name, int ocurrence=1) noexcept(false) |
const AvpId & | getId () const |
int | getVendorId () const |
const anna::diameter::stack::Avp * | getStackAvp () const noexcept(false) |
bool | vendorBit () const |
bool | mandatoryBit () const |
bool | encryptionBit () const |
const OctetString * | getOctetString () const noexcept(false) |
const Integer32 * | getInteger32 () const noexcept(false) |
const Integer64 * | getInteger64 () const noexcept(false) |
const Unsigned32 * | getUnsigned32 () const noexcept(false) |
const Unsigned64 * | getUnsigned64 () const noexcept(false) |
const Float32 * | getFloat32 () const noexcept(false) |
const Float64 * | getFloat64 () const noexcept(false) |
const Avp * | getAvp (AvpId id, int ocurrence=1, anna::Exception::Mode::_v emode=anna::Exception::Mode::Throw) const noexcept(false) |
Avp * | getAvp (AvpId id, int ocurrence=1, anna::Exception::Mode::_v emode=anna::Exception::Mode::Throw) noexcept(false) |
const Avp * | getAvp (const char *name, int ocurrence=1, anna::Exception::Mode::_v emode=anna::Exception::Mode::Throw) const noexcept(false) |
Avp * | getAvp (const char *name, int ocurrence=1, anna::Exception::Mode::_v emode=anna::Exception::Mode::Throw) noexcept(false) |
const Address * | getAddress () const noexcept(false) |
const Time * | getTime () const noexcept(false) |
const UTF8String * | getUTF8String () const noexcept(false) |
const DiameterIdentity * | getDiameterIdentity () const noexcept(false) |
const DiameterURI * | getDiameterURI () const noexcept(false) |
const Enumerated * | getEnumerated () const noexcept(false) |
const IPFilterRule * | getIPFilterRule () const noexcept(false) |
const QoSFilterRule * | getQoSFilterRule () const noexcept(false) |
const Unknown * | getUnknown () const noexcept(false) |
void | decode (const anna::DataBlock &db) noexcept(false) |
void | fromXML (const anna::xml::Node *avpNode) noexcept(false) |
void | code (char *buffer, int &size) const noexcept(false) |
anna::xml::Node * | asXML (anna::xml::Node *parent) const |
std::string | asXMLString (bool normalize=false) const |
bool | isLike (const std::string &pattern) const |
int | countAvp (AvpId id) const noexcept(false) |
int | countAvp (const char *name) const noexcept(false) |
int | countChilds () const noexcept(false) |
virtual void | unknownAvpWithMandatoryBit () const noexcept(false) |
Static Public Attributes | |
static const int | HeaderLengthVactive |
static const int | HeaderLengthVinactive |
static const U8 | VBitMask |
static const U8 | MBitMask |
static const U8 | PBitMask |
Protected Member Functions | |
virtual Engine * | getEngine () const noexcept(false) |
void | initialize () |
void | assertFormat (const std::string &name) const noexcept(false) |
U24 | getLength () const |
std::string | getXMLdata (bool &isHex, const anna::diameter::stack::Format *stackFormat) const |
void | decodeDataPart (const char *buffer, int size, const anna::diameter::codec::parent_t &parent, Message *answer) noexcept(false) |
Protected Attributes | |
Engine * | a_engine |
Friends | |
class | Message |
class | Engine |
bool | operator== (const Avp &a1, const Avp &a2) |
Diameter avp generic container
RFC 3588 Diameter Based Protocol September 2003 4.1. AVP Header
The fields in the AVP header MUST be sent in network byte order. The format of the header is:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AVP Code | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AVP Flags | AVP Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Vendor-ID (opt) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data ... +-+-+-+-+-+-+-+-+
AVP Flags: V (vendor-specific), M (mandatory), P (end to end encryption) +-+-+-+-+-+-+-+-+ |V M P r r r r r| +-+-+-+-+-+-+-+-+ AVP Length The AVP Length field is three octets, and indicates the number of octets in this AVP including the AVP Code, AVP Length, AVP Flags, Vendor-ID field (if present) and the AVP data. Vendor-ID: IANA "SMI Network Management Private Enterprise Codes" [ASSIGNNO] http://www.iana.org/assignments/enterprise-numbers
anna::diameter::codec::Avp::Avp | ( | Engine * | engine = NULL | ) |
Default constructor
engine | Codec engine used |
Identified constructor
id | Avp identifier as pair (code,vendor-id). |
engine | Codec engine used |
|
virtual |
Destructor
Reimplemented in anna::diameter::codec::tme::Avp.
Adds an avp child providing its identifier and reserve internal memory it. An exception is launched is the Avp over which we add the new avp, is not a grouped avp.
id | Avp identifier as pair (code,vendor-id). |
|
noexcept |
Same as #addAvp but providing dictionary logical name for Avp searched
Adds an avp child providing a persistent pointer (must be maintained by application). An exception is launched is the Avp over which we add the new avp, is not a grouped avp. It is not allowed to add an avp with no codec engine configured, neither if the engine is not the same.
avp | Avp external pointer. If NULL provided, nothing is done and NULL returned. Also NULL returned for bad engine configuration. |
|
protectednoexcept |
Assert format regarding dictionary
anna::xml::Node* anna::diameter::codec::Avp::asXML | ( | anna::xml::Node * | parent | ) | const |
Class xml representation
parent | Parent XML node on which hold this instance information. |
std::string anna::diameter::codec::Avp::asXMLString | ( | bool | normalize = false | ) | const |
Class xml string representation
normalize | Optional normalization which sorts attribute names and removes newlines in the xml representation in order to ease regexp matching. |
|
noexcept |
Clears and initializes Avp class information. Application should clear auxiliary avp objects before setting data in a new context.
|
noexcept |
Encodes buffer with the class content. This method is internally used to encode diameter messages, but is declared as public, to allow its use as serialization procedure. Then, it's assumed that this Avp is valid (validation shall be applied as part of a whole diameter message but nothing will be verified now).
buffer | Raw data to be encoded (shall be externally allocated) |
size | Size of raw data to be encoded |
|
inlinenoexcept |
Counts the number of ocurrences of Avps (first level) with the identifier provided
id | Avp identifier (pair code + vendor-id). |
|
noexcept |
Same as #countAvp but providing dictionary logical name for Avp searched
|
inlinenoexcept |
Counts the number of children within a grouped avp
id | Avp identifier (pair code + vendor-id). |
|
noexcept |
Decodes buffer provided over class content. If an error ocurred, decoding will stop launching exception (fatal error) or a warning trace (perhaps the achieved avp is valid against all odds then validation will go on). In case that validation is enabled (codec::Engine::ValidationMode) an exception will be launched depending on validation depth (codec::Engine::ValidationDepth).
Useful as serialization procedure with code
db | Buffer data block processed |
|
protectednoexcept |
|
inline |
Returns P bit activation state
|
noexcept |
Interpret xml data in order to dump over the class content.
avpNode | Avp root node |
|
inlinenoexcept |
Access content for Address Avp in order to set data part
|
inlinenoexcept |
Access content for Address Avp
|
inlinenoexcept |
Access content for Grouped Avp. Exception mode allows different combinations like cascade access:
try { message->getAvp(anna::diameter::helpers::base::AVP__Multiple_Services_Credit_Control, anna::Exception::Mode::Throw) ->getAvp(anna::diameter::helpers::base::AVP__Rating_Group, anna::Exception::Mode::Throw); } catch(anna::RuntimeException) {;}
Or step access:
const Avp *mscc = message->getAvp(anna::diameter::helpers::base::AVP__Multiple_Services_Credit_Control); const Avp *rg; if (mscc) rg = mscc->getAvp(anna::diameter::helpers::base::AVP__Rating_Group);
Replacing procedures becomes easy because an Avp can be searched and its pointer reconfigured by mean setId and data part setters. Deleting procedures must use #removeAvp. Access is internally cached to speed up the search operations. This cache is reset after calling #fix or #removeAvp methods.
id | Avp identifier (pair code + vendor-id). |
ocurrence | Order of appearance for the searched avp. Zero position is rejected, but negative values could be used to reverse access positions: i.e. -1 is the last ocurrence, -2 is the second to last (penultimate), etc. |
emode | Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (excepcion launched, by default), Trace (trace warning). If avp format is not grouped, always exception will be launched and no matter what mode is provided. It would be a development error and must be solved. |
|
inlinenoexcept |
|
inlinenoexcept |
Same as #getAvp but providing dictionary logical name for Avp searched
|
inlinenoexcept |
|
inlinenoexcept |
Access content for DiameterIdentity Avp in order to set data part
|
inlinenoexcept |
Access content for DiameterIdentity Avp
|
inlinenoexcept |
Access content for DiameterURI Avp in order to set data part
|
inlinenoexcept |
Access content for DiameterURI Avp
|
protectedvirtualnoexcept |
Codec Engine getter: avoids have to create base engine when using its child
|
inlinenoexcept |
Access content for Enumerated Avp in order to set data part
|
inlinenoexcept |
Access content for Enumerated Avp
|
inlinenoexcept |
Access content for Float32 Avp in order to set data part
|
inlinenoexcept |
Access content for Float32 Avp
|
inlinenoexcept |
Access content for Float64 Avp in order to set data part
|
inlinenoexcept |
Access content for Float64 Avp
|
inline |
Gets Avp identifier as pair (code, vendor-id).
|
inlinenoexcept |
Access content for Integer32 Avp in order to set data part
|
inlinenoexcept |
Access content for Integer32 Avp
|
inlinenoexcept |
Access content for Integer64 Avp in order to set data part
|
inlinenoexcept |
Access content for Integer64 Avp
|
inlinenoexcept |
Access content for IPFilterRule Avp in order to set data part
|
inlinenoexcept |
Access content for IPFilterRule Avp
|
protected |
Gets avp total length based on internal data part and header configuration. Padding octets are not included, only header and data part length. The only format which always have total length equal to sum of all its parts is Grouped, because of the 4-multiple nature of its data part length.
|
inlinenoexcept |
Access content for OctetString Avp in order to set data part
|
inlinenoexcept |
Access content for OctetString Avp
|
inlinenoexcept |
Access content for QoSFilterRule Avp in order to set data part
|
inlinenoexcept |
Access content for QoSFilterRule Avp
|
inlinenoexcept |
Gets stack avp (dictionary avp reference).
|
inlinenoexcept |
Access content for Time Avp in order to set data part
|
inlinenoexcept |
Access content for Time Avp
|
inlinenoexcept |
Access content for Unknown Avp in order to set data part
|
inlinenoexcept |
Access content for Unknown Avp
|
inlinenoexcept |
Access content for Unsigned32 Avp in order to set data part
|
inlinenoexcept |
Access content for Unsigned32 Avp
|
inlinenoexcept |
Access content for Unsigned64 Avp in order to set data part
|
inlinenoexcept |
Access content for Unsigned64 Avp
|
inlinenoexcept |
Access content for UTF8String Avp in order to set data part
|
inlinenoexcept |
Access content for UTF8String Avp
|
inline |
Gets Avp vendor-id.
|
protected |
Gets data or hexadecimal data depending on avp format, for xml creating
isHex | Hexadecimal/Natural data when apply. |
stackFormat | Stack avp format in which data extraction is based. |
|
protected |
Initializes Avp class information.
bool anna::diameter::codec::Avp::isLike | ( | const std::string & | pattern | ) | const |
Match a regular expression (string pattern) regarding xml string serialization for this avp. This works same as #Message::isLike
pattern | Pattern to match |
|
inline |
Returns M bit activation state
|
inlinenoexcept |
Removes an Avp within grouped type (first level) and free resources.
id | Avp identifier (pair code + vendor-id). |
ocurrence | Order of appearance for the searched avp. Zero value means remove all avps with provided identifier at first level (no recursiveness would be allowed in the API in order to avoid unexpected behaviour). Negative values could be used to reverse access positions: i.e. -1 is the last ocurrence, -2 is the second to last (penultimate), etc. |
|
noexcept |
Same as #removeAvp but providing dictionary logical name for Avp searched
|
inline |
Sets/unsets P bit activation. Application should not have to use this because dictionary information is used in order to configure flags when Avp identifier is stored. Anyway, could be useful when build unknown-type avps.
activate | Activates/deactivates the bit. True by default. |
void anna::diameter::codec::Avp::setEngine | ( | Engine * | engine | ) |
Sets the codec engine
Once assigned (here or at constructor), this method SHALL NOT be used anymore. Also, the associated dictionary SHOULD NOT BE CHANGED through the engine, unless you know what are you doing. If you want to reconfigure the engine, first clear the avp and then you could reuse the same object with different configurations (execution contexts).
Setting a new different engine with different stack, even same engine where the stack has been dynamically changed, could cause a bad behaviour depending on the changes: in general, if the dictionary grows, nothing bad will happen, but if you remove or modified some elements which were processed with a certain format, will be interpreted as 'unknown' with the new dictionary, and then some problems may occur. If you add elements (vendors, avps, messages) is not a problem.
|
noexcept |
Sets the avp identifier and clear the former content. Internally reserves memory for data part depending on avp format for the identifier provided. This must be called at first place because Avp class content is cleared when identifier is configured. Generic AVP assignment have no sense and will be ignored.
id | Avp identifier as pair (code,vendor-id). |
|
noexcept |
|
inline |
Sets/unsets M bit activation. Application should not have to use this because dictionary information is used in order to configure flags when Avp identifier is stored. Anyway, could be useful when build unknown-type avps.
The 'M' Bit, known as the Mandatory bit, indicates whether support of the AVP is required. If an AVP with the 'M' bit set is received by a Diameter client, server, proxy, or translation agent and either the AVP or its value is unrecognized, the message MUST be rejected. Diameter Relay and redirect agents MUST NOT reject messages with unrecognized AVPs.
activate | Activates/deactivates the bit. True by default. |
|
virtualnoexcept |
The 'M' Bit, known as the Mandatory bit, indicates whether support of the AVP is required. If an AVP with the 'M' bit set is received by a Diameter client, server, proxy, or translation agent and either the AVP or its value is unrecognized, the message MUST be rejected. Diameter Relay and redirect agents MUST NOT reject messages with unrecognized AVPs.
Default implementation launch alarm and counter indicating the anomaly but don't launch exception (traces at warning level). Relay and Redirect agents could reimplement this method to avoid oam management (another way is avoid alarm/counter registration on these applications). Result-Code DIAMETER_AVP_UNSUPPORTED will be stored for possible answer message.
|
inline |
Returns V bit activation state
|
friend |
|
friend |
|
static |
|
static |
|
static |
|
static |
|
static |