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

#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 \
)
#define ISHEXDIGIT (   x)
Value:
( \
(x >= '0' && x <= '9') || \
(x >= 'a' && x <= 'f') || \
(x >= 'A' && x <= 'F') \
)
#define LOWERNIBBLE (   _ln_)    ((_ln_) & 0x0f)
#define RAPIDJSON_NAMESPACE   epctoolsrapidjson
#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") ); \
}
Definition: efdjson.cpp:123
Definition: efdjson.cpp:108
Definition: efdjson.cpp:119
Definition: efdjson.cpp:109
Definition: efdjson.cpp:118
Definition: efdjson.cpp:113
Definition: efdjson.cpp:110
Definition: efdjson.cpp:116
Definition: efdjson.cpp:121
Definition: efdjson.cpp:122
Definition: efdjson.cpp:112
Definition: efdjson.cpp:115
Definition: efdjson.cpp:120
Definition: efdjson.cpp:114
std::string string_format(const char *format,...)
Definition: efdjson.cpp:89
Definition: efdjson.cpp:117
Definition: efdjson.cpp:111
Definition: efdjson.cpp:62
#define UPPERNIBBLE (   _un_)    ( LOWERNIBBLE((_un_) >> 4) )

Enumeration Type Documentation

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

Function Documentation

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.
std::string fdJsonBinaryToHex ( const unsigned char *  buffer,
size_t  len 
)
bool fdJsonGetApnValueFromSubData ( std::string  json,
std::string &  apn 
)
void fdJsonGetJSON ( msg_or_avp *  ref,
std::string &  json,
void(*)(const char *)  errfunc 
)
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.
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 
)
std::string string_format ( const char *  format,
  ... 
)