aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoding.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-06-02encoding: pass RFN to write_immediate_assignment(_reject)()Pau Espin Pedrol1-22/+22
Those function don't really require the full FN, hence let's pass only the required information. This makes the implementation here less dependent on how/if we are able to calculate full FNs based on RFN: We get an RFN, and we have to encode so that the RFN can be derived again, so feels less cumbersome having to go through RFN->FN->RFN which may only cause possible issues if there's some FN timing bug. 3GPP TS 44.018 10.5.2.30 Request Reference: "The purpose of the Request Reference information element is to provide the random access information used in the channel request and the frame number, FN modulo 42432" 3GPP TS 44.018 10.5.2.38 Starting Time: "The purpose of the Starting Time information element is to provide the start TDMA frame number, FN modulo 42432." Change-Id: If9b758434c00f2a3868534d5be84946809c989a9
2023-04-12gprs_rlcmac: convert from C++ to CMax1-1/+1
Change-Id: I7260ad1a67ebdc09767a679e579fead262f1627a
2023-02-24en/decoding: fix deprecated include pathPhilipp Maier1-1/+1
The file gprs/protocol/gsm_04_60.h is deprecated, now it is recommended to use gsm/protocol/gsm_44_060.h Change-Id: I870e446ad8f371e13bbdb4034feae1260c874ee5
2022-12-16Get rid of tbf->first_tsPau Espin Pedrol1-2/+2
There's no big benefit in keeping it stored since it can be quickly found. This makes the tbf data structure simplier and easier to maintain, and discharges the alloc_algorithm functions from an extra step. Change-Id: I5d2f665f648f8637466bfdd3bf7b924cb61ede33
2022-12-12encoding::write_immediate_assignment(): Constify tbf paramPau Espin Pedrol1-7/+7
Change-Id: Ic0b6e81dbeb44f200065dba92cadc33fa52ae75d
2022-10-28encoding: Use MT_PACKET_UPLINK_ASSIGNMENT define instead of hardcoded valuePau Espin Pedrol1-1/+1
Change-Id: I05b39d3183fdf741d648a15ff803d20e324443af
2022-10-28Rename as_{dl,ul}_tbf -> tbf_as_{dl,ul}_tbfPau Espin Pedrol1-6/+6
Prefix the function accordingly to specify the input object. Change-Id: I225568fe2cb5236817cdd9609354c24c66723606
2022-10-16Use GSM48_MT_RR_IMM_ASS instead of hardcoded 0x3f valuePau Espin Pedrol1-1/+1
Change-Id: Id966cbab403763d006bd5e59757c5bf57402bf9d
2022-10-16cosmetic: Add missing spacing between paramsPau Espin Pedrol1-13/+13
Change-Id: I45666ed52d15871b83aaca1d7cb3e521800751c2
2022-06-29encoding: fix an uninitialized field in gen_freq_params()Vadim Yanitskiy1-0/+2
This is not critical, given that we set 'ElementsOf_RFL_NUMBER' to 0. But still, let's ensure that all fields are initialized. Change-Id: I4dd5202d1c4bd75baf0ab4f88ffefcc47272bd9c Fixes: CID#272999
2021-12-14treewide: remove FSF address2021q4Oliver Smith1-4/+0
Remove the paragraph about writing to the Free Software Foundation's mailing address. The FSF has changed addresses in the past, and may do so again. In 2021 this is not useful, let's rather have a bit less boilerplate at the start of source files. Change-Id: I4a49dbeeec89b22624c968152118aecf8886dac6
2021-08-23Move tbf ul_ack_state to osmocom FSMPau Espin Pedrol1-3/+2
Related: OS#2709 Change-Id: Icf23bf5a4b85fbcbf1542cebceb76b9ba7185d30
2021-08-23Get rid of lots of code only used by testsPau Espin Pedrol1-10/+2
There are 2 methods "rcvd_dl_ack()" in osmo-pcu code. One is used by osmo-pcu itself, and the other is only used in tests. Changing the tests to use the same method as osmo-pcu allows removing the second one, and with it, a lot of code and complexity out of osmo-pcu. Change-Id: I14d9312cb61534dc97fca83141b9c0cd933c9206
2021-08-23replace dl_ass_state with osmocom FSMPau Espin Pedrol1-3/+3
Related: OS#2709 Change-Id: Ia33418478e17986a316ffda48b091030f53fa371
2021-08-23Replace ul_ass_state with osmocom FSMPau Espin Pedrol1-4/+2
Related: OS#2709 Change-Id: Id414eafe9c04a9a8759c6fb1a483bf2ee093a4d2
2021-05-11encoding: Encode TA in UL ACK/NACK if availablePau Espin Pedrol1-2/+19
Change-Id: I3b060ee16aeac5f5d9b314b6bc46383f5e9c44c3
2021-05-11encoding: Use gsm48_ta_is_valid() APIPau Espin Pedrol1-1/+1
Change-Id: Ieaa4c2f926611576e22eaac8a7ac595135809e2c
2021-05-11Tx ul ack/nack: Avoid sending invalid/unknown TLLIPau Espin Pedrol1-4/+14
It could happen that if MS sends first UL blocks without TLLI (wrongly, due to being in contention resolution), the submitted UL ACK/NACK would contain an invalid TLLI. Related: OS#1940 Change-Id: Ibae5df6cfbb56f8f8007cb9fec9c29006d673b72
2021-04-26Make WaitIndication T3172 configurablePau Espin Pedrol1-4/+10
Tbftest expectatins need to change because 5000/20 = 250 < 255, hence the message is now sent as units of 20ms instead of seconds. Related: OS#3928 Change-Id: I48b34b94b1a5dfb046a3a6cf8a0d944a7c9b6754
2021-04-26Make use of T3142 received from BTSPau Espin Pedrol1-6/+4
Related: OS#3928 Change-Id: I4e26f181db9693d3a267a879e2aebda12eab2a8c
2021-02-03nacc: Implement Pkt Cell Change Continue retransmissionPau Espin Pedrol1-5/+5
Use the fact that the MS must answer the RRBP of the Pkt Cell Change Continue with a CTRL ACK to find out whether the message was received successfuly or a retransmission is potentially required. 3GPP TS 44.060: """ When the mobile station receives the PACKET CELL CHANGE ORDER or the PACKET CELL CHANGE CONTINUE message the mobile station shall transmit a PACKET CONTROL ACKNOWLEDGMENT message in the specified uplink radio block if a valid RRBP field is received as part of the message; the mobile station may then switch to a new cell. """ Related: SYS#4909 Change-Id: I7cc28922e71699598da0ef6eb90136a47d3c002f
2021-02-01encoding: Fix comment description of S/P fieldPau Espin Pedrol1-2/+2
Those fields were ment to be 0 (non-valid), just the comments were copied over from somewhere else, and they are misleading. Change-Id: Ic95853e115f60c65f7f11187d49d6e870d08c7bb
2021-02-01Update TS 04.60 references to new TS 44.060Pau Espin Pedrol1-3/+3
Change-Id: Ib7c3a74b502b2251da2f7b9d6d711f3e32133bc3
2021-01-29Introduce NACC supportPau Espin Pedrol1-0/+53
A new nacc_fsm is introduced per MS object, with its partner priv structure struct nacc_fsm_ctx, which exists and is available in the MS object only during the duration of the NACC procedure. The NACC context is created on an MS whenever a Pkt Cell Change Notification is received on Uplink RLCMAC, which asks for neighbor information of a given ARFCN+BSIC. First, the target ARFCN+BSIC needs to be translated into a CGI-PS (RAC+CI) address. That's done by asking the BSC through the Neighbour Resolution Service available in osmo-bsc using the CTRL interface. Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO request against the SGSN (which will route the request as needed), and wait for a response containing the SI bits from the target cell. After the SI are received, the scheduler is instructed to eventually poll a TBF for the MS originating the CCN, so that we can send the SI encapsulated into multiple Packet Neighbor Cell Data messages on the downlink. One all the SI bits are sent, the scheduler is instructed to send a Packet Cell Change Continue message. Once the message above has been sent, the FSM autodestroys itself. Caches are also introduced in this patch which allows for re-using recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO respectively. Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-25encoding: fix typos in commentPau Espin Pedrol1-2/+2
Change-Id: I0867935ad08d6e49c62e061742d3d76eeac35844
2021-01-19Unify BTS into a C usable structurePau Espin Pedrol1-0/+1
Previous work on BTS class started to get stuff out of the C++ struct into a C struct (BTS -> struct gprs_glcmac_bts) so that some parts of it were accessible from C code. Doing so, however, ended up being messy too, since all code needs to be switching from one object to another, which actually refer to the same logical component. Let's instead rejoin the structures and make sure the struct is accessible and usable from both C and C++ code by rewriting all methods to be C compatible and converting 3 allocated suboject as pointers. This way BTS can internally still use those C++ objects while providing a clean APi to both C and C++ code. Change-Id: I7d12c896c5ded659ca9d3bff4cf3a3fc857db9dd
2021-01-05Convert GprsMS and helpers classes to CPau Espin Pedrol1-10/+10
As we integrate osmo-pcu more and more with libosmocore features, it becomes really hard to use them since libosmocore relies heavily on C specific compilation features, which are not available in old C++ compilers (such as designated initializers for complex types in FSMs). GprsMs is right now a quite simple object since initial design of osmo-pcu made it optional and most of the logic was placed and stored duplicated in TBF objects. However, that's changing as we introduce more features, with the GprsMS class getting more weight. Hence, let's move it now to be a C struct in order to be able to easily use libosmocore features there, such as FSMs. Some helper classes which GprsMs uses are also mostly move to C since they are mostly structs with methods, so there's no point in having duplicated APIs for C++ and C for such simple cases. For some more complex classes, like (ul_,dl_)tbf, C API bindings are added where needed so that GprsMs can use functionalitites from that class. Most of those APIs can be kept afterwards and drop the C++ ones since they provide no benefit in general. Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-01Dl TBF: Get rid of LLC UI dummy blocks following other dataPau Espin Pedrol1-55/+64
According to: * 3GPP TS 44.060 version 16.0.0 "9.3.1a Delayed release of downlink Temporary Block Flow" * 3GPP TS 44.064 version 16.0.0 "6.4.2.2 Unconfirmed Information (UI) Dummy command" LLC UI Dummy frames are to be used when there no more data to send, only in order to delay the release of a TBF. Hence, while not incorrect per se, makes no sense to send those LLC UI Dummy frames inserted into rlcmac blocks which already contain other LLC frames, since the MS in that case is already being kept active. It only makes sense to send those LLC UI Dummy frames when we have nothing else to send, that is, alone inside a RLCMAC block without other LLC frames. Related: OS#4849 Change-Id: Ifae1a7b2b3dfad8df19585063088ba0df2749c8f
2020-11-17encoding: Fix duplicate word in log strPau Espin Pedrol1-1/+1
Change-Id: Ifb0b359c43e79bab5599625fae20750ae5a6ae54
2020-11-05Fix mcs_is_valid(): UNKNOWN value is not a valid (M)CSPau Espin Pedrol1-0/+1
Also add a few more asserts to make sure a valid CS/MCS is passed in some placed where we expect (M)CS to be set. Change-Id: I0a973e10cd9477f72d8bd47a06048414b33ae96a
2020-10-29cosmetic: Fix ws between if keyword and parenthesisPau Espin Pedrol1-1/+1
Change-Id: I5932f21c58e76552f7187a175b8e281c5846536c
2020-10-24tbf: Make window() available to tbf base classPau Espin Pedrol1-2/+5
Return an interface to the window base class so that the tbf base class can access the common window methods, such as set_ws(). It will be used in next commit to get rid of duplicated function enable_egprs in both dl_tbf and ul_tbf subclasses. The user of the function can then decide to access more specific functionaltiites of the window class by static casting it to the specific direction (which is known by the caller since it operates on a ul_tbf or a dl_tbf). Change-Id: Ia2e1decf91be1184668e28297c2126affb9c7ae4
2020-09-10encoding: fix gen_freq_params(): do not check pdch twiceVadim Yanitskiy1-1/+1
This is a left-over from an earlier version of [1] that makes Coverity think that there can be NULL pointer dereference, even despite we assert(pdch != NULL). [1] I8adc0cdb1b05a87b4df5d4bc196f6d381283a06f Change-Id: I3490c38e0c1186dfd2fae63526a05c694547cebb Fixes: CID#214230
2020-09-08encoding: implement handing of hopping parametersVadim Yanitskiy1-11/+59
The following test cases verify coding of the hopping parameters: + (RR) Immediate Assignment - TC_pcuif_fh_imm_ass_ul_egprs, - TC_pcuif_fh_imm_ass_ul, - TC_pcuif_fh_imm_ass_dl, + (RLC/MAC) Packet Uplink/Downlink Assignment: - TC_pcuif_fh_pkt_ass_ul, - TC_pcuif_fh_pkt_ass_dl, all of them pass with this (and the upcoming) change applied. Change-Id: I8adc0cdb1b05a87b4df5d4bc196f6d381283a06f Related: SYS#4868, OS#4547
2020-09-08encoding: use CSN.1 codec to generate Packet Uplink AssignmentVadim Yanitskiy1-75/+105
It's quite odd to see that in write_packet_downlink_assignment() we initialize an 'RlcMacDownlink_t', so then the caller can use the power of CSN.1 codec to generate the final sequence of bytes to be transmitted, while in write_packet_uplink_assignment() we already compose the final RLC/MAC message straight away using the low-level bitvec API (like bitvec_write_field()). I guess the reason is that at the time of writing this code, the CSN.1 codec was not stable enough, so it was safer to generate the message 'by hand'. This would also explain why we *decode* the final RLC/MAC message in create_ul_ass() right after encoding. Rewrite write_packet_uplink_assignment(), so now it initializes a caller-provided 'RlcMacDownlink_t' structure. Given that it's allocated on heap using talloc_zero(), do not initialize presence indicators of fields that are not present in the message. This would facilitate handling of frequency hopping parameters in the upcoming changes, in particular we can now introduce a function that would compose Frequency Parameters IE for both write_packet_{downlink,uplink}_assignment(). Tested manually by running a GPRS-enabled network, as well as by running test cases from ttcn3-pcu-test => no regressions observed. Change-Id: I2850b91e0043cdca8ae7498a5fc727eeedd029b6 Related: SYS#4868, OS#4547
2020-09-08encoding: clarify docstring for write_packet_downlink_assignment()Vadim Yanitskiy1-3/+2
Change-Id: I7c4458c2e7767b6cf03462ba79acdd9c9904ee83
2020-08-24encoding: pass pdch slot directly to encoding functionsVadim Yanitskiy1-6/+8
In order to be able to encode frequency hopping parameters, let's pass a const pointer to 'gprs_rlcmac_pdch' (PDCH slot) directly, instead of passing all related parameters separately. Change-Id: I6bccad508f0fdccc4a763211008dd847a9111a8d Related: SYS#4868, OS#4547
2020-08-24encoding: use bool for use_egprs in write_packet_uplink_assignment()Vadim Yanitskiy1-1/+1
Change-Id: Iab4fb44c666a0d4fe8c98f5ff9221e23a6f1f2fa
2020-08-24encoding: fix RRBP field in write_packet_uplink_assignment()Vadim Yanitskiy1-1/+1
Do not hard-code 0x00, write what was passed as a parameter. Change-Id: I9eb362292e9f4c16d4b8f8d4253df0422062eeb4
2020-08-24encoding: do not encode out of range Timing Advance valuesVadim Yanitskiy1-3/+8
According to 3GPP TS 44.060, section 12.12 "Packet Timing Advance", the 'TIMING_ADVANCE_VALUE' field is optional, and takes 6 bits if present. This means that a value that fits in range 0..63 (inclusive) can be encoded (0b111111 == 63). It's possible that tbf->ta() returns GSM48_TA_INVALID == 220, so the bitvec API would encode only 6 LSBs of it: 220 & 0b111111 == 28 Let's ensure that the 'TIMING_ADVANCE_VALUE' is present iff tbf->ta() returns a correct (0 <= x <= 63), and absent otherwise. Change-Id: I342288ea4ef1e218e5744e9be6a8e528d4e697fa
2020-08-24encoding: constify 'tbf' in UL/DL assignment functionsVadim Yanitskiy1-2/+2
Change-Id: I9b80ce22914a355592502c936046b233c3ba216d
2020-08-24paging: pass struct osmo_mobile_identity, not encoded IE bytesNeels Hofmeyr1-2/+8
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is returned. Code paths following this repeatedly decode the Mobile Identity bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in from a different encoding than a typical Mobile Identity IE, the TMSI was manually encoded into a typical Mobile Identity IE. This is essentially a code dup of osmo_mobile_identity_encode(). Stop this madness. Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code paths after this use the struct osmo_mobile_identity directly without repeated decoding. At the point of finally needing an encoded Mobile Identity IE (in Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode(). Since this may return errors, add an rc check for the caller of write_paging_request(), gprs_rlcmac_paging_request(). A side effect is stricter validation of the Mobile Identity passing through the Paging code path. Before, invalid MI might have passed through unnoticed. Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-07-18encoding: assert() presence of Downlink TBFVadim Yanitskiy1-4/+1
This is not something that should normally happen. If it happens, then it's definitely a bug, and we should not tolerate it. Change-Id: I6e46ba42650f0db2399649b536a1d2b3f0fcbf04
2020-07-18encoding: drop log_alert_exit(), use OSMO_ASSERT() insteadVadim Yanitskiy1-13/+2
Change-Id: Id5ef1c3c08dc7f264ad801e519d727d86f5ae5b8
2020-07-09encoding.cpp: Fix missing spacing in function paramPau Espin Pedrol1-2/+2
Change-Id: I4f30a0cea615d57cd7783a92ae782790c8075a6c
2020-07-09encoding: Encode TA as unsigned and check validty against GSM48_TA_INVALIDPau Espin Pedrol1-3/+3
According to 3GPP TS 44.018 sec 10.5.2.40, Timing Advance value is 8 bit and range is 0-63 (0-219 on GSM400). Unsigned value (uint8_t) is used everywhere else, so avoid using a signed one here, and simply check for GSM48_TA_INVALID here, which we use everywhere else to initialize when the value is not known. Ideally we should check for value based on band, but it makes more sense to check that when receiving the data and storing in in set_ta(). Change-Id: I82b13561d0fe5ebafb5c3a8b9a501045c29809bc
2020-05-25encoding: fix write_ia_rest_egprs_uplink_sba(): add missing CHECK(rc)Vadim Yanitskiy1-0/+1
Change-Id: I8e41c2912aaff689b0e311c8e2d3e961d2f1ac2c
2020-05-23encoding: cosmetic: use RLC_MODE_ACKNOWLEDGED where possibleVadim Yanitskiy1-2/+3
Change-Id: Ic69d120f622f512f05016596bfdd4a89b96e3e3b
2020-05-20Get rid of class GprsCodingSchemePau Espin Pedrol1-3/+3
We have same kind of object splitted into two layers, in coding_scheme and gprs_coding_scheme. Let's merge them together and get rid of the class, which is not really useful because it's only a set of functions operating on one enum value. This change also fixes gcc 10.1.0 error about memseting a complex type in rlc.h init(). Change-Id: Ie9ce2144ba9e8dbba9704d4e0000a2929e3e41df
2020-02-10encoding: assert return value of bitvec_set_u64()Vadim Yanitskiy1-1/+2
Change-Id: Ic0de3ae34f06e41aacacb917f5a0214623259bdc Fixes: OS#182120