Copy latest code to master
[ric-plt/e2.git] / RIC-E2-TERMINATION / TEST / T1 / E2Setup.cpp
1 /*
2  * Copyright 2019 AT&T Intellectual Property
3  * Copyright 2019 Nokia
4  *
5  * Licensed under the Apache License, Version 2.0 (the "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  *      http://www.apache.org/licenses/LICENSE-2.0
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 // Created by adi ENZEL on 12/10/19.
20 //
21
22 #include "E2Builder.h"
23
24 #include "asn1cFiles/ProtocolIE-Field.h"
25
26 template<typename T>
27 X2SetupRequest_IEs_t *buildX2SetupIE(ProtocolIE_ID_t id,
28         Criticality_t criticality,
29         X2SetupRequest_IEs__value_PR present,
30         T *value) {
31     auto *x2SetupIE = (X2SetupRequest_IEs_t *)calloc(1, sizeof(X2SetupRequest_IEs_t));
32     x2SetupIE->id = id;
33     x2SetupIE->criticality = criticality;
34     x2SetupIE->value.present = present;
35
36     switch (present) {
37         case X2SetupRequest_IEs__value_PR_GlobalENB_ID: {
38             memcpy(&x2SetupIE->value.choice.GlobalENB_ID, value, sizeof(GlobalENB_ID_t));
39             break;
40         }
41         case X2SetupRequest_IEs__value_PR_ServedCells: {
42             memcpy(&x2SetupIE->value.choice.ServedCells, value, sizeof(ServedCells_t));
43             break;
44         }
45         case X2SetupRequest_IEs__value_PR_GUGroupIDList: {
46             memcpy(&x2SetupIE->value.choice.GUGroupIDList, value, sizeof(GUGroupIDList_t));
47             break;
48         }
49         case X2SetupRequest_IEs__value_PR_LHN_ID: {
50             memcpy(&x2SetupIE->value.choice.LHN_ID, value, sizeof(LHN_ID_t));
51             break;
52         }
53         case X2SetupRequest_IEs__value_PR_NOTHING:
54         default:
55             free(x2SetupIE);
56             x2SetupIE = nullptr;
57             break;
58     }
59     return x2SetupIE;
60 }
61
62 /**
63  *
64  * @param x2Setup
65  * @param member
66  */
67 void buildE2SetupRequest(X2SetupRequest_t *x2Setup, vector<X2SetupRequest_IEs_t> &member) {
68     for (auto v : member) {
69         ASN_SEQUENCE_ADD(&x2Setup->protocolIEs.list, &v);
70     }
71 }
72
73 void init_log() {
74     mdclog_attr_t *attr;
75     mdclog_attr_init(&attr);
76     mdclog_attr_set_ident(attr, "setup Request");
77     mdclog_init(attr);
78     mdclog_attr_destroy(attr);
79 }
80
81 int main(const int argc, char **argv) {
82     init_log();
83     //mdclog_level_set(MDCLOG_WARN);
84     //mdclog_level_set(MDCLOG_INFO);
85     mdclog_level_set(MDCLOG_DEBUG);
86
87 //    x2Setup   X2AP-ELEMENTARY-PROCEDURE ::= {
88 //            INITIATING MESSAGE                X2SetupRequest
89 //            SUCCESSFUL OUTCOME                X2SetupResponse
90 //            UNSUCCESSFUL OUTCOME      X2SetupFailure
91 //            PROCEDURE CODE                    id-x2Setup
92 //            CRITICALITY                               reject
93 //    }
94 //
95 //
96
97 //    X2SetupRequest ::= SEQUENCE {
98 //            protocolIEs               ProtocolIE-Container    {{X2SetupRequest-IEs}},
99 //            ...
100 //    }
101 //
102 //    X2SetupRequest-IEs X2AP-PROTOCOL-IES ::= {
103 //            { ID id-GlobalENB-ID                      CRITICALITY reject      TYPE GlobalENB-ID                       PRESENCE mandatory}|
104 //            { ID id-ServedCells                               CRITICALITY reject      TYPE ServedCells                        PRESENCE mandatory}|
105 //            { ID id-GUGroupIDList                     CRITICALITY reject      TYPE GUGroupIDList                      PRESENCE optional}|
106 //            { ID id-LHN-ID                                    CRITICALITY ignore      TYPE LHN-ID                                     PRESENCE optional},
107 //            ...
108 //    }
109
110
111
112 }