TOP

Application Skeleton

Applies to: NAS/C++ 5G r15.2.1 v7.0.0

As an example, here is a skeleton of a simple application using the OSS NAS/C++ 5G Encoder/Decoder. The application receives some input message, decodes it, creates an output message, encodes it, sends it to the peer, and repeats the same sequence until some condition is met.

use namespace OssNas;
use namespace OssNas::v5GS1521; /* Use another namespace to handle other NAS versions */

/* initialization */
OssNasCoder<NASMessage> coder;
OssString input_buffer;   /* buffer for input message in encoded form */ 
const NASMessage *input_msg; /* input message in decoded form */
NASMessage output_msg; /* output message in unencoded form */
OssString *output_buffer; /* buffer for output message in encoded form */

do {
    /* some code to read the input message into input_buffer */
    ...

    /* decode */
    try {
        /* decode the message from input_buffer */
        input_msg = coder.decode(input_buffer);
        /* some code to create the response and place it to output_msg */
        ...
        /* delete the decoded message if it is not needed */
        coder.deleteDecoded(input_msg);
    } catch (OssNasException & e) {
        /* some code to handle the error */
        ...
        /* some code to create the response and place it to output_msg */
        ...
    }

    /* encode the response */
    try {
        /* encode the response message to output_buffer */
        coder.encode(output_msg, &output_buffer, NULL);
        /* some code to send the response */
        ...
        /* delete the encoded response message */
        delete output_buffer;
    } catch (OssNasException & e) {
        /* some code to handle the error */
        ...
    }
} while (/* some code to check the exit condition */);

The input_buffer, output_msg, and coder objects are properly deallocated and deinitialized by destructors. There is no need for the programmer to do anything explicitly.

The complete example that demonstrates the OSS NAS/C++ 5G API, and how an application using this API should be compiled and linked, can be found in the /samples subdirectory of the OSS NAS/C++ Encoder/Decoder shipment.


This documentation applies to the NAS/C++ Encoder Decoder Library for 5G v7.0.0 for 3GPP Release 15.2.1.

Copyright © 2020 OSS Nokalva, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise, without the prior permission of OSS Nokalva, Inc.
Every distributed copy of the NAS/C++ Encoder Decoder Library for 5G is associated with a specific license and related unique license number. That license determines, among other things, what functions of the NAS/C++ Encoder Decoder Library for 5G are available to you.