msc.h 4.47 KB
Newer Older
1 2 3 4 5
/*
 * 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
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 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
 */

22 23 24
#ifndef MSC_H_
#define MSC_H_
#include <stdarg.h>
25
#include <stdint.h>
26

27
typedef enum {
Lionel Gauthier's avatar
Lionel Gauthier committed
28 29
	MIN_MSC_ENV = 0,
    MSC_E_UTRAN = MIN_MSC_ENV,
Lionel Gauthier's avatar
Lionel Gauthier committed
30
    MSC_E_UTRAN_LIPA,
31
    MSC_MME_GW,
Lionel Gauthier's avatar
Lionel Gauthier committed
32 33
    MSC_MME,
    MSC_SP_GW,
34 35 36 37
    MAX_MSC_ENV
} msc_env_t;


38 39
typedef enum {
    MIN_MSC_PROTOS = 0,
40 41
    MSC_IP_UE = MIN_MSC_PROTOS,
    MSC_NAS_UE,
42 43 44 45 46 47 48 49 50 51
    MSC_RRC_UE,
    MSC_PDCP_UE,
    MSC_RLC_UE,
    MSC_MAC_UE,
    MSC_PHY_UE,
    MSC_PHY_ENB,
    MSC_MAC_ENB,
    MSC_RLC_ENB,
    MSC_PDCP_ENB,
    MSC_RRC_ENB,
52
    MSC_IP_ENB,
53 54 55 56
    MSC_S1AP_ENB,
    MSC_GTPU_ENB,
    MSC_GTPU_SGW,
    MSC_S1AP_MME,
57
    MSC_MMEAPP_MME,
58
    MSC_NAS_MME,
59 60
    MSC_NAS_EMM_MME,
    MSC_NAS_ESM_MME,
Lionel Gauthier's avatar
Lionel Gauthier committed
61 62
    MSC_SP_GWAPP_MME,
    MSC_S11_MME,
63 64 65
    MSC_S6A_MME,
    MSC_HSS,
    MAX_MSC_PROTOS,
66 67
    MSC_X2AP_SRC_ENB,
    MSC_X2AP_TARGET_ENB,
68 69
} msc_proto_t;

70 71


72 73 74 75 76 77
// Access stratum
#define MSC_AS_TIME_FMT "%05u:%02u"

#define MSC_AS_TIME_ARGS(CTXT_Pp) \
    (CTXT_Pp)->frame, \
    (CTXT_Pp)->subframe
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

typedef int(*msc_init_t)(const msc_env_t, const int );
typedef void(*msc_start_use_t)(void );
typedef void(*msc_end_t)(void);
typedef void(*msc_log_event_t)(const msc_proto_t,char *, ...);
typedef void(*msc_log_message_t)(const char *   const, const msc_proto_t, const msc_proto_t, 
                                 const uint8_t* const, const unsigned int, char * , ...);
typedef struct msc_interface {
    int               msc_loaded;
    msc_init_t        msc_init;
    msc_start_use_t   msc_start_use;
    msc_end_t         msc_end;
    msc_log_event_t   msc_log_event;
    msc_log_message_t msc_log_message;
} msc_interface_t;

#ifdef MSC_LIBRARY
95 96
int msc_init(const msc_env_t envP, const int max_threadsP);
void msc_start_use(void);
97
void msc_flush_messages(void);
98 99 100
void msc_end(void);
void msc_log_declare_proto(const msc_proto_t  protoP);
void msc_log_event(const msc_proto_t  protoP,char *format, ...);
101 102
void msc_log_message(
	const char * const message_operationP,
103 104
    const msc_proto_t  receiverP,
    const msc_proto_t  senderP,
105
    const uint8_t* const bytesP,
106 107
    const unsigned int num_bytes,
    char *format, ...);
108

109
#else
110 111 112 113 114 115 116 117 118 119

msc_interface_t msc_interface;
#define MSC_INIT(arg1,arg2)                                     if(msc_interface.msc_loaded) msc_interface.msc_init(arg1,arg2)
#define MSC_START_USE                                           if(msc_interface.msc_loaded) msc_interface.msc_start_use
#define MSC_END                                                 if(msc_interface.msc_loaded) msc_interface.msc_end
#define MSC_LOG_EVENT(mScPaRaMs, fORMAT, aRGS...)               if(msc_interface.msc_loaded) msc_interface.msc_log_event(mScPaRaMs, fORMAT, ##aRGS)
#define MSC_LOG_RX_MESSAGE(rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, aRGS...)           if(msc_interface.msc_loaded) msc_interface.msc_log_message("<-",rECEIVER, sENDER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
#define MSC_LOG_RX_DISCARDED_MESSAGE(rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, aRGS...) if(msc_interface.msc_loaded) msc_interface.msc_log_message("x-",rECEIVER, sENDER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
#define MSC_LOG_TX_MESSAGE(sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, aRGS...)           if(msc_interface.msc_loaded) msc_interface.msc_log_message("->",sENDER, rECEIVER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
#define MSC_LOG_TX_MESSAGE_FAILED(sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, aRGS...)    if(msc_interface.msc_loaded) msc_interface.msc_log_message("-x",sENDER, rECEIVER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
120
#endif
121 122

#endif