Commit Graph

149 Commits

Author SHA1 Message Date
Vadim Yanitskiy b594b15e79 srsue/extnas: handle (U)SIM GenAuthResp.Request 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 27344af7f0 srsue/rrctl: make codec::enc_hdr() return proto::msg_hdr 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 796a6df0df srsue/rrctl: add Security Mode messages for EEA/EIA 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy 510bd4ee02 srsue/rrctl: add (U)SIM specific protocol extensions 2022-01-31 17:18:02 +06:00
Vadim Yanitskiy f68931f6e8 srsue/rrctl: add RFU (Reserved for Further Use) message type 2022-01-31 17:18:01 +06:00
Vadim Yanitskiy 7b38286864 srsue/extnas: implement RRCTL codec and message handling
RRCTL is a simple protocol (inspired by Osmocom's L1CTL) that allows
an external NAS entity to control the RRC layer of srsUE. The most
notable primitives are PLMN search, selection, and PDU transfer.

The protocol assumes traditional master-slave communication, where
one side (an external NAS entity) initiates various processes,
while the other (srsUE) executes them and indicates the outcome.

Each RRCTL message starts with a header that can be defined as follows:

  +-------------------------------+--------------------------+
  | Message type                  | 6 bits                   |
  +-------------------------------+--------------------------+
  | Message sub-type              | 2 bits                   |
  +-------------------------------+--------------------------+
  | Spare (RFU)                   | 8 bits                   |
  +-------------------------------+--------------------------+
  | Payload length                | 2 octets (big endian)    |
  +-------------------------------+--------------------------+
  | Payload (optional)            | (see payload length)     |
  +-------------------------------+--------------------------+

The following message types are defined at the moment:

  - RRCTL_RESET - reset internal state of the external NAS interface
                  (does nothing for now, may be useful in the future);

  - RRCTL_PLMN_SEARCH - initiates PLMN (carrier) search on pre-configured
                        EARFCN (Absolute Radio Freqency Number);

  - RRCTL_PLMN_SELECT - binds the UE to one of the previously detected
                        carriers (see RRCTL_PLMN_SEARCH) defined by a
                        given pair of MCC and MNC;

  - RRCTL_CONN_ESTABLISH - establishes connection to the serving cell
                           (previously selected using RRCTL_PLMN_SELECT)
                           with a given cause and NAS PDU;

  - RRCTL_CONN_RELEASE - releases previously established dedicated connection
                         (currently does nothing because the RRC layer does
                          not expose any API for that);

  - RRCTL_DATA - encapsulates a received (Downlink) or to be transmitted
                 (Uplink) NAS PDU (the former also contains LCID).

Each message type has at least two of the following sub-types:

  - RRCTL_REQ - request (usually comes from an external NAS entity),
                used to initiate some process (e.g. PLMN search);

  - RRCTL_IND - indication that something has happened without a prior
                request (for example, a Downlink NAS PDU was received);

  - RRCTL_CNF - confirmation (positive conslusion) of the requested task;

  - RRCTL_ERR - negative conslusion of the requested task (error).

The protocol definition (enums ans structs) and codec functions are
defined in a separate namespaces: 'rrctl::proto' and 'rrctl::codec'
respectively. The codec functions may throw exceptions of type
'rrctl::codec::error' if something goes wrong.
2022-01-31 17:17:57 +06:00
Vadim Yanitskiy 900ad92912 srsue/extnas: implement a simple UNIX domain socket server
Unfortunately, the existing networking API (common/network_utils.h)
lacks the UNIX domain socket support, and it turned to be easier
to implement a simple, single client server using Boost.Asio.

The server runs in its own thread with a blocking Tx queue, and
calls a user definted callback on receipt of any data from client.
Multiple client connections are not supported and will be rejected.
2020-11-09 06:31:45 +07:00
Vadim Yanitskiy 8bc72d44b9 srsue/extnas: introduce draft implementation of 'nas_ext' class
This commit introduces a skeleton class (child of 'nas_base') for
the upcoming implementation of an external NAS interface, as well
as the implementation-specific configuration container.
2020-11-09 06:31:45 +07:00
Vadim Yanitskiy 2b1ded220e srsue/extnas: derive abstract 'nas_base' class from 'nas'
This is the first step towards the goal of having an external NAS
interface.  The new 'nas_base' class becomes a parent of 'nas',
combining all interfaces and the basic (common) API.

The 'ue_stack_lte' now holds a unique_ptr of type 'srsue::nas_base',
so the underlying NAS implementation (built-in or external) can
be choosen at run-time depending on configuration.

The implementation specific configuration now needs to be passed
to the constructor instead, not to the init() method as was before.
2020-11-09 05:34:03 +07:00
Pedro Alvarez 5a4e71a6e4 Created k_enb_context structure that holds k_enb, NCC and NH to make it easier to restore context from failed handover. 2020-10-08 09:46:34 +01:00
Pedro Alvarez bcb422736c Save and restore NH on handover and handover failure. 2020-10-08 09:46:34 +01:00
Pedro Alvarez 3eb525563a Fix issue reading MNC length in USIM. 2020-10-07 10:04:50 +01:00
Pedro Alvarez 22a6dc305f Moved common variables and functions from the usim and pcsc_usim classes into usim_base class. 2020-10-05 12:14:46 +01:00
Pedro Alvarez 2f0125ef4e Fix issue recovering key state, when the first HO fails (specifically, is_first_ncc was not recovered). Minor improvements in key logging. 2020-10-01 18:48:07 +01:00
faluco dfeed52514 - Rename out_stream function to console. 2020-09-29 17:38:13 +02:00
faluco 62faef7c71 - Replaced all uses of the log::console method. 2020-09-29 17:38:13 +02:00
Sylvain Munaut 5783c01cbb tf_packet_filter: Improve support for the different filter types 2020-09-28 16:08:28 +02:00
Pedro Alvarez 86f4d469c6 Added some functions to save and restore AS keys for the case of failed handover in the USIM 2020-09-24 13:30:08 +01:00
Andre Puschmann 8df388ba3e usim: fix typo in log 2020-09-14 21:20:59 +02:00
Andre Puschmann 138ec1f8e7 nas,usim: remove use of shadowed variables 2020-07-20 10:58:10 +02:00
Andre Puschmann a7911f0dab pdcp,rlc: refactor SDU queueing policy
this patch refactors the SDU queuing and dropping policy of the RLC and PDCP layer.
the previous design had issues when packets have been generated at a higher
rate above the PDCP than they could be consumed below the RLC.

When the RLC SDU queues were full, we allowed two policies, one to block on the write
and the other to drop the SDU. Both options are not ideal because they either
lead to a blocking stack thread or to lost PDCP PDUs.

To avoid this, this patch makes the following changes:

* PDCP monitors RLC's SDU queue and drops packets on its north-bound SAP if queues are full
  * a new method sdu_queue_is_full() has been added to the RLC interface for PDCP
* remove blocking write from pdcp and rlc write_sdu() interface
  * all writes into queues need to be non-blocking
  * if Tx queues are overflowing, SDUs are dropped above PDCP, not RLC
* log warning if RLC still needs to drop SDUs
  * this case should be avoided with the monitoring mechanism
2020-07-13 17:05:28 +02:00
Francisco Paisana 1a9c04bf2f use of task scheduler handle in pdcp 2020-07-13 11:19:25 +01:00
Andre Puschmann 1e4eae7395 nas: log estimated count instead of local rx_count when logging integrity check result 2020-07-05 16:56:06 +02:00
Pedro Alvarez 772ab89391 srsUE: Fix for NAS overflow counter computation. 2020-07-02 14:52:21 +01:00
Xavier Arteaga de230826b9 Added string helper for removing spaces and parsing list
Fix

Fix string parser
2020-06-16 11:00:51 +02:00
Pedro Alvarez 960c0e97cd Added handling of RRC re-establishment to srsENB.
* Added the appropriate code for handling and sending the
   re-establishment procedure messages to rrc_ue.c/.h.
 * Triggered RRC reconfiguration after the reception of RRC
   re-establishment complete
 * Refreshed K_eNB at the reception of re-establishment
   request
 * Changed the mapping of TEIDs to RNTIs in the GTP-U layer,
   as the RNTI might change with reestablishment.
2020-06-02 11:19:17 +01:00
Andre Puschmann 25ab36ddd5 nas: fix UE not attaching if PLMN isn't found after switching on
if no cell/PLMN can be found if the UE is switched on, the UE was never
trying again.
In theory this would be handled by T3410, but the timer
is not started in case the PLMN search isn't done yet.
2020-05-01 21:03:47 +02:00
Francisco Paisana de4d58d8fe fix coverity scan issues in master 2020-04-29 11:17:00 +02:00
Xavier Arteaga 77d5dedddc Fix LGTM warnings and recommendations 2020-04-22 18:01:43 +02:00
Xavier Arteaga 562590e595 Fix LGTM warnings 2020-04-22 18:01:43 +02:00
Francisco Paisana 28467d568d eliminated old way to schedule tasks using the heap 2020-04-17 11:38:24 +01:00
Andre Puschmann d35c9e2b89 nas: add support ot UE test loop mode B
extend GW-NAS interface to signal test mode activation.
The method is a noop in the normal GW but is implemented in
the TTCN3 DUT according to TS 36.509 for Mode B
2020-04-10 21:18:43 +02:00
Andre Puschmann 66a799661e gw,tft: move traffic flow template matching into own class
this prepares the reuse of the matching functions for the TTCN3 DUT.
create own matcher class that the GW uses.
2020-04-10 21:18:43 +02:00
Francisco Paisana 2950d26daa remove asn1 namespace from srsue files 2020-04-09 10:10:04 +01:00
Daniel Willmann 925225dbeb Implement Close UE Test Loop/Complete messages
This commit implements support for the CLOSE_UE_TEST_LOOP message.
Currently the mode is not saved and looping the data is not implemented.
Only the *_COMPLETE message is sent back as a response.
2020-04-04 22:51:43 +02:00
Andre Puschmann a4abd96ab6 nas: use MME security header when receiving identity request
this basically avoids sending a integrity protected or ciphered
identity response to a plain identity request
2020-04-03 22:22:04 +02:00
Andre Puschmann 4f8f6bf90c nas: add comment as to why attach request is only integrity protected 2020-04-03 22:22:04 +02:00
Andre Puschmann acc2948b45 nas: fix security handling
First of all, with this the NAS conformance tests pass with ciphering and
integrity turned on. Before only integrity was working.

Mainly the NAS was applying the integrity protection and/or ciphering
incorrectly because it wasn't taking the secuirty status of the PDUs
into account. Some where already correct, some not. The patch
streamlines the handling for all outgoing messages.
2020-04-03 22:22:04 +02:00
Francisco Paisana 30ae2226c1 common interface for stack multiqueue tasks, background tasks and timers 2020-03-31 13:42:06 +01:00
Andre Puschmann dbb8b6a360 nas: add helper for entering new state in FSM
the helper will log the event
2020-03-30 11:23:40 +02:00
Andre Puschmann ef80502047 nas: print attach attempts on console 2020-03-30 11:23:40 +02:00
Andre Puschmann f477c1d2e5 nas: allow starting a attach request procedure even if a PLMN is already selected
previously the NAS would cancel a attach request procedure if the PLMN
is already selected. PLMN selection, however, in not necessarily happening
before requesting RRC to establish a connection.
2020-03-30 11:23:40 +02:00
Andre Puschmann d8680cc9a8 nas: add helper to pack attach request and send to RRC 2020-03-30 11:23:40 +02:00
Andre Puschmann cf28276a3a nas: add helper function to reset NAS security context 2020-03-30 11:23:40 +02:00
Andre Puschmann 94c6034339 nas: rename start_attach_request to start_attach_proc
this is to better differentiate from "send_attach_request" that
only packs and send the actual attach request message. The
entire attach procedure may include PLMN search, etc.
2020-03-30 11:23:40 +02:00
Andre Puschmann 0e76b9ed15 nas: set NAS key set identifier to no key available when attaching with IMSI 2020-03-28 21:24:13 +01:00
Andre Puschmann 9cfe692825 nas: fix reset of attach attempt counter according to 24.301 Sec 5.5.1.1 2020-03-27 18:15:37 +01:00
Andre Puschmann d0480141e5 nas: move re-arming and stopping of attach request related timers
t3402, t3410 and t3411 are now managed in the sender
function of the attach request. previosly they were only
correctly started in the high-level NAS call start_attach_request()
which may not be called if NAS itself resends the request
2020-03-27 18:15:37 +01:00
Andre Puschmann 15c47fab56 nas: adding t3402 to restart attach after initial attach attempt counter expired 2020-03-27 18:15:37 +01:00
Andre Puschmann 7ef56cb637 nas: add an attach attempt counter as described in 24.301 2020-03-27 18:15:37 +01:00