https://github.com/volkds/diameter
Implementation of the Diameter Base Protocol RFC 6733 for C++ language
https://github.com/volkds/diameter
3gpp c-plus-plus cpp cpp17 diameter protocol rfc6733 signaling
Last synced: 10 months ago
JSON representation
Implementation of the Diameter Base Protocol RFC 6733 for C++ language
- Host: GitHub
- URL: https://github.com/volkds/diameter
- Owner: VolkDS
- License: mit
- Created: 2025-06-11T17:52:42.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-07-13T17:07:35.000Z (10 months ago)
- Last Synced: 2025-07-13T19:13:02.000Z (10 months ago)
- Topics: 3gpp, c-plus-plus, cpp, cpp17, diameter, protocol, rfc6733, signaling
- Language: C++
- Homepage:
- Size: 42 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Diameter Protocol Library
Library is an implementation of the Diameter Base Protocol [RFC 6733](http://tools.ietf.org/html/rfc6733) for C++ language
## Requirements
You need to install or clone [Netpacker Library](https://github.com/VolkDS/netpacker) for the project compilation
```
$ mkdir -p externals
$ git clone https://github.com/VolkDS/netpacker externals/netpacker
```
## Examples
Encode the Message
```c++
#include
#include
using namespace diameter::message;
// Create Diameter Message
Message m {
{
header::ProtocolVersion{header::ProtocolVersionV::V01},
header::MessageLength{0},
header::CommandFlags{0x80},
header::CommandCode{257},
header::ApplicationId{0},
header::HopByHopIdentifier{0x6ad1d314},
header::EndToEndIdentifier{0x77287404}
},
std::list{
avp::AVP{264, avp::Flags{avp::Flag::Mandatory}, std::nullopt, avp::DiameterIdentity("testhost.epc.mnc000.mcc000.3gppnetwork.org")},
avp::AVP{296, avp::Flags{avp::Flag::Mandatory}, std::nullopt, avp::DiameterIdentity("epc.mnc000.mcc000.3gppnetwork.org")},
avp::AVP{257, avp::Flags{avp::Flag::Mandatory}, std::nullopt, avp::Address("127.0.0.1")},
avp::AVP{266, avp::Flags{avp::Flag::Mandatory}, std::nullopt, avp::Unsigned32(uint32_t{10415})},
avp::AVP{269, avp::Flags{}, std::nullopt, avp::UTF8String("ExampleProduct")},
avp::AVP{258, avp::Flags{avp::Flag::Mandatory}, std::nullopt, avp::Unsigned32(uint32_t{4})},
avp::AVP{265, avp::Flags{avp::Flag::Mandatory}, std::nullopt, avp::Unsigned32(uint32_t{10415})}
}
};
// And serialize it
auto data = std::vector(m.size());
netpacker::put(data.begin(), data.end(), m);
```
Decode the message
```c++
// Receive some data
std::string hexed = \
"010000C080000101000000006AD1D314" \
"77287404000001084000003274657374" \
"686F73742E6570632E6D6E633030302E" \
"6D63633030302E336770706E6574776F" \
"726B2E6F726700000000012840000029" \
"6570632E6D6E633030302E6D63633030" \
"302E336770706E6574776F726B2E6F72" \
"67000000000001014000000E00017F00" \
"000100000000010A4000000C000028AF" \
"0000010D000000164578616D706C6550" \
"726F647563740000000001024000000C" \
"00000004000001094000000C000028AF";
std::vector data;
load_from_hex(hexed, data);
// And put it to decoder
auto pos = data.begin();
auto msg = netpacker::get(pos, data.end());
```
### Usage with CMake
If using CMake, you can use ```add_subdirectory``` for incorporate the library
directly in to one's CMake project.
```cmake
add_subdirectory(diameter)
```
And link to the library as follows.
```cmake
target_link_libraries(MyTarget diameter::diameter)
```