Skip to content
SiddiqSoftPublic

About

SIP Parser for Modern C++

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

sip2json: A Focused SIP Parser for Modern C++

Build Status NuGet Version NuGet Downloads Tests C++20 License BSD-3

IETF RFC 3261 IETF RFC 4475 IETF RFC 8866 W3C WebRTC SDP

sip2json is a header-only Modern C++20 SIP protocol parser and serializer library designed with nlohmann::json as a first-class API metaphor for seamlessly converting SIP protocol messages to/from JSON for NoSQL databases and distributed event processing.


Documentation

siddiqsoft.github.io/sip2json


Quick Examples

Stream Parsing

#include <iostream>
#include "siddiqsoft/sip2json.hpp"

using namespace siddiqsoft;

void onNetworkDataReceived(std::string& tcpReadBuffer)
{
    // Asynchronously parse multiple SIP frames from buffer (erasing consumed bytes)
    sip2json::parseAsync(
        tcpReadBuffer,
        [](sipmessage&& msg) {
            std::cout << "Parsed " << msg.getMethod() << " Call-ID: " << msg.getCallID() << "\n";
            nlohmann::json doc = msg; // First-class JSON metaphor
        },
        [](const sip2json_exception& ex, auto& start, const auto& end) {
            std::cerr << "Parser warning: " << ex.what() << "\n";
        }
    );
}

Push to RabbitMQ

#include "siddiqsoft/sip2json.hpp"
#include <SimpleAmqpClient/SimpleAmqpClient.h>

using namespace siddiqsoft;

// Stream incoming SIP frames directly into a RabbitMQ exchange as JSON
auto channel = AmqpClient::Channel::Create("localhost");

sip2json::parseAsync(tcpReadBuffer, [&](sipmessage&& msg) {
    nlohmann::json doc = msg;
    auto body = AmqpClient::BasicMessage::Create(doc.dump());
    channel->BasicPublish("sip_events", std::string(msg.getMethod()), body);
});

Log to DuckDB

#include "siddiqsoft/sip2json.hpp"
#include <duckdb.hpp>

using namespace siddiqsoft;

// Stream incoming SIP traffic directly into DuckDB for columnar analytics
duckdb::DuckDB db("sip_analytics.db");
duckdb::Connection con(db);
con.Query("CREATE TABLE IF NOT EXISTS sip_traffic (method VARCHAR, call_id VARCHAR, payload JSON);");

duckdb::Appender appender(con, "sip_traffic");
sip2json::parseAsync(tcpReadBuffer, [&](sipmessage&& msg) {
    nlohmann::json doc = msg;
    appender.AppendRow(std::string(msg.getMethod()), std::string(msg.getCallID()), doc.dump());
});
appender.Flush();

Note

Use threadpool or async versions of specific SDKs to maximize performance.


Standards Compliance

sip2json is verified against official IETF specifications across dedicated automated test suites:

For full coverage matrices, section mappings, and torture test details, see the Standards Compliance Guide on our documentation site.

Note

Performance: High-throughput stream parsing with low microsecond latency -- see our pipeline-compiled Performance & Benchmarks Guide.


License

Licensed under the BSD 3-Clause License.

About

SIP Parser for Modern C++

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages