Missing release field/length in MS RA capability container
In case of MS RA Capability container "Content_t", there is no dedicated field to denote the existence of 3GPP release in the message. The encoder goes out of max length allowed for release supported and encodes incorrectly.
Example vector with failure:
vector1 = 40165e000000268ca2a050740440000000300b2b2b2b2b
vector2 = 40165e00000026d0a2a0507400000220000000180b2b2b
vector1 == vector2 : FALSE
For this, we shall have precomputed value of length to terminate the container encoding before calling Content_Dissector in csn1.cpp file. The pre computing length logic routine shall consider the presence of different 3GPP releases.
For example in case of release 5 RA capability message , encoder should be able to code only till release 5 fields . In case of release 6 RA capability, encoder must be able to code till release 6. This release information must be available to the encoder to calculate length. Decoder will set the release field based on the fields present in the message.
Fix RAI construction
The gsm48_construct_ra() expect 6-byte buffer while ra_id.digits is
3-byte buffer. The function fills in LAC and RAC as well so we should
pass entire struct, not just 'digits' part which only store MCC/MNC.
Fixes: CID57877, CID57876
Add function to properly encode RAI
Add gsm48_encode_ra() which takes appropriate struct as [out] parameter
instead of generic buffer. Using uint8_t buffer instead of proper struct
type prooved to be error-prone - see Coverity CID57877, CID57876.
Old gsm48_construct_ra() is made into tiny wrapper around new
function. The test output is adjusted because of the change in function
return value which was constant and hence ignored anyway.
It's just a tiny wrapper around gsm48_encode_ra() with less strict type
Use gsm48_encode_ra() for RAI encoding
It has stricter type signature which increase the chance of spotting
misuse either via compiler warning or with automated scan. This also
paves the way for gsm48_construct_ra() deprecation in libosmocore.
- Assignee deleted (
fixeria, is this still an issue?
I remember we had some problems with encoding of the MS RA Capability, but this is not critical. Decoding is important for the PCU, because it needs to know the MS capabilities, and it seems to work fine. Encoding is not. The only place where we do encoding is the unit test, so unless I am missing something, it's not worth to spend time on that.
Here is what I get with the current master:
vector1 = 40165e000000268ca2a050740440000000300b2b2b2b2b =========Start DECODE=========== +++++++++Finish DECODE (0)++++++++++ =========Start ENCODE============= +++++++++Finish ENCODE (0)+++++++++++ vector1 = 40 16 5e 00 00 00 26 8c a2 a0 50 74 04 40 00 00 00 30 0b 2b 2b 2b 2b vector2 = 40 16 5e 00 00 00 27 0c a2 a0 50 74 00 00 00 00 04 40 00 00 00 30 0b vector1 == vector2 : FALSE