9 #ifndef anna_diameter_codec_functions_hpp 10 #define anna_diameter_codec_functions_hpp 28 #define REQUIRED_WORDS(bytes) ((bytes)/4+((((bytes)%4)!=0)?1:0 )) 44 static const char *MessageDTD =
"\ 45 <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\ 46 <!-- Diameter message DTD -->\n\ 48 <!ELEMENT message (avp*)>\n\ 49 <!ELEMENT avp (avp*)>\n\ 51 <!ATTLIST message version CDATA #IMPLIED name CDATA #IMPLIED code CDATA #IMPLIED flags CDATA #IMPLIED p-bit (yes | no) #IMPLIED e-bit (yes | no) #IMPLIED t-bit (yes | no) #IMPLIED application-id CDATA #REQUIRED hop-by-hop-id CDATA #IMPLIED end-to-end-id CDATA #IMPLIED>\n\ 53 version: Diameter version. Sets '1' by default\n\ 54 name: Command name within working stack (dictionary identifier)\n\ 55 p-bit: (P)roxiable bit flag (yes, no). By default is 'no'\n\ 56 e-bit: (E)rror bit flag (yes, no). By default is 'no'\n\ 57 t-bit: Potentially re-(T)ransmitted bit flag (yes, no). By default is 'no'\n\ 59 In order to get more coding capabilities, command code and flags could be established instead of former fields,\n\ 60 but neither of them are allowed if the other are present (and vice versa):\n\ 63 flags: Command flags byte value (0-255) where standard bit set for flags is 'RPET rrrr': (R)equest, (P)roxiable, (E)rror, Potentially re-(T)ransmitted message and (r)eserved\n\ 66 application-id: Message application id\n\ 67 hop-by-hop-id: Message hop by hop id. Sets '0' by default\n\ 68 end-to-end-id: Message end to end id. Sets '0' by default\n\ 71 <!ATTLIST avp name CDATA #IMPLIED code CDATA #IMPLIED vendor-code CDATA #IMPLIED flags CDATA #IMPLIED data CDATA #IMPLIED hex-data CDATA #IMPLIED alias CDATA #IMPLIED>\n\ 73 name: Avp name within working stack (dictionary identifier)\n\ 75 In order to get more coding capabilities, avp code, vendor-id and flags could be established instead of former avp name,\n\ 76 but neither of them are allowed if 'name' is provided (and vice versa):\n\ 79 vendor-code: Avp vendor code\n\ 80 flags: Avp flags byte value (0-255) where standard bit set for flags is 'VMPr rrrr': (V)endor-specific, (M)andatory, end to end encry(P)tion and r(eserved)\n\ 81 alias: Descriptive/helper field for certain numeric data values. Aliases are defined at diameter dictionary, but are ignored (not checked) at xml message parsing\n\ 82 The reason to include it in dtd definition, is because xml messages traced by the diameter codec could add alias field for some Avps\n\ 85 data: Natural string representation for avp data. Specially applicable with numbers and printable strings, but also\n\ 86 useful for certain formats which could be easily understandable in such friendly/smart representation. We will\n\ 87 achieve different human-readable strings depending on data format:\n\ 89 [ OctetString ] (if printable, but not recommended)\n\ 90 [ Integer32, Integer64, Unsigned32, Unsigned64, Float32, Float64 ] (normal number representation)\n\ 91 [ Time ] (NTP timestamp, normal number representation)\n\ 92 [ Address ] ('<type (IANA Address Family Number)>|<value>' representation; i.e. '1|192.168.0.1'(IPv4), '8|34616279266'(E164), etc.\n\ 93 Type (and pipe) field could be avoided for IPv4 and IPv6 address types (a light parse checking is done: one colon for\n\ 94 IPv6, one dot for IPv4). Internal engine always includes type on data field, which is also recommended for inputs.\n\ 95 Currently, only IPv4, IPv6 and E164 address types have a known printable presentation, anyway using printable format\n\ 96 for another types will encode the address value directly as E164 does)\n\ 97 [ UTF8String, DiameterIdentity, DiameterURI ] (printable)\n\ 98 [ IPFilterRule, QoSFilterRule ] (uses ASCII charset, printable)\n\ 100 New application formats must define specific natural representation for internal raw data\n\ 102 hex-data: Hexadecimal octet sequence representation (i.e. 'af012fb3', with even number of digits). Suitable for whatever kind\n\ 103 of diameter format, but mandatory for non printable information. OctetString usually transport non human-readable\n\ 104 data and should better be encoded within this field although being printable. Unknown avps (which fails identifying\n\ 105 provided name or code/vendor-code) must always use this representation.\n\ 107 Xml representation for decoded messages shows natural content except for 'OctetString' format and unknown avps. Anyway, when printable,\n\ 108 OctetString could show such information at data field apart from hex-data, because many implementations use this format to transport\n\ 109 readable-string data. In general, one of the data fields is mandatory except for 'Grouped' type (its data is another level of avps).\n\ 110 Application-specific formats must decide the way to represent its contents, being recommended to use a natural representation if possible,\n\ 111 because xml is read by humans with testing and monitoring purposes.\n\ 124 std::vector<anna::diameter::AvpId>
AvpsId;
147 static bool potentiallyReTransmittedMessageBit(
const anna::DataBlock &) noexcept(
false);
169 static void decodeCommandHeader(
const char *start,
char & version,
U24 & length,
char & flags,
CommandId &
id,
int & appId,
int & hbh,
int & ete) noexcept(
false);
180 static void decodeAVP(
const char *start,
AvpId &
id,
char & flags,
int & length, std::string & data) noexcept(
false);
192 static const char * nextAVP(
const char *avpsDB,
int avpsLen,
const char *start) noexcept(
false);
215 static const char *findAVP(
const char *avpsDB,
int avpsLen,
const diameter::AvpId &
id,
int n = 1) noexcept(
false);
233 static void setPotentiallyReTransmittedMessageBit(
const anna::DataBlock & db,
bool activate =
true) noexcept(
false);
307 static void messageXmlDocumentFromXmlFile(
anna::xml::DocumentFile &xmlDocument,
const std::string & xmlPathFile) noexcept(
false);
321 static void messageXmlDocumentFromXmlString(
anna::xml::DocumentMemory &xmlDocument,
const std::string &xmlString) noexcept(
false);
static bool isRequest(const anna::DataBlock &db) noexcept(false)
Definition: functions.hpp:150
unsigned int EndToEnd
Definition: defines.hpp:70
unsigned int HopByHop
Definition: defines.hpp:68
std::vector< std::string > AvpsName
Definition: functions.hpp:125
void setMessage(const anna::diameter::CommandId &mid, const char *mname=NULL)
static bool isRequest(const CommandId &cid)
Definition: functions.hpp:149
std::vector< anna::diameter::AvpId > AvpsId
Definition: functions.hpp:124
struct anna::diameter::codec::parent parent_t
std::pair< S32, S32 > AvpId
Definition: defines.hpp:31
std::string asString() const
U32 U24
Definition: defines.hpp:96
static bool isAnswer(const anna::DataBlock &db) noexcept(false)
Definition: functions.hpp:153
std::string MessageName
Definition: functions.hpp:122
void addAvp(const anna::diameter::AvpId &aid, const char *aname=NULL)
unsigned int ApplicationId
Definition: defines.hpp:64
anna::diameter::CommandId MessageId
Definition: functions.hpp:121
Definition: DocumentFile.hpp:23
std::pair< U24, bool > CommandId
Definition: defines.hpp:32
static bool isAnswer(const CommandId &cid)
Definition: functions.hpp:152
Definition: DocumentMemory.hpp:23
Definition: DataBlock.hpp:24
Definition: functions.hpp:118
Definition: functions.hpp:136