/
M5GDeRegistrationAcceptUEInit.cpp
107 lines (99 loc) · 3.98 KB
/
M5GDeRegistrationAcceptUEInit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
Copyright 2020 The Magma Authors.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
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.
*/
#include <iostream>
#include <sstream>
#ifdef __cplusplus
extern "C" {
#endif
#include "lte/gateway/c/core/oai/common/log.h"
#ifdef __cplusplus
}
#endif
#include "lte/gateway/c/core/oai/tasks/nas5g/include/M5GDeRegistrationAcceptUEInit.hpp"
#include "lte/gateway/c/core/oai/tasks/nas5g/include/M5GCommonDefs.h"
namespace magma5g {
DeRegistrationAcceptUEInitMsg::DeRegistrationAcceptUEInitMsg(){};
DeRegistrationAcceptUEInitMsg::~DeRegistrationAcceptUEInitMsg(){};
// Decoding De Registration Accept Message and its IEs
int DeRegistrationAcceptUEInitMsg::DecodeDeRegistrationAcceptUEInitMsg(
DeRegistrationAcceptUEInitMsg* de_reg_accept, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0;
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, DEREGISTRATION_ACCEPT_UEINIT_MINIMUM_LENGTH, len);
if ((decoded_result = de_reg_accept->extended_protocol_discriminator
.DecodeExtendedProtocolDiscriminatorMsg(
&de_reg_accept->extended_protocol_discriminator,
0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = de_reg_accept->spare_half_octet.DecodeSpareHalfOctetMsg(
&de_reg_accept->spare_half_octet, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result =
de_reg_accept->sec_header_type.DecodeSecurityHeaderTypeMsg(
&de_reg_accept->sec_header_type, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = de_reg_accept->message_type.DecodeMessageTypeMsg(
&de_reg_accept->message_type, 0, buffer + decoded, len - decoded)) <
0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
};
// Encoding De Registration Accept Message and its IEs
int DeRegistrationAcceptUEInitMsg::EncodeDeRegistrationAcceptUEInitMsg(
DeRegistrationAcceptUEInitMsg* de_reg_accept, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length
// expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, DEREGISTRATION_ACCEPT_UEINIT_MINIMUM_LENGTH, len);
if ((encoded_result = de_reg_accept->extended_protocol_discriminator
.EncodeExtendedProtocolDiscriminatorMsg(
&de_reg_accept->extended_protocol_discriminator,
0, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
if ((encoded_result = de_reg_accept->spare_half_octet.EncodeSpareHalfOctetMsg(
&de_reg_accept->spare_half_octet, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
if ((encoded_result =
de_reg_accept->sec_header_type.EncodeSecurityHeaderTypeMsg(
&de_reg_accept->sec_header_type, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
if ((encoded_result = de_reg_accept->message_type.EncodeMessageTypeMsg(
&de_reg_accept->message_type, 0, buffer + encoded, len - encoded)) <
0)
return encoded_result;
else
encoded += encoded_result;
return encoded;
};
} // namespace magma5g