-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNASHelperS1AP_DownlinkNasTransport.cpp
More file actions
38 lines (33 loc) · 1.63 KB
/
NASHelperS1AP_DownlinkNasTransport.cpp
File metadata and controls
38 lines (33 loc) · 1.63 KB
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
#include "NASHelperS1AP.hpp"
bool NASHelperS1AP::tryParseDownlinkNasTransportInformationElements(
const std::uint8_t* const informationElements,
const std::size_t informationElementOctetCount,
DownlinkNasTransportInformationElementsParse& out) {
out = DownlinkNasTransportInformationElementsParse{};
if (informationElements == nullptr ||
informationElementOctetCount < DownlinkNasTransportMandatoryFields::kNasMessageContainerLvMinTotalOctets) {
return false;
}
const std::uint8_t valueLen = informationElements[0];
const std::size_t totalLv = 1U + static_cast<std::size_t>(valueLen);
if (totalLv < DownlinkNasTransportMandatoryFields::kNasMessageContainerLvMinTotalOctets ||
totalLv > DownlinkNasTransportMandatoryFields::kNasMessageContainerLvMaxTotalOctets) {
return false;
}
if (informationElementOctetCount < totalLv) {
return false;
}
out.mandatory.nas_message_container_value = informationElements + 1U;
out.mandatory.nas_message_container_value_octet_count = static_cast<std::size_t>(valueLen);
out.mandatory.mandatory_total_octets = totalLv;
out.unparsed_begin = informationElements + totalLv;
out.unparsed_octet_count = informationElementOctetCount - totalLv;
out.ok = true;
return true;
}
bool NASHelperS1AP::tryParseUplinkNasTransportInformationElements(
const std::uint8_t* const informationElements,
const std::size_t informationElementOctetCount,
UplinkNasTransportInformationElementsParse& out) {
return tryParseDownlinkNasTransportInformationElements(informationElements, informationElementOctetCount, out);
}