lixen-wg2 / otc

Erlang/OTC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Erlang/OTC - Open Telecom Codec

This library tries to implement encoding and decoding for different telco protocols. The aim is to support the newest release of each spec, if not stated otherwise.

Encoded format is a binary, and decoded format is a map.

If a field or message is not supported, the library should not crash but instead return some error-tuple or atom.

Decoding should preferably be strict, and follow the rules from the specification. Encoding on the other hand, should be lenient, but if format is incorrect, then log a warning. The idea behind this is that the user knows best what to send, but might need guidance.

Usage

otc can be called with both decode/2, decode/3, as well as decapsulate/2, decapsulate/3 functions. The differens is that decapsulate will crash on errors while decode returns an error-tuple.

In successful cases `decode` will return an ok-tuple containing either (only) a list of headers if the binary was fully decoded, or both a list of decoded headers, and a binary containing the parts it was not able to decode.

“` 1> otc:decode(m2pa, UserBinary). {ok, {[#{protocol := m2pa, ..}, #{protocol := mtp3, ..}, #{protocol := sccp, ..}], <<SCCPPayload>>}}

2> otc:decode(m2pa, UserBinary, #{stop_after > mtp3}). {ok, {[#{protocol : m2pa, ..}, #{protocol := mtp3, ..}], <<MTP3Payload>>}}

3> otc:decode(m2pa, LinkBinary). {ok, [#{protocol := m2pa, ..}]}

4> otc:decapsulate(m2pa, UserBinary). {[#{protocol := m2pa, ..}, #{protocol := mtp3, ..}, #{protocol := sccp, ..}], <<SCCPPayload>>}

5> otc:decapsulate(m2pa, UserBinary, #{stop_after > mtp3}). {[#{protocol : m2pa, ..}, #{protocol := mtp3, ..}], <<MTP3Payload>>}

6> otc:decapsulate(m2pa, LinkBinary). [#{protocol := m2pa, ..}] “`

For encoding there is only one function encode/1, but it can take multiple different types of inputs.

“` 11> otc:encode(#{protocol => m2pa, ..}). <<M2PABinary>>

12> otc:encode([#{protocol => m2pa, ..}, #{protocol => mtp3, ..}]). <<M2PABinary>>

13> otc:encode({[#{protocol => m2pa, ..}], <<M2PAPayload>>}). <<M2PABinary>> “`

Examples are given with m2pa codec, but could be used with any of the supported protocols. See [tests](test/otc_tests.erl)

Linguistics

decode - function that converts from binary format to an Erlang map

decapsulate - as decode, but crashes on errors.

parse - function that converts from UMTS magic number to Erlang atom

encode - function that converts from Erlang map to binary format

compose - function that converts from Erlang atom to UMTS magic number

*_codec - modules used as helpers, does not comply with the pkt-style codecs.

Codecs

NameSpecEncodeDecodeProduction TestedNotes
M3UAIETF RFC 4666 September 2006XX
M2PAIETF RFC 4165 September 2005XX
MTP3ITU-T Q.704 (07/96) July 1996XX
SCCPITU-T Q.713 (03/2001)XX
L33GPP TS 24.007 v16.5.0XX
NAS EPS3GPP TS 24.301 v16.8.0//Messages are de-/encoded, but missing parameters
NAS 5GS3GPP TS 24.501 v16.10.0//Messages are de-/encoded, but missing parameters
SGSAP3GPP TS 29.118 v16.0.0

Diameter dictionaries

NameSpecInterfacesDone
BaseIETF RFC 6733
S63GPP TS 29.272 v16.4.0S6a, S6d
S73GPP TS 29.272 v16.4.0S7a, S7d
S133GPP TS 29.272 v16.4.0S13, S13’
SLh3GPP TS 29.173 v16.0.0SLh
Ro3GPP TS 32.299 v16.2.0
Rf3GPP TS 32.299 v16.2.0
Gxx3GPP TS 29.212 v16.4.0Gx
Sd3GPP TS 29.212 v16.4.0Gx
St3GPP TS 29.212 v16.4.0Gx
Rx3GPP TS 29.214 v16.6.0
Sy3GPP TS 29.219 v16.0.0Sy
PLMN-PDN3GPP TS 29.061 v16.4.0
S6mn3GPP TS 29.336 v16.3.0S6m, S6n
S6t3GPP TS 29.336 v16.3.0S6t
Cx3GPP TS 29.229 v16.2.0Cx
Dx3GPP TS 29.229 v16.2.0Dx

ASN.1

NameSpecNote
MAP v1GSM 09.02 v4.9.1/ETS 300.599 01-60correct spec?
MAP v2GSM 09.02 v4.19.1/ETS 300.599 09-60correct spec?
MAP v3
MAP v43GPP TS 29.002 v16.3.0
CAP v1GSM Phase 2+ R96
CAP v2GSM 03.78/3GPP TS 01.441 v7.8.1
CAP v33GPP TS 23.078 v4.11.1
CAP v43GPP TS 23.078 v16.0.0

About

Erlang/OTC

License:Apache License 2.0


Languages

Language:Erlang 95.9%Language:Awk 4.1%