lte/gateway/c/core/oai/tasks/amf/nas5g_message.cpp
/****************************************************************************
 **                                                                        **
 ** Name:  _nas5g_message_plain_encode()                                   **
 **                                                                        **
 ** Description: Encode plain NAS message                                  **
 **                                                                        **
 ** Inputs:    pd:    Protocol discriminator of the NAS message            **
 *  *                 to encode                                            **
 **            msg:   Plain NAS message structure to encode                **
 **          length:  Maximal capacity of the output buffer                **
 **          Others:  None                                                 **
 **                                                                        **
 ** Outputs:   buffer:  Pointer to the encoded data buffer                 **
 **            Return:  The number of bytes in the buffer if the           **
 **                     data have been successfully encoded;               **
 **                     A negative error code otherwise.                   **
 **            Others:  None                                               **
 **                                                                        **
 ***************************************************************************/


Encode plain NAS message

Protocol discriminator of the NAS message
to encode
msg:   Plain NAS message structure to encode
length:  Maximal capacity of the output buffer
Others:  None

Pointer to the encoded data buffer
Return:  The number of bytes in the buffer if the
data have been successfully encoded;
A negative error code otherwise.
Others:  None
Encode plain NAS message Protocol discriminator of the NAS message to encode msg : Plain NAS message structure to encode length : Maximal capacity of the output buffer Others : None Pointer to the encoded data buffer Return : The number of bytes in the buffer if the data have been successfully encoded ; A negative error code otherwise . Others : None
int _nas5g_message_plain_encode(
    unsigned char* buffer, const amf_msg_header* header,
    const nas_message_plain_t* msg, uint32_t length) {
  OAILOG_FUNC_IN(LOG_AMF_APP);
  int bytes = TLV_PROTOCOL_NOT_SUPPORTED;
  AmfMsg amf_msg_test;
  if (M5GS_MOBILITY_MANAGEMENT_MESSAGE ==
      msg->amf.header.extended_protocol_discriminator) {
    bytes = amf_msg_test.M5gNasMessageEncodeMsg(
        (AmfMsg*) &msg->amf, (uint8_t*) buffer, length);
    if (bytes < 0) {
      OAILOG_WARNING(LOG_AMF_APP, "Encoding Message Failed");
      OAILOG_FUNC_RETURN(LOG_AMF_APP, bytes);
    }
    OAILOG_DEBUG(
        LOG_AMF_APP, "[%s] Msg plain encode bytes[0-%d]\n%s",
        get_message_type_str(msg->amf.header.message_type).c_str(), bytes,
        uint8_to_hex_string(buffer, bytes).c_str());
  } else {
    OAILOG_WARNING(
        LOG_AMF_APP,
        "NET-API   - Protocol discriminator 0x%x is "
        "not supported\n",
        header->extended_protocol_discriminator);
  }
  OAILOG_FUNC_RETURN(LOG_AMF_APP, bytes);
}
int _nas5g_message_plain_encode ( unsigned char * buffer , const amf_msg_header * header , const nas_message_plain_t * msg , uint32_t length ) { OAILOG_FUNC_IN ( LOG_AMF_APP ) ; int bytes = TLV_PROTOCOL_NOT_SUPPORTED ; AmfMsg amf_msg_test ; if ( M5GS_MOBILITY_MANAGEMENT_MESSAGE == msg -> amf . header . extended_protocol_discriminator ) { bytes = amf_msg_test . M5gNasMessageEncodeMsg ( ( AmfMsg * ) & msg -> amf , ( uint8_t * ) buffer , length ) ; if ( bytes < 0 ) { OAILOG_WARNING ( LOG_AMF_APP , " " ) ; OAILOG_FUNC_RETURN ( LOG_AMF_APP , bytes ) ; } OAILOG_DEBUG ( LOG_AMF_APP , " \n " , get_message_type_str ( msg -> amf . header . message_type ) . c_str ( ) , bytes , uint8_to_hex_string ( buffer , bytes ) . c_str ( ) ) ; } else { OAILOG_WARNING ( LOG_AMF_APP , " " " \n " , header -> extended_protocol_discriminator ) ; } OAILOG_FUNC_RETURN ( LOG_AMF_APP , bytes ) ; }
Name:  _nas5g_message_plain_encode()
Name : _nas5g_message_plain_encode ()
/*
     * Encode Mobility Management L3 message
     */ /*
     * Discard L3 messages with not supported protocol discriminator
     */