go-tcap icon indicating copy to clipboard operation
go-tcap copied to clipboard

Supports marshaling of nested IEs

Open linouxis9 opened this issue 3 months ago • 3 comments

Depends on #17

WIP, unit tests to be fixed.

linouxis9 avatar Mar 26 '24 16:03 linouxis9

@wmnsk Issues found with units tests were fixed. Thanks! :-)

linouxis9 avatar Mar 27 '24 10:03 linouxis9

Can you provide the example of payload that this PR will make it possible to handle? 💯 if you can add it to the test case in codec_test.go.

Yes, I'll add an example as a test case! But basically it allows you to construct a tree of IEs (IEs containing other IEs) and then marshaling them, without having to manually inject the inner IEs encoded into the outer IEs's Value field. It's pretty handy to construct a TCAP with a MAP payload out of tcap.IE for instance.

What is the point in returning "Decoded Length is not equal to..." error? In which situation would it happen, and can it be avoided somehow? There are two cases where this error can be triggered:

  • Internal parsing issue where the IEs were incorrectly decoded: while developing this PR, some times, I mistakenly decoded multi IEs into a single IE with some fields being lost, this helped catching the issue
  • The message being parsed is invalid, for example: the IE TLV's length is not equal to the size of its child IEs + the headers: this helped me caught a few marshaling issues when trying to unmarshal a message marshaled with go-tcap.

This error helped me while developing this PR, and I'm sure it could help us catch parsing errors in the wild, and could make potentiel bug reports a bit more readable of what happened in case of issues.

Thanks a lot for your time on such a niche but awesome library :-)

linouxis9 avatar Apr 01 '24 13:04 linouxis9

Test case added and rebased upon new commit of PR #17, thanks a lot!

linouxis9 avatar Apr 04 '24 10:04 linouxis9