lte/gateway/c/core/oai/tasks/amf/nas5g_message.cpp
/****************************************************************************
 **                                                                        **
 ** Name:  _nas5g_message_protected_decode()                               **
 **                                                                        **
 ** Description: Decode security protected NAS message                     **
 **                                                                        **
 ** Inputs:  buffer:  Pointer to the buffer containing the secu-           **
 **                   rity protected NAS message data                      **
 **          header:  Header of the security protected NAS message         **
 **          length:  Number of bytes that should be decoded               **
 **                   amf_security_context: security context               **
 **          Others:  None                                                 **
 **                                                                        **
 ** Outputs:   msg:     Decoded NAS message                                **
 **            Return:  The number of bytes in the buffer if the           **
 **                     data have been successfully decoded;               **
 **                     A negative error code otherwise.                   **
 **            Others:  None                                               **
 **                                                                        **
 ***************************************************************************/


Decode security protected NAS message

Pointer to the buffer containing the secu
rity protected NAS message data
header:  Header of the security protected NAS message
length:  Number of bytes that should be decoded
amf_security_context: security context
Others:  None

Decoded NAS message
Return:  The number of bytes in the buffer if the
data have been successfully decoded;
A negative error code otherwise.
Others:  None
Decode security protected NAS message Pointer to the buffer containing the secu rity protected NAS message data header : Header of the security protected NAS message length : Number of bytes that should be decoded amf_security_context : security context Others : None Decoded NAS message Return : The number of bytes in the buffer if the data have been successfully decoded ; A negative error code otherwise . Others : None
static int _nas5g_message_protected_decode(
    unsigned char* const buffer, amf_msg_header* header,
    nas_message_plain_t* msg, uint32_t length,
    amf_security_context_t* const amf_security_context,
    amf_nas_message_decode_status_t* const status) {
  OAILOG_FUNC_IN(LOG_AMF_APP);
  int bytes                      = TLV_BUFFER_TOO_SHORT;
  unsigned char* const plain_msg = (unsigned char*) calloc(1, length);
  if (plain_msg) {
    header->extended_protocol_discriminator = _nas5g_message_decrypt(
        plain_msg, buffer, header->security_header_type,
        header->message_authentication_code, header->sequence_number, length,
        amf_security_context, status);
    bytes = _nas5g_message_plain_decode(plain_msg, header, msg, length);
    free(plain_msg);
  }
  OAILOG_FUNC_RETURN(LOG_AMF_APP, bytes);
}
static int _nas5g_message_protected_decode ( unsigned char * const buffer , amf_msg_header * header , nas_message_plain_t * msg , uint32_t length , amf_security_context_t * const amf_security_context , amf_nas_message_decode_status_t * const status ) { OAILOG_FUNC_IN ( LOG_AMF_APP ) ; int bytes = TLV_BUFFER_TOO_SHORT ; unsigned char * const plain_msg = ( unsigned char * ) calloc ( 1 , length ) ; if ( plain_msg ) { header -> extended_protocol_discriminator = _nas5g_message_decrypt ( plain_msg , buffer , header -> security_header_type , header -> message_authentication_code , header -> sequence_number , length , amf_security_context , status ) ; bytes = _nas5g_message_plain_decode ( plain_msg , header , msg , length ) ; free ( plain_msg ) ; } OAILOG_FUNC_RETURN ( LOG_AMF_APP , bytes ) ; }
Name:  _nas5g_message_protected_decode()
Name : _nas5g_message_protected_decode ()
/*
     * Decrypt the security protected NAS message
     */ /*
     * Decode the decrypted message as plain NAS message
     */