EpcTools
An event based multi-threaded C++ development framework.
Classes | Macros | Enumerations | Functions
efdjson.cpp File Reference
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include <string>
#include <sstream>
#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include "freeDiameter/freeDiameter-host.h"
#include "freeDiameter/libfdcore.h"
#include "freeDiameter/libfdproto.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"
#include "efdjson.h"
#include "etime.h"
#include "esynch.h"

Classes

class  runtimeInfo
 
class  runtimeError
 
class  Buffer< T >
 
class  AvpDictionaryEntry
 
class  AVP
 

Macros

#define RAPIDJSON_NAMESPACE   epctoolsrapidjson
 
#define ISHEXDIGIT(x)
 
#define HEX2BIN(x)
 
#define LOWERNIBBLE(_ln_)   ((_ln_) & 0x0f)
 
#define UPPERNIBBLE(_un_)   ( LOWERNIBBLE((_un_) >> 4) )
 
#define THROW_DATATYPE_MISMATCH()
 

Enumerations

enum  AvpDataType {
  ADTUnknown, ADTOctetString, ADTI32, ADTI64,
  ADTU32, ADTU64, ADTF32, ADTF64,
  ADTGrouped, ADTAddress, ADTTime, ADTUTF8String,
  ADTDiameterIdentity, ADTDiameterURI, ADTEnumerated, ADTIPFilterRule
}
 

Functions

std::string string_format (const char *format,...)
 
int fdJsonAddAvps (const char *json, msg_or_avp *msg, void(*errfunc)(const char *))
 Adds the AVP from the JSON string to a freeDiameter message or grouped AVP. More...
 
std::string fdJsonBinaryToHex (const unsigned char *buffer, size_t len)
 
void fdJsonGetJSON (msg_or_avp *ref, std::string &json, void(*errfunc)(const char *))
 
const char * fdJsonGetJSON (msg_or_avp *ref, void(*errfunc)(const char *))
 Converts the AVP's from a freeDiameter message or grouped AVP to a JSON string. More...
 
bool fdJsonGetValueOfMember (std::string json, std::string member, std::string &value)
 
void parseRecursive (std::string scope, RAPIDJSON_NAMESPACE::Value::ConstMemberIterator object, std::unordered_map< std::string, std::string > &values)
 
bool fdJsonGetApnValueFromSubData (std::string json, std::string &apn)
 

Macro Definition Documentation

◆ HEX2BIN

#define HEX2BIN (   x)
Value:
( \
x >= '0' && x <= '9' ? x - '0' : \
x >= 'a' && x <= 'f' ? x - 'a' + 10 : \
x >= 'A' && x <= 'F' ? x - 'A' + 10 : 15 \
)

◆ ISHEXDIGIT

#define ISHEXDIGIT (   x)
Value:
( \
(x >= '0' && x <= '9') || \
(x >= 'a' && x <= 'f') || \
(x >= 'A' && x <= 'F') \
)

◆ LOWERNIBBLE

#define LOWERNIBBLE (   _ln_)    ((_ln_) & 0x0f)

◆ RAPIDJSON_NAMESPACE

#define RAPIDJSON_NAMESPACE   epctoolsrapidjson

◆ THROW_DATATYPE_MISMATCH

#define THROW_DATATYPE_MISMATCH ( )
Value:
{ \
throw runtimeInfo( string_format("%s:%d - INFO - Datatype mismatch for [%s] - expected datatype compatible with %s, JSON data type was %s", \
__FILE__, __LINE__, name, \
avp.getType() == ADTUnknown ? "ADTUnknown" : \
avp.getType() == ADTOctetString ? "ADTOctetString" : \
avp.getType() == ADTI32 ? "ADTI32" : \
avp.getType() == ADTI64 ? "ADTI64" : \
avp.getType() == ADTU32 ? "ADTU32" : \
avp.getType() == ADTU64 ? "ADTU64" : \
avp.getType() == ADTF32 ? "ADTF32" : \
avp.getType() == ADTF64 ? "ADTF64" : \
avp.getType() == ADTGrouped ? "ADTGrouped" : \
avp.getType() == ADTAddress ? "ADTAddress" : \
avp.getType() == ADTTime ? "ADTTime" : \
avp.getType() == ADTUTF8String ? "ADTUTF8String" : \
avp.getType() == ADTDiameterIdentity ? "ADTDiameterIdentity" : \
avp.getType() == ADTDiameterURI ? "ADTDiameterURI" : \
avp.getType() == ADTEnumerated ? "ADTEnumerated" : \
avp.getType() == ADTIPFilterRule ? "ADTIPFilterRule" : "UNKNOWN", \
value.GetType() == RAPIDJSON_NAMESPACE::kNullType ? "kNullType" : \
value.GetType() == RAPIDJSON_NAMESPACE::kFalseType ? "kFalseType" : \
value.GetType() == RAPIDJSON_NAMESPACE::kTrueType ? "kTrueType" : \
value.GetType() == RAPIDJSON_NAMESPACE::kObjectType ? "kObjectType" : \
value.GetType() == RAPIDJSON_NAMESPACE::kArrayType ? "kArrayType" : \
value.GetType() == RAPIDJSON_NAMESPACE::kStringType ? "kStringType" : \
value.GetType() == RAPIDJSON_NAMESPACE::kNumberType ? "kNumber" : "Unknown") ); \
}

◆ UPPERNIBBLE

#define UPPERNIBBLE (   _un_)    ( LOWERNIBBLE((_un_) >> 4) )

Enumeration Type Documentation

◆ AvpDataType

Enumerator
ADTUnknown 
ADTOctetString 
ADTI32 
ADTI64 
ADTU32 
ADTU64 
ADTF32 
ADTF64 
ADTGrouped 
ADTAddress 
ADTTime 
ADTUTF8String 
ADTDiameterIdentity 
ADTDiameterURI 
ADTEnumerated 
ADTIPFilterRule 

Function Documentation

◆ fdJsonAddAvps()

int fdJsonAddAvps ( const char *  json,
msg_or_avp *  msg,
void(*)(const char *)  errfunc 
)

Adds the AVP from the JSON string to a freeDiameter message or grouped AVP.

Parameters
jsonthe JSON string to process.
msgthe freeDiameter or grouped AVP to add to.
errfunca function that is called in the event of an error.
Returns
0 indicates success, otherwise failure.

◆ fdJsonBinaryToHex()

std::string fdJsonBinaryToHex ( const unsigned char *  buffer,
size_t  len 
)

◆ fdJsonGetApnValueFromSubData()

bool fdJsonGetApnValueFromSubData ( std::string  json,
std::string &  apn 
)

◆ fdJsonGetJSON() [1/2]

void fdJsonGetJSON ( msg_or_avp *  ref,
std::string &  json,
void(*)(const char *)  errfunc 
)

◆ fdJsonGetJSON() [2/2]

const char* fdJsonGetJSON ( msg_or_avp *  msg,
void(*)(const char *)  errfunc 
)

Converts the AVP's from a freeDiameter message or grouped AVP to a JSON string.

Parameters
msgthe freeDiameter message or grouped AVP to process.
errfunca function that is called in the event of an error.
Returns
the resulting JSON string.

◆ fdJsonGetValueOfMember()

bool fdJsonGetValueOfMember ( std::string  json,
std::string  member,
std::string &  value 
)

◆ parseRecursive()

void parseRecursive ( std::string  scope,
RAPIDJSON_NAMESPACE::Value::ConstMemberIterator  object,
std::unordered_map< std::string, std::string > &  values 
)

◆ string_format()

std::string string_format ( const char *  format,
  ... 
)
ADTU32
Definition: efdjson.cpp:112
string_format
std::string string_format(const char *format,...)
Definition: efdjson.cpp:89
ADTAddress
Definition: efdjson.cpp:117
ADTI64
Definition: efdjson.cpp:111
ADTU64
Definition: efdjson.cpp:113
runtimeInfo
Definition: efdjson.cpp:62
ADTIPFilterRule
Definition: efdjson.cpp:123
ADTUTF8String
Definition: efdjson.cpp:119
ADTOctetString
Definition: efdjson.cpp:109
ADTTime
Definition: efdjson.cpp:118
ADTI32
Definition: efdjson.cpp:110
ADTGrouped
Definition: efdjson.cpp:116
ADTUnknown
Definition: efdjson.cpp:108
ADTF64
Definition: efdjson.cpp:115
ADTDiameterURI
Definition: efdjson.cpp:121
ADTEnumerated
Definition: efdjson.cpp:122
ADTF32
Definition: efdjson.cpp:114
ADTDiameterIdentity
Definition: efdjson.cpp:120