O-CU-UP
[scp/ocu/5gnr.git] / Include / ngu.h
1 /******************************************************************************
2 ###############################################################################
3 #   Copyright (c) [2017-2020] [ICT/CAS]                                        #
4 #   Licensed under the ORAN Software License v1.0 (License)             #
5 ###############################################################################
6 ******************************************************************************/
7
8 #ifndef NG_U_H
9 #define NG_U_H
10
11 #include "vos_lib.h"
12 #include "cuupCommon.h"
13 #include "plat_syslog.h"
14
15 #define DL_PDU_SESSION_INFORMATION      0       /* NGU DL PDU type */
16 #define UL_PDU_SESSION_INFORMATION      1       /* NGU UL PDU type */
17
18 #define NGU_FREE(p) if(NULL != p)\
19                                         {\
20                                                 VOS_Free(p);\
21                                                 p = NULL;\
22                                         }
23
24 #define nguLog(iLog_Level, content, arg...) \
25         VOS_SysLog(gNguModuleId, iLog_Level, __FILE__, __LINE__, __func__, content, ##arg);
26
27 #define nguNullCheck(p) \
28 {\
29    if(NULL == p)\
30    {\
31            nguLog(LOG_ERR, "[NGU] NULL pointer\n");\
32        return VOS_ERROR;\
33    }\
34 }
35
36 #define nguGetInstance(ueIdx,pduSessId,p) \
37 {\
38         if((NULL == gNguUeInfo[ueIdx])\
39                 || (NULL == gNguUeInfo[ueIdx]->nguInstance[pduSessId]))\
40         {\
41                 p = NULL;\
42         }else\
43         {\
44                 p = gNguUeInfo[ueIdx]->nguInstance[pduSessId];\
45         }\
46 }
47
48 #define nguDlDataCheck(p)       if(NULL == p)\
49                                                         {\
50                                                                 nguLog(LOG_ERR,"[NGU] input is NULL!\n");\
51                                                                 return VOS_ERROR;\
52                                                         }else if(NULL==p->pMsgBuff)\
53                                                         {\
54                                                                 nguLog(LOG_ERR,"[NGU] p->pMsgBuff in input is NULL!\n");\
55                                                                 return VOS_ERROR;\
56                                                         }\
57
58 #define nguExPduCheck(p)        if(NULL == p)\
59                                                         {\
60                                                                 nguLog(LOG_ERR,"[NGU] ex pdu is null\n");\
61                                                                 return VOS_ERROR;\
62                                                         }else if( (GTP_EXT_PDUSESSION_CONTAINER!=p->exHdrType) || (NULL==p->pPdu) || (p->len<=0))\
63                                                         {\
64                                                                 nguLog(LOG_ERR,"[NGU] ex pdu is wrong\n");\
65                                                                 return VOS_ERROR;\
66                                                         }
67
68 #define nguDlDataFree(p) \
69 {\
70         if(NULL != p)\
71         {\
72                 if(NULL != p->pExPduInfo)\
73                 {\
74                         if(NULL != p->pExPduInfo->pPdu)\
75                         {\
76                                 NGU_FREE(p->pExPduInfo->pPdu);\
77                                 p->pExPduInfo->pPdu = NULL;\
78                         }\
79                         NGU_FREE(p->pExPduInfo);\
80                         p->pExPduInfo = NULL;\
81                 }\
82                 NGU_FREE(p);\
83                 p = NULL;\
84         }\
85 }
86
87
88
89 typedef struct
90 {
91         UINT64                  ueE1apId;
92         UINT16                  ueIdx;
93         UINT16                  pduSessionId;
94         UINT32                  ownTeid;        
95 }NguInstance_t; 
96
97
98 typedef struct
99 {       
100         UINT16                          ueIdx;
101         UINT64                          ueE1apId;
102         CuupBearerStatus_e      ueStatus;
103         NguInstance_t           *nguInstance[CUUP_MAX_SESSION_NUM];
104 }NguUeInfo_t;
105
106
107 typedef struct dlPduSessInfo
108 {
109         UINT8 exHdrLen;         /* gtp extension head length:2 */
110         UINT8 spare1 :4;        /* spare: 0 */
111         UINT8 pduType :4;       /* pdu type:0 */
112         UINT8 qfi :6;           /* qfi */
113         UINT8 rqi :1;
114         UINT8 ppp :1;
115         UINT8 spare2 :5;
116         UINT8 ppi :3;
117         UINT8 padding[3];
118         UINT8 nextExHdrType;/* next extension head type:0 */
119 }DlPduSessInfo_t;
120
121 typedef struct ulPduSessInfo
122 {
123         UINT8 exHdrLen;         /* gtp extension head length:1 */
124         UINT8 spare1 :4;        /* spare: 0 */
125         UINT8 pduType :4;       /* pdu type:1 */
126         UINT8 qfi :6;           /* qfi */
127         UINT8 spare2 :2;
128         UINT8 nextExHdrType;/* next extension head type:0 */
129 }UlPduSessInfo_t;
130
131
132 #endif /* NG_U_H */