C++ helpers for parsing and rewriting EPS (TS 24.301 / S1AP) and 5GS (TS 24.501 / NGAP) NAS payloads.
Maintained by Melrose Networks.
cmake -S . -B build
cmake --build build
ctest --test-dir buildThe nas_app target is a small driver; library consumers should link nas_core.
nas_core is a static library (see CMakeLists.txt) with the NAS helper sources. Link it from your CMake project:
target_link_libraries(your_target PRIVATE nas_core)
target_include_directories(your_target PRIVATE /path/to/NAS)The library does not implement pseudonym policy or subscriber mapping. It:
- Enumerates replaceable identity value octets in a mutable PDU (
NASHelper::enumerateMobileIdentifiers). - Describes wire encoding (
NasMobileIdentifierEncoding,NasMobileIdentifierWireFormat) so callers can produce length-matched substitute octets (e.g. EPS TBCD, 5GS mobile identity with preserved first-octet type/odd-even). - Applies caller-supplied bytes at those offsets (
NASHelper::applyMobileIdentifierReplacements).
Typical flow: enumerate on the buffer you will patch → build replacements of the same length per occurrence → apply using the same occurrence list from enumeration. NASHelper::transformMobileIdentifiers combines enumerate → callback → apply; length mismatches fail without changing the PDU.
Only inner/plain identity fields are intended targets; outer security headers and MACs are not recomputed here.
nas_mobile_identifier_tests covers enumeration, replacement, and alignment with fill-based redaction on sample PDUs (tests/nas_mobile_identifier_tests.cpp).
See LICENSE (CC BY-NC 4.0).
Do not open pull requests that include secrets, credentials, or real network data that could identify subscribers. Keep any sample hex or traces synthetic.