Modify licenses
[scp/ocu/5gnr.git] / Include / ngu.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 ICT/CAS.
4 *
5 *   Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       https://www.o-ran.org/software
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19
20 #ifndef NG_U_H
21 #define NG_U_H
22
23 #include "vos_lib.h"
24 #include "cuupCommon.h"
25 #include "plat_syslog.h"
26
27 #define DL_PDU_SESSION_INFORMATION      0       /* NGU DL PDU type */
28 #define UL_PDU_SESSION_INFORMATION      1       /* NGU UL PDU type */
29
30 #define NGU_FREE(p) if(NULL != p)\
31                                         {\
32                                                 VOS_Free(p);\
33                                                 p = NULL;\
34                                         }
35
36 #define nguLog(iLog_Level, content, arg...) \
37         VOS_SysLog(gNguModuleId, iLog_Level, __FILE__, __LINE__, __func__, content, ##arg);
38
39 #define nguNullCheck(p) \
40 {\
41    if(NULL == p)\
42    {\
43            nguLog(LOG_ERR, "[NGU] NULL pointer\n");\
44        return VOS_ERROR;\
45    }\
46 }
47
48 #define nguGetInstance(ueIdx,pduSessId,p) \
49 {\
50         if((NULL == gNguUeInfo[ueIdx])\
51                 || (NULL == gNguUeInfo[ueIdx]->nguInstance[pduSessId]))\
52         {\
53                 p = NULL;\
54         }else\
55         {\
56                 p = gNguUeInfo[ueIdx]->nguInstance[pduSessId];\
57         }\
58 }
59
60 #define nguDlDataCheck(p)       if(NULL == p)\
61                                                         {\
62                                                                 nguLog(LOG_ERR,"[NGU] input is NULL!\n");\
63                                                                 return VOS_ERROR;\
64                                                         }else if(NULL==p->pMsgBuff)\
65                                                         {\
66                                                                 nguLog(LOG_ERR,"[NGU] p->pMsgBuff in input is NULL!\n");\
67                                                                 return VOS_ERROR;\
68                                                         }\
69
70 #define nguExPduCheck(p)        if(NULL == p)\
71                                                         {\
72                                                                 nguLog(LOG_ERR,"[NGU] ex pdu is null\n");\
73                                                                 return VOS_ERROR;\
74                                                         }else if( (GTP_EXT_PDUSESSION_CONTAINER!=p->exHdrType) || (NULL==p->pPdu) || (p->len<=0))\
75                                                         {\
76                                                                 nguLog(LOG_ERR,"[NGU] ex pdu is wrong\n");\
77                                                                 return VOS_ERROR;\
78                                                         }
79
80 #define nguDlDataFree(p) \
81 {\
82         if(NULL != p)\
83         {\
84                 if(NULL != p->pExPduInfo)\
85                 {\
86                         if(NULL != p->pExPduInfo->pPdu)\
87                         {\
88                                 NGU_FREE(p->pExPduInfo->pPdu);\
89                                 p->pExPduInfo->pPdu = NULL;\
90                         }\
91                         NGU_FREE(p->pExPduInfo);\
92                         p->pExPduInfo = NULL;\
93                 }\
94                 NGU_FREE(p);\
95                 p = NULL;\
96         }\
97 }
98
99
100
101 typedef struct
102 {
103         UINT64                  ueE1apId;
104         UINT16                  ueIdx;
105         UINT16                  pduSessionId;
106         UINT32                  ownTeid;
107 }NguInstance_t;
108
109
110 typedef struct
111 {
112         UINT16                          ueIdx;
113         UINT64                          ueE1apId;
114         CuupBearerStatus_e      ueStatus;
115         NguInstance_t           *nguInstance[CUUP_MAX_SESSION_NUM];
116 }NguUeInfo_t;
117
118
119 typedef struct dlPduSessInfo
120 {
121         UINT8 exHdrLen;         /* gtp extension head length:2 */
122         UINT8 spare1 :4;        /* spare: 0 */
123         UINT8 pduType :4;       /* pdu type:0 */
124         UINT8 qfi :6;           /* qfi */
125         UINT8 rqi :1;
126         UINT8 ppp :1;
127         UINT8 spare2 :5;
128         UINT8 ppi :3;
129         UINT8 padding[3];
130         UINT8 nextExHdrType;/* next extension head type:0 */
131 }DlPduSessInfo_t;
132
133 typedef struct ulPduSessInfo
134 {
135         UINT8 exHdrLen;         /* gtp extension head length:1 */
136         UINT8 spare1 :4;        /* spare: 0 */
137         UINT8 pduType :4;       /* pdu type:1 */
138         UINT8 qfi :6;           /* qfi */
139         UINT8 spare2 :2;
140         UINT8 nextExHdrType;/* next extension head type:0 */
141 }UlPduSessInfo_t;
142
143
144 #endif /* NG_U_H */