Engine/ASN1Message

Purpose

The ASN1Message is an ASN.1 based general message format for encoding messages. It is derived from struct _message in the p≡p engine.

The ASN1Message can be used in all p≡p based protocols where a binary message format or a simplistic XML message format is required, because the ASN.1 implementation of the p≡p engine provides BER, PER and XER encoding.

ASN.1 definition

The ASN.1 definition is in asn.1/message.asn1.

API

The ASN1Message API is part of p≡p API. It can be found in map_asn1.h and message_codec.h.

Converting a struct _message to ASN1Message and serializing using PER

char *data = NULL;
size_t data_size = 0;

ASN1Message_t *pm = ASN1Message_from_message(msg, NULL, false, 10240000);
if (pm) {
    status = encode_ASN1Message_message(pm, &data, &data_size);
    if (status)
        goto error;
}
else {
    status = PEP_OUT_OF_MEMORY;
    goto error;
}

Deserializing PER encoded data and converting to struct _message

ASN1Message_t *pm = NULL;
status = decode_ASN1Message_message(data, data_size, &pm);
if (status)
    goto error;

message *msg = ASN1Message_to_message(pm, NULL, false, 10240000);
if (!msg) {
    status = PEP_OUT_OF_MEMORY;
    goto error;
}