Files
openairinterface5g/openair3/NAS/TEST/AS_SIMULATOR/as_data.c
T
Robert Schmidt 6ae4ec37ca Remove most doxygen file-level commands, copyrights, and authors
Remove the \file directive, as it is always superfluous  because the
current file is implicit [1]:

> If the file name is omitted (i.e. the line after \file is left blank)
> then the documentation block that contains the \file command will belong
> to the file it is located in.

Author names and e-mails are not relevant for us: it can always be
inferred from git blame, and is often outdated.

Eurecom code has been contributed and was under OAI PL v1.0/v1.1.

For the cpack package contact: put generic email address that is
independent of an individual and that will remain reachable.

[1] https://www.doxygen.nl/manual/commands.html#cmdfile
2026-03-27 14:52:47 +01:00

156 lines
4.9 KiB
C

/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*****************************************************************************
Source as_data.c
Version 0.1
Date 2013/04/11
Product Access-Stratum sublayer simulator
Subsystem Access-Stratum data
Description Defines constants and functions used by the AS simulator
process.
*****************************************************************************/
#include "as_data.h"
#include "as_message.h"
#include <stdio.h> // snprintf
#include <time.h> // clock_gettime
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/*
* -----------------------------------------------------------------------------
* Time stamp generator
* -----------------------------------------------------------------------------
*/
const char* getTime(void)
{
#define TIME_BUFFER_SIZE 16
static char time_buffer[TIME_BUFFER_SIZE];
struct timespec ts;
clock_gettime (CLOCK_REALTIME, &ts);
snprintf(time_buffer, TIME_BUFFER_SIZE, "%.6ld:%.6ld",
ts.tv_sec % 3600, ts.tv_nsec / 1000);
return (time_buffer);
}
/*
* -----------------------------------------------------------------------------
* Return RRC establishment cause
* -----------------------------------------------------------------------------
*/
const char* rrcCause(char cause)
{
if (cause == AS_CAUSE_EMERGENCY) {
return "EMERGENCY";
} else if (cause == AS_CAUSE_HIGH_PRIO) {
return "HIGH_PRIORITY";
} else if (cause == AS_CAUSE_MT_ACCESS) {
return "MT_ACCESS";
} else if (cause == AS_CAUSE_MO_SIGNAL) {
return "MO_SIGNALLING";
} else if (cause == AS_CAUSE_MO_DATA) {
return "MO_DATA";
} else if (cause == AS_CAUSE_V1020) {
return "V1020";
} else {
return "Unknown";
}
}
/*
* -----------------------------------------------------------------------------
* Return RRC call type
* -----------------------------------------------------------------------------
*/
const char* rrcType(char type)
{
if (type == AS_TYPE_ORIGINATING_SIGNAL) {
return "ORIGINATING_SIGNAL";
} else if (type == AS_TYPE_EMERGENCY_CALLS) {
return "EMERGENCY_CALLS";
} else if (type == AS_TYPE_ORIGINATING_CALLS) {
return "ORIGINATING_CALLS";
} else if (type == AS_TYPE_TERMINATING_CALLS) {
return "TERMINATING_CALLS";
} else if (type == AS_TYPE_MO_CS_FALLBACK) {
return "MO_CS_FALLBACK";
} else {
return "Unknown";
}
}
/*
* -----------------------------------------------------------------------------
* Return Error Code
* -----------------------------------------------------------------------------
*/
const char* rrcErrCode(char code)
{
if (code == AS_SUCCESS) {
return "SUCCESS";
} else if (code == AS_TERMINATED_NAS) {
return "TERMINATED_NAS";
} else if (code == AS_TERMINATED_AS) {
return "TERMINATED_AS";
} else if (code == AS_FAILURE) {
return "FAILURE";
} else {
return "Unknown";
}
}
/*
* -----------------------------------------------------------------------------
* Return NAS release cause
* -----------------------------------------------------------------------------
*/
const char* rrcReleaseCause(char cause)
{
if (cause == AS_AUTHENTICATION_FAILURE) {
return "AUTHENTICATION FAILURE";
} else if (cause == AS_DETACH) {
return "DETACH";
} else {
return "Unknown";
}
}