Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
sneltved
openairinterface5G
Commits
0f11865f
Commit
0f11865f
authored
Feb 28, 2019
by
Raphael Defosseux
Browse files
Merge remote-tracking branch 'origin/issue-404-pdcp-integrity' into develop_integration_2019_w09
Signed-off-by:
Raphael Defosseux
<
raphael.defosseux@eurecom.fr
>
parents
53f5f668
e3782b5c
Changes
19
Hide whitespace changes
Inline
Side-by-side
cmake_targets/CMakeLists.txt
View file @
0f11865f
...
...
@@ -595,7 +595,6 @@ Message("CPU_Affinity flag is ${CPU_AFFINITY}")
##############################################################
# ???!!! TO BE DOCUMENTED OPTIONS !!!???
##############################################################
add_boolean_option
(
ENABLE_SECURITY True
"Enable LTE integrity and ciphering between RRC UE and eNB"
)
add_boolean_option
(
ENABLE_USE_MME True
"eNB connected to MME (INTERFACE S1-C), not standalone eNB"
)
add_boolean_option
(
NO_RRM True
"DO WE HAVE A RADIO RESSOURCE MANAGER: NO"
)
add_boolean_option
(
RRC_DEFAULT_RAB_IS_AM False
"set the RLC mode to AM for the default bearer"
)
...
...
cmake_targets/epc_test/CMakeLists.template
View file @
0f11865f
...
...
@@ -9,7 +9,6 @@ set ( EMIT_ASN_DEBUG False )
set ( ENABLE_ITTI True )
set ( ENABLE_NAS_UE_LOGGING True )
set ( ENABLE_NEW_MULTICAST True )
set ( ENABLE_SECURITY True )
set ( ENABLE_STANDALONE_EPC False)
set ( ENABLE_USE_CPU_EXECUTION_TIME True )
set ( ENABLE_USE_MME True )
...
...
cmake_targets/oaisim_build_oai/CMakeLists.template
View file @
0f11865f
...
...
@@ -8,7 +8,6 @@ set ( ENABLE_ITTI True )
set ( ENABLE_NAS_UE_LOGGING True )
set ( ENABLE_NEW_MULTICAST True )
set ( ENABLE_RAL False )
set ( ENABLE_SECURITY True )
set ( ENABLE_STANDALONE_EPC False)
set ( ENABLE_USE_CPU_EXECUTION_TIME True )
set ( ENABLE_USE_MME True )
...
...
cmake_targets/oaisim_mme_build_oai/CMakeLists.template
View file @
0f11865f
...
...
@@ -8,7 +8,6 @@ set ( ENABLE_ITTI True )
set ( ENABLE_NAS_UE_LOGGING False )
set ( ENABLE_NEW_MULTICAST False )
set ( ENABLE_RAL False )
set ( ENABLE_SECURITY False )
set ( ENABLE_STANDALONE_EPC False )
set ( ENABLE_USE_CPU_EXECUTION_TIME False )
set ( ENABLE_USE_MME False )
...
...
cmake_targets/oaisim_noS1_build_oai/CMakeLists.template
View file @
0f11865f
...
...
@@ -7,7 +7,6 @@ set ( ENABLE_ITTI True )
set ( ENABLE_NAS_UE_LOGGING False )
set ( ENABLE_NEW_MULTICAST True )
set ( ENABLE_RAL False )
set ( ENABLE_SECURITY False )
set ( ENABLE_STANDALONE_EPC False)
set ( ENABLE_USE_CPU_EXECUTION_TIME True )
set ( ENABLE_USE_MME False )
...
...
cmake_targets/s1c_mme_test/CMakeLists.template
View file @
0f11865f
...
...
@@ -9,7 +9,6 @@ set ( ENABLE_NAS_UE_LOGGING True )
set ( ENABLE_NEW_MULTICAST True )
set ( ENABLE_PDCP_NETLINK_FIFO False )
set ( ENABLE_RAL False )
set ( ENABLE_SECURITY True )
set ( ENABLE_STANDALONE_EPC False)
set ( ENABLE_USE_CPU_EXECUTION_TIME True )
set ( ENABLE_USE_MME True )
...
...
openair2/LAYER2/PDCP_v10.1.0/pdcp.c
View file @
0f11865f
...
...
@@ -50,9 +50,7 @@
#include
"msc.h"
#include
"targets/COMMON/openairinterface5g_limits.h"
#include
"SIMULATION/ETH_TRANSPORT/proto.h"
#if defined(ENABLE_SECURITY)
#include
"UTIL/OSA/osa_defs.h"
#endif
#include
"UTIL/OSA/osa_defs.h"
# include "intertask_interface.h"
...
...
@@ -294,8 +292,6 @@ boolean_t pdcp_data_req(
pdcp_pdu_p
->
data
[
pdcp_header_len
+
sdu_buffer_sizeP
+
i
]
=
0x00
;
// pdu_header.mac_i[i];
}
#if defined(ENABLE_SECURITY)
if
((
pdcp_p
->
security_activated
!=
0
)
&&
(((
pdcp_p
->
cipheringAlgorithm
)
!=
0
)
||
((
pdcp_p
->
integrityProtAlgorithm
)
!=
0
)))
{
...
...
@@ -321,7 +317,6 @@ boolean_t pdcp_data_req(
}
}
#endif
/* Print octets of outgoing data in hexadecimal form */
LOG_D
(
PDCP
,
"Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)
\n
"
,
pdcp_pdu_size
);
...
...
@@ -442,6 +437,10 @@ pdcp_data_ind(
uint16_t
pdcp_uid
=
0
;
MessageDef
*
message_p
=
NULL
;
uint8_t
*
gtpu_buffer_p
=
NULL
;
uint32_t
rx_hfn_for_count
;
int
pdcp_sn_for_count
;
int
security_ok
;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND
,
VCD_FUNCTION_IN
);
LOG_DUMPMSG
(
PDCP
,
DEBUG_PDCP
,(
char
*
)
sdu_buffer_pP
->
data
,
sdu_buffer_sizeP
,
"[MSG] PDCP UL %s PDU on rb_id %d
\n
"
,
(
srb_flagP
)
?
"CONTROL"
:
"DATA"
,
rb_idP
);
...
...
@@ -529,10 +528,10 @@ pdcp_data_ind(
}
else
{
// DRB
pdcp_tailer_len
=
0
;
if
(
pdcp_p
->
seq_num_size
==
PDCP_SN_7BIT
)
{
if
(
pdcp_p
->
seq_num_size
==
7
)
{
pdcp_header_len
=
PDCP_USER_PLANE_DATA_PDU_SHORT_SN_HEADER_SIZE
;
sequence_number
=
pdcp_get_sequence_number_of_pdu_with_short_sn
((
unsigned
char
*
)
sdu_buffer_pP
->
data
);
}
else
if
(
pdcp_p
->
seq_num_size
==
PDCP_SN_12BIT
)
{
}
else
if
(
pdcp_p
->
seq_num_size
==
12
)
{
pdcp_header_len
=
PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE
;
sequence_number
=
pdcp_get_sequence_number_of_pdu_with_long_sn
((
unsigned
char
*
)
sdu_buffer_pP
->
data
);
}
else
{
...
...
@@ -541,6 +540,7 @@ pdcp_data_ind(
PROTOCOL_PDCP_CTXT_FMT
"wrong sequence number (%d) for this pdcp entity
\n
"
,
PROTOCOL_PDCP_CTXT_ARGS
(
ctxt_pP
,
pdcp_p
),
pdcp_p
->
seq_num_size
);
exit
(
1
);
}
//uint8_t dc = pdcp_get_dc_filed((unsigned char*)sdu_buffer_pP->data);
...
...
@@ -566,6 +566,8 @@ pdcp_data_ind(
return
FALSE
;
}
#if 0
/* Removed by Cedric */
if (pdcp_is_rx_seq_number_valid(sequence_number, pdcp_p, srb_flagP) == TRUE) {
LOG_T(PDCP, "Incoming PDU has a sequence number (%d) in accordance with RX window\n", sequence_number);
/* if (dc == PDCP_DATA_PDU )
...
...
@@ -586,10 +588,18 @@ pdcp_data_ind(
free_mem_block(sdu_buffer_pP, __func__);
return FALSE;
}
#endif
// SRB1/2: control-plane data
if
(
srb_flagP
)
{
#if defined(ENABLE_SECURITY)
/* process as described in 36.323 5.1.2.2 */
if
(
sequence_number
<
pdcp_p
->
next_pdcp_rx_sn
)
{
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
+
1
;
pdcp_sn_for_count
=
sequence_number
;
}
else
{
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
;
pdcp_sn_for_count
=
sequence_number
;
}
if
(
pdcp_p
->
security_activated
==
1
)
{
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
...
...
@@ -598,23 +608,45 @@ pdcp_data_ind(
start_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
pdcp_validate_security
(
ctxt_pP
,
pdcp_p
,
srb_flagP
,
rb_idP
,
pdcp_header_len
,
sequence_number
,
sdu_buffer_pP
->
data
,
sdu_buffer_sizeP
-
pdcp_tailer_len
);
security_ok
=
pdcp_validate_security
(
ctxt_pP
,
pdcp_p
,
srb_flagP
,
rb_idP
,
pdcp_header_len
,
rx_hfn_for_count
,
pdcp_sn_for_count
,
sdu_buffer_pP
->
data
,
sdu_buffer_sizeP
-
pdcp_tailer_len
)
==
0
;
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
stop_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
else
{
stop_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
}
else
{
security_ok
=
1
;
}
if
(
security_ok
==
0
)
{
LOG_W
(
PDCP
,
PROTOCOL_PDCP_CTXT_FMT
"security not validated for incoming PDCP SRB PDU
\n
"
,
PROTOCOL_PDCP_CTXT_ARGS
(
ctxt_pP
,
pdcp_p
));
LOG_W
(
PDCP
,
"Ignoring PDU...
\n
"
);
free_mem_block
(
sdu_buffer_pP
,
__func__
);
/* TODO: indicate integrity verification failure to upper layer */
return
FALSE
;
}
if
(
sequence_number
<
pdcp_p
->
next_pdcp_rx_sn
)
pdcp_p
->
rx_hfn
++
;
pdcp_p
->
next_pdcp_rx_sn
=
sequence_number
+
1
;
if
(
pdcp_p
->
next_pdcp_rx_sn
>
pdcp_p
->
maximum_pdcp_rx_sn
)
{
pdcp_p
->
next_pdcp_rx_sn
=
0
;
pdcp_p
->
rx_hfn
++
;
}
#endif
//rrc_lite_data_ind(module_id, //Modified MW - L2 Interface
MSC_LOG_TX_MESSAGE
(
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
?
MSC_PDCP_UE
:
MSC_PDCP_ENB
,
...
...
@@ -638,40 +670,168 @@ pdcp_data_ind(
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_IND
,
VCD_FUNCTION_OUT
);
return
TRUE
;
}
}
/* if (srb_flagP) */
/*
* DRBs
*/
payload_offset
=
pdcp_header_len
;
// PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE;
#if defined(ENABLE_SECURITY)
if
(
pdcp_p
->
security_activated
==
1
)
{
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
start_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
switch
(
pdcp_p
->
rlc_mode
)
{
case
RLC_MODE_AM
:
{
/* process as described in 36.323 5.1.2.1.2 */
int
reordering_window
;
if
(
pdcp_p
->
seq_num_size
==
7
)
reordering_window
=
REORDERING_WINDOW_SN_7BIT
;
else
reordering_window
=
REORDERING_WINDOW_SN_12BIT
;
if
(
sequence_number
-
pdcp_p
->
last_submitted_pdcp_rx_sn
>
reordering_window
||
(
pdcp_p
->
last_submitted_pdcp_rx_sn
-
sequence_number
>=
0
&&
pdcp_p
->
last_submitted_pdcp_rx_sn
-
sequence_number
<
reordering_window
))
{
/* TODO: specs say to decipher and do header decompression */
LOG_W
(
PDCP
,
PROTOCOL_PDCP_CTXT_FMT
"discard PDU, out of
\n
"
,
PROTOCOL_PDCP_CTXT_ARGS
(
ctxt_pP
,
pdcp_p
));
LOG_W
(
PDCP
,
"Ignoring PDU...
\n
"
);
free_mem_block
(
sdu_buffer_pP
,
__func__
);
/* TODO: indicate integrity verification failure to upper layer */
return
FALSE
;
}
else
if
(
pdcp_p
->
next_pdcp_rx_sn
-
sequence_number
>
reordering_window
)
{
pdcp_p
->
rx_hfn
++
;
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
;
pdcp_sn_for_count
=
sequence_number
;
pdcp_p
->
next_pdcp_rx_sn
=
sequence_number
+
1
;
}
else
if
(
sequence_number
-
pdcp_p
->
next_pdcp_rx_sn
>=
reordering_window
)
{
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
-
1
;
pdcp_sn_for_count
=
sequence_number
;
}
else
if
(
sequence_number
>=
pdcp_p
->
next_pdcp_rx_sn
)
{
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
;
pdcp_sn_for_count
=
sequence_number
;
pdcp_p
->
next_pdcp_rx_sn
=
sequence_number
+
1
;
if
(
pdcp_p
->
next_pdcp_rx_sn
>
pdcp_p
->
maximum_pdcp_rx_sn
)
{
pdcp_p
->
next_pdcp_rx_sn
=
0
;
pdcp_p
->
rx_hfn
++
;
}
}
else
{
/* sequence_number < pdcp_p->next_pdcp_rx_sn */
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
;
pdcp_sn_for_count
=
sequence_number
;
}
if
(
pdcp_p
->
security_activated
==
1
)
{
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
start_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
else
{
start_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
security_ok
=
pdcp_validate_security
(
ctxt_pP
,
pdcp_p
,
srb_flagP
,
rb_idP
,
pdcp_header_len
,
rx_hfn_for_count
,
pdcp_sn_for_count
,
sdu_buffer_pP
->
data
,
sdu_buffer_sizeP
-
pdcp_tailer_len
)
==
0
;
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
stop_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
else
{
stop_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
}
else
{
s
tart_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
)
;
s
ecurity_ok
=
1
;
}
pdcp_validate_security
(
ctxt_p
P
,
pdcp_p
,
srb_flagP
,
rb_idP
,
pdcp_header_len
,
sequence_number
,
sdu_buffer_pP
->
data
,
sdu_buffer_sizeP
-
pdcp_tailer_len
);
if
(
security_ok
==
0
)
{
LOG_W
(
PDC
P
,
PROTOCOL_PDCP_CTXT_FMT
"security not validated for incoming PDPC DRB RLC/AM PDU
\n
"
,
PROTOCOL_PDCP_CTXT_ARGS
(
ctxt_pP
,
pdcp_p
));
LOG_W
(
PDCP
,
"Ignoring PDU...
\n
"
);
free_mem_block
(
sdu_buffer_pP
,
__func__
);
/* TODO: indicate integrity verification failure to upper layer */
return
FALSE
;
}
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
stop_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
/* TODO: specs say we have to store this PDU in a list and then deliver
* stored packets to upper layers according to a well defined
* procedure. The code below that deals with delivery is today
* too complex to do this properly, so we only send the current
* received packet. This is not correct and has to be fixed
* some day.
* In the meantime, let's pretend the last submitted PDCP SDU
* is the current one.
* TODO: we also have to deal with re-establishment PDU (control PDUs)
* that contain no SDU.
*/
pdcp_p
->
last_submitted_pdcp_rx_sn
=
sequence_number
;
break
;
}
/* case RLC_MODE_AM */
case
RLC_MODE_UM
:
/* process as described in 36.323 5.1.2.1.3 */
if
(
sequence_number
<
pdcp_p
->
next_pdcp_rx_sn
)
{
pdcp_p
->
rx_hfn
++
;
}
rx_hfn_for_count
=
pdcp_p
->
rx_hfn
;
pdcp_sn_for_count
=
sequence_number
;
pdcp_p
->
next_pdcp_rx_sn
=
sequence_number
+
1
;
if
(
pdcp_p
->
next_pdcp_rx_sn
>
pdcp_p
->
maximum_pdcp_rx_sn
)
{
pdcp_p
->
next_pdcp_rx_sn
=
0
;
pdcp_p
->
rx_hfn
++
;
}
if
(
pdcp_p
->
security_activated
==
1
)
{
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
start_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
else
{
start_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
security_ok
=
pdcp_validate_security
(
ctxt_pP
,
pdcp_p
,
srb_flagP
,
rb_idP
,
pdcp_header_len
,
rx_hfn_for_count
,
pdcp_sn_for_count
,
sdu_buffer_pP
->
data
,
sdu_buffer_sizeP
-
pdcp_tailer_len
)
==
0
;
if
(
ctxt_pP
->
enb_flag
==
ENB_FLAG_NO
)
{
stop_meas
(
&
eNB_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
else
{
stop_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
);
}
}
else
{
s
top_meas
(
&
UE_pdcp_stats
[
ctxt_pP
->
module_id
].
validate_security
)
;
s
ecurity_ok
=
1
;
}
}
#endif
}
else
{
if
(
security_ok
==
0
)
{
LOG_W
(
PDCP
,
PROTOCOL_PDCP_CTXT_FMT
"security not validated for incoming PDPC DRB RLC/UM PDU
\n
"
,
PROTOCOL_PDCP_CTXT_ARGS
(
ctxt_pP
,
pdcp_p
));
LOG_W
(
PDCP
,
"Ignoring PDU...
\n
"
);
free_mem_block
(
sdu_buffer_pP
,
__func__
);
/* TODO: indicate integrity verification failure to upper layer */
return
FALSE
;
}
break
;
default:
LOG_E
(
PDCP
,
"bad RLC mode, cannot happen.
\n
"
);
exit
(
1
);
}
/* switch (pdcp_p->rlc_mode) */
}
else
{
/* MBMS_flagP == 0 */
payload_offset
=
0
;
}
...
...
@@ -1536,22 +1696,23 @@ pdcp_config_req_asn1 (
pdcp_pP
->
status_report
=
rb_reportP
;
if
(
rb_snP
==
LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits
)
{
pdcp_pP
->
seq_num_size
=
PDCP_SN_12BIT
;
pdcp_pP
->
seq_num_size
=
12
;
pdcp_pP
->
maximum_pdcp_rx_sn
=
(
1
<<
12
)
-
1
;
}
else
if
(
rb_snP
==
LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits
)
{
pdcp_pP
->
seq_num_size
=
PDCP_SN_7BIT
;
pdcp_pP
->
seq_num_size
=
7
;
pdcp_pP
->
maximum_pdcp_rx_sn
=
(
1
<<
7
)
-
1
;
}
else
{
pdcp_pP
->
seq_num_size
=
PDCP_SN_5BIT
;
pdcp_pP
->
seq_num_size
=
5
;
pdcp_pP
->
maximum_pdcp_rx_sn
=
(
1
<<
5
)
-
1
;
}
pdcp_pP
->
rlc_mode
=
rlc_modeP
;
pdcp_pP
->
next_pdcp_tx_sn
=
0
;
pdcp_pP
->
next_pdcp_rx_sn
=
0
;
pdcp_pP
->
next_pdcp_rx_sn_before_integrity
=
0
;
pdcp_pP
->
tx_hfn
=
0
;
pdcp_pP
->
rx_hfn
=
0
;
pdcp_pP
->
last_submitted_pdcp_rx_sn
=
4095
;
pdcp_pP
->
first_missing_pdu
=
-
1
;
pdcp_pP
->
rx_hfn_offset
=
0
;
LOG_I
(
PDCP
,
PROTOCOL_PDCP_CTXT_FMT
" Action ADD LCID %d (%s id %d) "
"configured with SN size %d bits and RLC %s
\n
"
,
PROTOCOL_PDCP_CTXT_ARGS
(
ctxt_pP
,
pdcp_pP
),
...
...
openair2/LAYER2/PDCP_v10.1.0/pdcp.h
View file @
0f11865f
...
...
@@ -177,13 +177,12 @@ typedef struct pdcp_s {
*/
pdcp_sn_t
next_pdcp_tx_sn
;
pdcp_sn_t
next_pdcp_rx_sn
;
pdcp_sn_t
next
_pdcp_rx_sn
_before_integrity
;
pdcp_sn_t
maximum
_pdcp_rx_sn
;
/*
* TX and RX Hyper Frame Numbers
*/
pdcp_hfn_t
tx_hfn
;
pdcp_hfn_t
rx_hfn
;
pdcp_hfn_offset_t
rx_hfn_offset
;
// related to sn mismatch
/*
* SN of the last PDCP SDU delivered to upper layers
...
...
@@ -488,14 +487,6 @@ typedef struct {
#define REORDERING_WINDOW_SN_7BIT 64
#define REORDERING_WINDOW_SN_12BIT 2048
/*
* SN size
*/
#define PDCP_SN_5BIT 5
#define PDCP_SN_7BIT 7
#define PDCP_SN_12BIT 12
signed
int
pdcp_2_nas_irq
;
pdcp_stats_t
UE_pdcp_stats
[
MAX_MOBILES_PER_ENB
];
pdcp_stats_t
eNB_pdcp_stats
[
NUMBER_OF_eNB_MAX
];
...
...
openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h
View file @
0f11865f
...
...
@@ -173,7 +173,6 @@ int pdcp_netlink_dequeue_element(const protocol_ctxt_t* const ctxt_pP,
void
pdcp_config_set_security
(
const
protocol_ctxt_t
*
const
ctxt_pP
,
pdcp_t
*
pdcp_pP
,
rb_id_t
rb_idP
,
uint16_t
lc_idP
,
uint8_t
security_modeP
,
uint8_t
*
kRRCenc_pP
,
uint8_t
*
kRRCint_pP
,
uint8_t
*
kUPenc_pP
);
#if defined(ENABLE_SECURITY)
int
pdcp_apply_security
(
const
protocol_ctxt_t
*
const
ctxt_pP
,
pdcp_t
*
pdcp_entity
,
srb_flag_t
srb_flagP
,
...
...
@@ -188,10 +187,10 @@ int pdcp_validate_security(const protocol_ctxt_t* const ctxt_pP,
srb_flag_t
srb_flagP
,
rb_id_t
rb_id
,
uint8_t
pdcp_header_len
,
uint16_t
current_sn
,
uint32_t
hfn
,
int
sn
,
uint8_t
*
pdcp_pdu_buffer
,
uint16_t
sdu_buffer_size
);
#endif
/* defined(ENABLE_SECURITY) */
#endif
/** @}*/
openair2/LAYER2/PDCP_v10.1.0/pdcp_security.c
View file @
0f11865f
...
...
@@ -40,13 +40,6 @@
#include
"msc.h"
#include
"pdcp_primitives.h"
#if defined(ENABLE_SECURITY)
static
uint32_t
pdcp_get_next_count_tx
(
pdcp_t
*
const
pdcp_pP
,
const
srb_flag_t
srb_flagP
,
const
uint16_t
pdcp_sn
);
static
uint32_t
pdcp_get_next_count_rx
(
pdcp_t
*
const
pdcp_pP
,
const
srb_flag_t
srb_flagP
,
const
uint16_t
pdcp_sn
);
//-----------------------------------------------------------------------------
static
uint32_t
pdcp_get_next_count_tx
(
...
...
@@ -79,26 +72,25 @@ static
uint32_t
pdcp_get_next_count_rx
(
pdcp_t
*
const
pdcp_pP
,
const
srb_flag_t
srb_flagP
,
const
uint16_t
pdcp_sn
)
const
uint32_t
hfn
,
const
int
sn
)
{
uint32_t
count
;
/* For RX COUNT = RX_HFN << length of SN | pdcp SN of received PDU */
if
(
srb_flagP
)
{
/* 5 bits length SN */
count
=
(
((
pdcp_pP
->
rx_hfn
+
pdcp_pP
->
rx_hfn_offset
)
<<
5
)
|
(
pdcp_
sn
&
0x001F
)
)
;
count
=
(
hfn
<<
5
)
|
(
sn
&
0x001F
);
}
else
{
if
(
pdcp_pP
->
seq_num_size
==
LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits
)
{
if
(
pdcp_pP
->
seq_num_size
==
7
)
{
/* 7 bits length SN */
count
=
(
((
pdcp_pP
->
rx_hfn
+
pdcp_pP
->
rx_hfn_offset
)
<<
7
)
|
(
pdcp_
sn
&
0x007F
)
)
;
count
=
(
hfn
<<
7
)
|
(
sn
&
0x007F
);
}
else
{
// default
/* 12 bits length SN */
count
=
(
((
pdcp_pP
->
rx_hfn
+
pdcp_pP
->
rx_hfn_offset
)
<<
12
)
|
(
pdcp_
sn
&
0x0FFF
)
)
;
count
=
(
hfn
<<
12
)
|
(
sn
&
0x0FFF
);
}
}
// reset the hfn offset
pdcp_pP
->
rx_hfn_offset
=
0
;
LOG_D
(
PDCP
,
"[OSA] RX COUNT = 0x%08x
\n
"
,
count
);
return
count
;
...
...
@@ -182,7 +174,8 @@ pdcp_validate_security(
const
srb_flag_t
srb_flagP
,
const
rb_id_t
rb_id
,
const
uint8_t
pdcp_header_len
,
const
uint16_t
current_sn
,
const
uint32_t
hfn
,
const
int
sn
,
uint8_t
*
const
pdcp_pdu_buffer
,
const
uint16_t
sdu_buffer_size
)
...
...
@@ -201,7 +194,7 @@ pdcp_validate_security(
decrypt_params
.
direction
=
(
pdcp_pP
->
is_ue
==
1
)
?
SECU_DIRECTION_DOWNLINK
:
SECU_DIRECTION_UPLINK
;
decrypt_params
.
bearer
=
rb_id
-
1
;
decrypt_params
.
count
=
pdcp_get_next_count_rx
(
pdcp_pP
,
srb_flagP
,
current_
sn
);
decrypt_params
.
count
=
pdcp_get_next_count_rx
(
pdcp_pP
,
srb_flagP
,
hfn
,
sn
);
decrypt_params
.
message
=
&
pdcp_pdu_buffer
[
pdcp_header_len
];
decrypt_params
.
blength
=
(
sdu_buffer_size
-
pdcp_header_len
)
<<
3
;
decrypt_params
.
key_length
=
16
;
...
...
@@ -246,5 +239,3 @@ pdcp_validate_security(
return
0
;
}
#endif
/* ENABLE_SECURITY */
openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.c
View file @
0f11865f
...
...
@@ -140,152 +140,6 @@ boolean_t pdcp_advance_rx_window(pdcp_t* pdcp_entity)
return
TRUE
;
}
/**
* Checks if incoming PDU has a sequence number in accordance with the RX window
* @return 1 if SN is okay, 0 otherwise
* XXX Reordering window should also be handled here
*/
boolean_t
pdcp_is_rx_seq_number_valid
(
uint16_t
seq_num
,
pdcp_t
*
pdcp_entity
,
srb_flag_t
srb_flagP
)
{
uint16_t
reordering_window
=
0
;
LOG_D
(
PDCP
,
"Incoming RX Sequence number is %04d
\n
"
,
seq_num
);
if
(
pdcp_is_seq_num_size_valid
(
pdcp_entity
)
==
FALSE
||
pdcp_is_seq_num_valid
(
seq_num
,
pdcp_entity
->
seq_num_size
)
==
FALSE
)
{
return
FALSE
;
}
/*
* Mark received sequence numbers to keep track of missing ones
* (and to build PDCP Control PDU for PDCP status report)
*/
if
(
pdcp_mark_current_pdu_as_received
(
seq_num
,
pdcp_entity
)
==
TRUE
)
{
LOG_D
(
PDCP
,
"Received sequence number successfuly marked
\n
"
);
}
else
{
LOG_W
(
PDCP
,
"Cannot mark received sequence number on the bitmap!
\n
"
);
}
/*
* RX Procedures for SRB and DRBs as described in sec 5.1.2 of 36.323
*/
if
(
srb_flagP
)
{
// SRB
if
(
seq_num
<
pdcp_entity
->
next_pdcp_rx_sn
)
{
// decipher and verify the integrity of the PDU (if applicable) using COUNT based on RX_HFN + 1 and the received PDCP SN
pdcp_entity
->
rx_hfn
++
;
pdcp_entity
->
rx_hfn_offset
=
0
;
}
else
{
// decipher and verify the integrity of the PDU (if applicable) using COUNT based using COUNT based on RX_HFN and the received PDCP SN
pdcp_entity
->
rx_hfn_offset
=
0
;
}
// Assume that integrity verification is applicable and the integrity verification is passed successfully;
// or assume that integrity verification is not applicable:
// same the old next_pdcp_rx_sn to revert otherwise
pdcp_entity
->
next_pdcp_rx_sn_before_integrity
=
pdcp_entity
->
next_pdcp_rx_sn
;
if
(
seq_num
!=
pdcp_entity
->
next_pdcp_rx_sn
)
{
LOG_D
(
PDCP
,
"Re-adjusting the sequence number to %d
\n
"
,
seq_num
);
}
//set Next_PDCP_RX_SN to the received PDCP SN +1 ;
pdcp_entity
->
next_pdcp_rx_sn
=
seq_num
;
pdcp_advance_rx_window
(
pdcp_entity
);
// + 1, and check if it is larger than Maximum_PDCP_SN:
}
else
{
// DRB
if
(
pdcp_entity
->
seq_num_size
==
PDCP_SN_7BIT
)
{
reordering_window
=
REORDERING_WINDOW_SN_7BIT
;
}
else
{
reordering_window
=
REORDERING_WINDOW_SN_12BIT
;
}
switch
(
pdcp_entity
->
rlc_mode
)
{
case
RLC_MODE_AM
:
if
((
seq_num
-
p