Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF-Simple
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
0
Merge Requests
0
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
CommunityXG
OpenXG-AMF-Simple
Commits
80b2835a
Commit
80b2835a
authored
Aug 20, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polish the code for header files
parent
5704fffb
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
55 deletions
+33
-55
etc/amf.conf
etc/amf.conf
+1
-1
src/amf-app/amf_config.hpp
src/amf-app/amf_config.hpp
+0
-1
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+21
-27
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+1
-1
src/amf-app/mysql_db.cpp
src/amf-app/mysql_db.cpp
+1
-1
src/common/comUt.hpp
src/common/comUt.hpp
+1
-1
src/contexts/nas_context.hpp
src/contexts/nas_context.hpp
+0
-1
src/ngap/ngap_app/ngap_app.hpp
src/ngap/ngap_app/ngap_app.hpp
+7
-6
src/sctp/sctp_server.hpp
src/sctp/sctp_server.hpp
+1
-1
src/secu_algorithms/5gaka/authentication_algorithms_with_5gaka.hpp
...algorithms/5gaka/authentication_algorithms_with_5gaka.hpp
+0
-15
No files found.
etc/amf.conf
View file @
80b2835a
...
...
@@ -47,7 +47,7 @@ AMF =
NGAP_AMF
:{
INTERFACE_NAME
=
"ens3"
;
IPV4_ADDRESS
=
"read"
;
PORT
=
38412
;
PORT
=
38412
;
PPID
=
60
;
};
N11
:{
...
...
src/amf-app/amf_config.hpp
View file @
80b2835a
...
...
@@ -167,7 +167,6 @@ class amf_config {
int
load_interface
(
const
Setting
&
if_cfg
,
interface_cfg_t
&
cfg
);
int
load_thread_sched_params
(
const
libconfig
::
Setting
&
thread_sched_params_cfg
,
util
::
thread_sched_params
&
cfg
);
void
display
();
public:
unsigned
int
instance
;
std
::
string
pid_dir
;
interface_cfg_t
n2
;
...
...
src/amf-app/amf_n1.hpp
View file @
80b2835a
...
...
@@ -71,13 +71,12 @@ class amf_n1 {
~
amf_n1
();
void
handle_itti_message
(
itti_uplink_nas_data_ind
&
);
void
handle_itti_message
(
itti_downlink_nas_transfer
&
itti_msg
);
public:
// nas message decode
// nas message decode
void
nas_signalling_establishment_request_handle
(
SecurityHeaderType
type
,
std
::
shared_ptr
<
nas_context
>
nc
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
,
std
::
string
snn
,
uint8_t
ulCount
);
void
uplink_nas_msg_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
);
void
uplink_nas_msg_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
,
plmn_t
plmn
);
bool
check_security_header_type
(
SecurityHeaderType
&
type
,
uint8_t
*
buffer
);
public:
std
::
map
<
long
,
std
::
shared_ptr
<
nas_context
>>
amfueid2nas_context
;
// amf ue ngap id
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nas_context
>>
imsi2nas_context
;
std
::
map
<
std
::
string
,
long
>
supi2amfId
;
...
...
@@ -95,33 +94,15 @@ class amf_n1 {
void
set_amf_ue_ngap_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
,
std
::
shared_ptr
<
nas_context
>
nc
);
database_t
*
db_desc
;
private:
//nas message handlers
void
ue_initiate_de_registration_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
void
registration_request_handle
(
bool
isNasSig
,
std
::
shared_ptr
<
nas_context
>
nc
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
std
::
string
snn
,
bstring
reg
);
void
authentication_response_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
);
void
authentication_failure_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
);
void
security_mode_complete_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas_msg
);
void
security_mode_reject_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas_msg
);
void
ul_nas_transport_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
void
ul_nas_transport_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
,
plmn_t
plmn
);
void
sha256
(
unsigned
char
*
message
,
int
msg_len
,
unsigned
char
*
output
);
void
service_request_handle
(
bool
isNasSig
,
std
::
shared_ptr
<
nas_context
>
nc
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
private:
//authentication vector
bool
generate_authentication_vector
();
private:
void
itti_send_dl_nas_buffer_to_task_n2
(
bstring
&
b
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
private:
//response message
void
response_registration_reject_msg
(
uint8_t
cause_value
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
public:
//procedures
//procedures
void
run_registration_procedure
(
std
::
shared_ptr
<
nas_context
>
&
nc
);
void
run_initial_registration_procedure
();
void
run_mobility_registration_update_procedure
(
std
::
shared_ptr
<
nas_context
>
nc
);
public:
//authentication
//authentication
bool
auth_vectors_generator
(
std
::
shared_ptr
<
nas_context
>
&
nc
);
bool
authentication_vectors_generator_in_ausf
(
std
::
shared_ptr
<
nas_context
>
&
nc
);
bool
authentication_vectors_generator_in_udm
(
std
::
shared_ptr
<
nas_context
>
&
nc
);
public:
//mysql handlers in mysql_db.cpp
//mysql handlers in mysql_db.cpp
bool
get_mysql_auth_info
(
std
::
string
imsi
,
mysql_auth_info_t
&
resp
);
void
mysql_push_rand_sqn
(
std
::
string
imsi
,
uint8_t
*
rand_p
,
uint8_t
*
sqn
);
void
mysql_increment_sqn
(
std
::
string
imsi
);
...
...
@@ -137,15 +118,28 @@ class amf_n1 {
void
encode_nas_message_protected
(
nas_secu_ctx
*
nsc
,
bool
is_secu_ctx_new
,
uint8_t
security_header_type
,
uint8_t
direction
,
uint8_t
*
input_nas_buf
,
int
input_nas_len
,
bstring
&
encrypted_nas
);
bool
nas_message_integrity_protected
(
nas_secu_ctx
*
nsc
,
uint8_t
direction
,
uint8_t
*
input_nas
,
int
input_nas_len
,
uint32_t
&
mac
);
bool
nas_message_cipher_protected
(
nas_secu_ctx
*
nsc
,
uint8_t
direction
,
bstring
input_nas
,
bstring
&
output_nas
);
public:
void
dump_nas_message
(
uint8_t
*
buf
,
int
len
);
public:
void
ue_authentication_simulator
(
uint8_t
*
rand
,
uint8_t
*
autn
);
void
annex_a_4_33501
(
uint8_t
ck
[
16
],
uint8_t
ik
[
16
],
uint8_t
*
input
,
uint8_t
rand
[
16
],
std
::
string
serving_network
,
uint8_t
*
output
);
public:
void
send_itti_to_smf_services_consumer
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
uint8_t
request_type
,
uint8_t
pdu_session_id
,
bstring
dnn
,
bstring
sm_msg
);
public:
void
update_ue_information_statics
(
ue_infos
&
ueItem
,
const
std
::
string
connStatus
,
const
std
::
string
registerStatus
,
uint32_t
ranid
,
uint32_t
amfid
,
std
::
string
imsi
,
std
::
string
guti
,
std
::
string
mcc
,
std
::
string
mnc
,
uint32_t
cellId
);
private:
//nas message handlers
void
ue_initiate_de_registration_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
void
registration_request_handle
(
bool
isNasSig
,
std
::
shared_ptr
<
nas_context
>
nc
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
std
::
string
snn
,
bstring
reg
);
void
authentication_response_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
);
void
authentication_failure_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
plain_msg
);
void
security_mode_complete_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas_msg
);
void
security_mode_reject_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas_msg
);
void
ul_nas_transport_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
void
ul_nas_transport_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
,
plmn_t
plmn
);
void
sha256
(
unsigned
char
*
message
,
int
msg_len
,
unsigned
char
*
output
);
void
service_request_handle
(
bool
isNasSig
,
std
::
shared_ptr
<
nas_context
>
nc
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
);
//authentication vector
bool
generate_authentication_vector
();
void
itti_send_dl_nas_buffer_to_task_n2
(
bstring
&
b
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
//response message
void
response_registration_reject_msg
(
uint8_t
cause_value
,
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
);
};
}
...
...
src/amf-app/amf_n2.cpp
View file @
80b2835a
...
...
@@ -507,7 +507,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request &itti_msg) {
}
list
.
push_back
(
item
);
msg
->
setPduSessionResourceSetupRequestList
(
list
);
msg
->
setUEAggregateMaxBitRate
(
0x08a7d8c0
,
0x20989680
);
msg
->
setUEAggregateMaxBitRate
(
0x08a7d8c0
,
0x20989680
);
//TODO: remove hardcoded value
}
uint8_t
buffer
[
10000
];
...
...
src/amf-app/mysql_db.cpp
View file @
80b2835a
...
...
@@ -54,7 +54,7 @@ bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { /
res
=
mysql_store_result
(
db_desc
->
db_conn
);
pthread_mutex_unlock
(
&
db_desc
->
db_cs_mutex
);
if
(
!
res
)
{
Logger
::
amf_n1
().
error
(
"
d
ata fetched from MySQL is not present"
);
Logger
::
amf_n1
().
error
(
"
D
ata fetched from MySQL is not present"
);
return
false
;
}
if
(
row
=
mysql_fetch_row
(
res
))
{
...
...
src/common/comUt.hpp
View file @
80b2835a
...
...
@@ -33,7 +33,7 @@
#include <string>
//------------------------------------------------------------------------------
void
print_buffer
(
const
std
::
string
app
,
const
std
::
string
commit
,
uint8_t
*
buf
,
int
len
)
{
void
print_buffer
(
const
std
::
string
app
,
const
std
::
string
mode
,
const
std
::
string
commit
,
uint8_t
*
buf
,
int
len
)
{
if
(
!
app
.
compare
(
"amf_app"
))
Logger
::
amf_app
().
debug
(
commit
.
c_str
());
if
(
!
app
.
compare
(
"amf_n1"
))
...
...
src/contexts/nas_context.hpp
View file @
80b2835a
...
...
@@ -40,7 +40,6 @@ class nas_context {
public:
nas_context
();
~
nas_context
();
public:
bool
ctx_avaliability_ind
;
bool
is_stacs_available
;
long
amf_ue_ngap_id
;
...
...
src/ngap/ngap_app/ngap_app.hpp
View file @
80b2835a
...
...
@@ -48,19 +48,20 @@ class ngap_app : public sctp_application {
ngap_app
(
const
std
::
string
&
address
,
const
uint16_t
port_num
);
~
ngap_app
();
uint32_t
getPpid
();
protected:
sctp_server
sctp_s_38412
;
uint32_t
ppid_
;
std
::
map
<
sctp_assoc_id_t
,
std
::
shared_ptr
<
gnb_context
>>
assoc2gnbContext
;
mutable
std
::
shared_mutex
m_assoc2gnbContext
;
public:
void
handle_receive
(
bstring
payload
,
sctp_assoc_id_t
assoc_id
,
sctp_stream_id_t
stream
,
sctp_stream_id_t
instreams
,
sctp_stream_id_t
outstreams
);
void
handle_sctp_new_association
(
sctp_assoc_id_t
assoc_id
,
sctp_stream_id_t
instreams
,
sctp_stream_id_t
outstreams
);
bool
is_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
)
const
;
void
set_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
,
std
::
shared_ptr
<
gnb_context
>
gc
);
std
::
shared_ptr
<
gnb_context
>
assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
)
const
;
protected:
sctp_server
sctp_s_38412
;
uint32_t
ppid_
;
std
::
map
<
sctp_assoc_id_t
,
std
::
shared_ptr
<
gnb_context
>>
assoc2gnbContext
;
mutable
std
::
shared_mutex
m_assoc2gnbContext
;
};
}
...
...
src/sctp/sctp_server.hpp
View file @
80b2835a
...
...
@@ -98,7 +98,7 @@ class sctp_server {
int
sctp_get_localaddresses
(
int
sock
,
struct
sockaddr
**
local_addr
,
int
*
nb_local_addresses
);
int
sctp_get_peeraddresses
(
int
sock
,
struct
sockaddr
**
remote_addr
,
int
*
nb_remote_addresses
);
sctp_association_t
*
sctp_is_assoc_in_list
(
sctp_assoc_id_t
assoc_id
);
private:
int
socket_
;
sctp_application
*
app_
;
pthread_t
thread_
;
...
...
src/secu_algorithms/5gaka/authentication_algorithms_with_5gaka.hpp
View file @
80b2835a
...
...
@@ -102,25 +102,12 @@ typedef enum {
}
algorithm_type_dist_t
;
class
Authentication_5gaka
{
public:
/****** sequence number functions ********/
//struct sqn_ue_s *sqn_exists(uint64_t imsi);
//void sqn_insert(struct sqn_ue_s *item);
//void sqn_init(struct sqn_ue_s *item);
//struct sqn_ue_s *sqn_new(uint64_t imsi);
//void sqn_list_init(void);
//void sqn_get(uint64_t imsi, uint8_t sqn[6]);
public:
/****** random number functions *********/
//void random_init(void);
//void generate_random(uint8_t *random, ssize_t length);
public:
/****** internal algorithms f1 f2 f3 f4 f5 ********/
static
void
f1
(
const
uint8_t
opc
[
16
],
const
uint8_t
k
[
16
],
const
uint8_t
_rand
[
16
],
const
uint8_t
sqn
[
6
],
const
uint8_t
amf
[
2
],
uint8_t
mac_a
[
8
]);
static
void
f1star
(
const
uint8_t
kP
[
16
],
const
uint8_t
k
[
16
],
const
uint8_t
rand
[
16
],
const
uint8_t
sqn
[
6
],
const
uint8_t
amf
[
2
],
uint8_t
mac_s
[
8
]);
static
void
f2345
(
const
uint8_t
opc
[
16
],
const
uint8_t
k
[
16
],
const
uint8_t
_rand
[
16
],
uint8_t
res
[
8
],
uint8_t
ck
[
16
],
uint8_t
ik
[
16
],
uint8_t
ak
[
6
]);
static
void
f5star
(
const
uint8_t
kP
[
16
],
const
uint8_t
k
[
16
],
const
uint8_t
rand
[
16
],
uint8_t
ak
[
6
]);
public:
/****** key derive ***********/
static
void
kdf
(
uint8_t
*
key
,
uint16_t
key_len
,
uint8_t
*
s
,
uint16_t
s_len
,
uint8_t
*
out
,
uint16_t
out_len
);
static
void
derive_kasme
(
uint8_t
ck
[
16
],
uint8_t
ik
[
16
],
uint8_t
plmn
[
3
],
uint8_t
sqn
[
6
],
uint8_t
ak
[
6
],
uint8_t
kasme
[
32
]);
...
...
@@ -130,12 +117,10 @@ class Authentication_5gaka {
static
void
derive_knas
(
algorithm_type_dist_t
nas_alg_type
,
uint8_t
nas_alg_id
,
uint8_t
kamf
[
32
],
uint8_t
*
knas
);
static
void
derive_kgnb
(
uint32_t
uplinkCount
,
uint8_t
accessType
,
uint8_t
kamf
[
32
],
uint8_t
*
kgnb
);
static
uint8_t
*
sqn_ms_derive
(
const
uint8_t
opc
[
16
],
uint8_t
*
key
,
uint8_t
*
auts
,
uint8_t
*
rand
);
public:
/****** general functions ********/
static
void
ComputeOPc
(
const
uint8_t
kP
[
16
],
const
uint8_t
opP
[
16
],
uint8_t
opcP
[
16
]);
static
void
generate_autn
(
const
uint8_t
sqn
[
6
],
const
uint8_t
ak
[
6
],
const
uint8_t
amf
[
2
],
const
uint8_t
mac_a
[
8
],
uint8_t
autn
[
16
]);
static
int
generate_vector
(
const
uint8_t
opc
[
16
],
uint64_t
imsi
,
uint8_t
key
[
16
],
uint8_t
plmn
[
3
],
uint8_t
sqn
[
6
],
auc_vector_t
*
vector
);
public:
/****** Rijndael ********/
static
void
RijndaelKeySchedule
(
const
uint8_t
key
[
16
]);
static
void
RijndaelEncrypt
(
const
uint8_t
in
[
16
],
uint8_t
out
[
16
]);
...
...
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