Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-RAN
Commits
ccab22f4
Commit
ccab22f4
authored
Nov 19, 2024
by
Guido Casati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for E1AP Bearer Context Setup Request enc/dec library
parent
254a0e9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
3 deletions
+137
-3
openair2/E1AP/tests/CMakeLists.txt
openair2/E1AP/tests/CMakeLists.txt
+5
-2
openair2/E1AP/tests/e1ap_lib_test.c
openair2/E1AP/tests/e1ap_lib_test.c
+132
-1
No files found.
openair2/E1AP/tests/CMakeLists.txt
View file @
ccab22f4
...
@@ -2,5 +2,8 @@ add_executable(e1ap_lib_test e1ap_lib_test.c)
...
@@ -2,5 +2,8 @@ add_executable(e1ap_lib_test e1ap_lib_test.c)
add_dependencies
(
tests e1ap_lib_test
)
add_dependencies
(
tests e1ap_lib_test
)
add_test
(
NAME e1ap_lib_test COMMAND e1ap_lib_test
)
add_test
(
NAME e1ap_lib_test COMMAND e1ap_lib_test
)
target_link_libraries
(
e1ap_lib_test PRIVATE e1ap_lib
)
target_link_libraries
(
e1ap_lib_test PRIVATE e1ap_lib
)
target_link_libraries
(
e1ap_lib_test PRIVATE asn1_f1ap
)
target_link_libraries
(
e1ap_lib_test PRIVATE asn1_e1ap
)
target_include_directories
(
e1ap_lib_test PRIVATE ../../../
)
target_include_directories
(
e1ap_lib_test PRIVATE
${
CMAKE_SOURCE_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
openair2/E1AP/tests/e1ap_lib_test.c
View file @
ccab22f4
...
@@ -30,6 +30,137 @@
...
@@ -30,6 +30,137 @@
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
#include <stdio.h>
#include "E1AP/lib/e1ap_bearer_context_management.h"
#include "E1AP/lib/e1ap_lib_includes.h"
#include "common/utils/assertions.h"
#include "common/utils/assertions.h"
#include "e1ap.h"
void
exit_function
(
const
char
*
file
,
const
char
*
function
,
const
int
line
,
const
char
*
s
,
const
int
assert
)
{
printf
(
"detected error at %s:%d:%s: %s
\n
"
,
file
,
line
,
function
,
s
);
abort
();
}
static
E1AP_E1AP_PDU_t
*
e1ap_encode_decode
(
const
E1AP_E1AP_PDU_t
*
enc_pdu
)
{
// xer_fprint(stdout, &asn_DEF_E1AP_E1AP_PDU, enc_pdu);
DevAssert
(
enc_pdu
!=
NULL
);
char
errbuf
[
2048
];
size_t
errlen
=
sizeof
(
errbuf
);
int
ret
=
asn_check_constraints
(
&
asn_DEF_E1AP_E1AP_PDU
,
enc_pdu
,
errbuf
,
&
errlen
);
AssertFatal
(
ret
==
0
,
"asn_check_constraints() failed: %s
\n
"
,
errbuf
);
uint8_t
msgbuf
[
16384
];
asn_enc_rval_t
enc
=
aper_encode_to_buffer
(
&
asn_DEF_E1AP_E1AP_PDU
,
NULL
,
enc_pdu
,
msgbuf
,
sizeof
(
msgbuf
));
AssertFatal
(
enc
.
encoded
>
0
,
"aper_encode_to_buffer() failed
\n
"
);
E1AP_E1AP_PDU_t
*
dec_pdu
=
NULL
;
asn_codec_ctx_t
st
=
{.
max_stack_size
=
100
*
1000
};
asn_dec_rval_t
dec
=
aper_decode
(
&
st
,
&
asn_DEF_E1AP_E1AP_PDU
,
(
void
**
)
&
dec_pdu
,
msgbuf
,
enc
.
encoded
,
0
,
0
);
AssertFatal
(
dec
.
code
==
RC_OK
,
"aper_decode() failed
\n
"
);
// xer_fprint(stdout, &asn_DEF_E1AP_E1AP_PDU, dec_pdu);
return
dec_pdu
;
}
static
void
e1ap_msg_free
(
E1AP_E1AP_PDU_t
*
pdu
)
{
ASN_STRUCT_FREE
(
asn_DEF_E1AP_E1AP_PDU
,
pdu
);
}
/**
* @brief Test E1AP Bearer Context Setup Request encoding/decoding
*/
static
void
test_bearer_context_setup_request
(
void
)
{
bearer_context_pdcp_config_t
pdcp
=
{
.
discardTimer
=
E1AP_DiscardTimer_ms10
,
.
pDCP_Reestablishment
=
E1AP_PDCP_Reestablishment_true
,
.
pDCP_SN_Size_DL
=
E1AP_PDCP_SN_Size_s_12
,
.
pDCP_SN_Size_UL
=
E1AP_PDCP_SN_Size_s_12
,
.
reorderingTimer
=
10
,
.
rLC_Mode
=
E1AP_RLC_Mode_rlc_am
,
};
bearer_context_sdap_config_t
sdap
=
{
.
defaultDRB
=
1
,
.
sDAP_Header_DL
=
true
,
.
sDAP_Header_UL
=
true
,
};
qos_flow_to_setup_t
qos
=
{
.
qfi
=
1
,
.
qos_params
.
alloc_reten_priority
.
preemption_capability
=
E1AP_Pre_emptionCapability_shall_not_trigger_pre_emption
,
.
qos_params
.
alloc_reten_priority
.
preemption_vulnerability
=
E1AP_Pre_emptionVulnerability_not_pre_emptable
,
.
qos_params
.
alloc_reten_priority
.
priority_level
=
E1AP_PriorityLevel_highest
,
.
qos_params
.
qos_characteristics
.
non_dynamic
.
fiveqi
=
9
,
};
security_indication_t
security
=
{
.
confidentialityProtectionIndication
=
E1AP_ConfidentialityProtectionIndication_required
,
.
integrityProtectionIndication
=
E1AP_IntegrityProtectionIndication_required
,
.
maxIPrate
=
E1AP_MaxIPrate_max_UErate
,
};
// Step 1: Initialize the E1AP Bearer Context Setup Request
e1ap_bearer_setup_req_t
orig
=
{
.
gNB_cu_cp_ue_id
=
1234
,
.
cipheringAlgorithm
=
0x01
,
.
integrityProtectionAlgorithm
=
0x01
,
.
ueDlAggMaxBitRate
=
1000000000
,
.
bearerContextStatus
=
0
,
.
servingPLMNid
.
mcc
=
001
,
.
servingPLMNid
.
mnc
=
01
,
.
servingPLMNid
.
mnc_digit_length
=
0x02
,
.
activityNotificationLevel
=
ANL_PDU_SESSION
,
.
numPDUSessions
=
1
,
.
pduSession
[
0
].
sessionId
=
1
,
.
pduSession
[
0
].
sessionType
=
E1AP_PDU_Session_Type_ipv4
,
.
pduSession
[
0
].
nssai
.
sd
=
0x01
,
.
pduSession
[
0
].
nssai
.
sst
=
0x01
,
.
pduSession
[
0
].
securityIndication
=
security
,
.
pduSession
[
0
].
numDRB2Setup
=
1
,
.
pduSession
[
0
].
UP_TL_information
.
tlAddress
=
167772161
,
.
pduSession
[
0
].
UP_TL_information
.
teId
=
0x12345
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
id
=
1
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
sdap_config
=
sdap
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
pdcp_config
=
pdcp
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
id
=
1
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
numCellGroups
=
1
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
cellGroupList
[
0
]
=
MCG
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
numQosFlow2Setup
=
1
,
.
pduSession
[
0
].
DRBnGRanList
[
0
].
qosFlows
[
0
]
=
qos
,
};
memset
(
orig
.
encryptionKey
,
0xAB
,
sizeof
(
orig
.
encryptionKey
));
memset
(
orig
.
integrityProtectionKey
,
0xCD
,
sizeof
(
orig
.
integrityProtectionKey
));
// E1AP encode the original message
E1AP_E1AP_PDU_t
*
enc
=
encode_E1_bearer_context_setup_request
(
&
orig
);
// E1AP decode the encoded message
E1AP_E1AP_PDU_t
*
dec
=
e1ap_encode_decode
(
enc
);
// Free the E1AP encoded message
e1ap_msg_free
(
enc
);
// E1 message decode
e1ap_bearer_setup_req_t
decoded
=
{
0
};
bool
ret
=
decode_E1_bearer_context_setup_request
(
dec
,
&
decoded
);
AssertFatal
(
ret
,
"decode_E1_bearer_context_setup_request(): could not decode message
\n
"
);
// Free the E1AP decoded message
e1ap_msg_free
(
dec
);
// Equality check original/decoded
ret
=
eq_bearer_context_setup_request
(
&
orig
,
&
decoded
);
AssertFatal
(
ret
,
"eq_bearer_context_setup_request(): decoded message doesn't match
\n
"
);
// Free the memory for the decoded message
free_e1ap_context_setup_request
(
&
decoded
);
// Deep copy and equality check of the original message
e1ap_bearer_setup_req_t
cp
=
cp_bearer_context_setup_request
(
&
orig
);
ret
=
eq_bearer_context_setup_request
(
&
orig
,
&
cp
);
AssertFatal
(
ret
,
"eq_bearer_context_setup_request(): copied message doesn't match
\n
"
);
// Free the copied message and original
free_e1ap_context_setup_request
(
&
cp
);
free_e1ap_context_setup_request
(
&
orig
);
}
int
main
()
{
test_bearer_context_setup_request
();
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment