TOP

Application Skeleton

Applies to: NAS/C++ LTE/EPC r14.4.0 v6.2.1

As an example, here is a skeleton of a simple application using the OSS NAS Tools for C++. 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::v1440; /* 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++ API, and how an application using this API should be compiled and linked, can be found in the /samples subdirectory of the OSS NAS Tools for C++ product installation.


This documentation applies to the OSS NAS Tools for C++ for LTE/EPC v6.2.1 for 3GPP Release 14.4.0.

Copyright © 2024 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 OSS NAS Tools for C++ for LTE/EPC is associated with a specific license and related unique license number. That license determines, among other things, what functions of the OSS NAS Tools for C++ for LTE/EPC are available to you.