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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
canghaiwuhen
OpenXG-RAN
Commits
141b56ba
Commit
141b56ba
authored
Nov 23, 2020
by
Chenyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encode authentication response
parent
4cb7ee39
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
31 deletions
+63
-31
openair3/NAS/NR_UE/nas_nrue_task.c
openair3/NAS/NR_UE/nas_nrue_task.c
+62
-29
openair3/NAS/NR_UE/nas_nrue_task.h
openair3/NAS/NR_UE/nas_nrue_task.h
+1
-2
No files found.
openair3/NAS/NR_UE/nas_nrue_task.c
View file @
141b56ba
...
@@ -44,6 +44,9 @@
...
@@ -44,6 +44,9 @@
extern
unsigned
char
NB_eNB_INST
;
extern
unsigned
char
NB_eNB_INST
;
extern
uint16_t
NB_UE_INST
;
extern
uint16_t
NB_UE_INST
;
static
int
_nas_mm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
);
static
int
_nas_mm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
);
void
*
nas_ue_task
(
void
*
args_p
)
void
*
nas_ue_task
(
void
*
args_p
)
{
{
int
nb_events
;
int
nb_events
;
...
@@ -156,31 +159,32 @@ void nr_nas_proc_dl_transfer_ind (UENAS_msg *msg, Byte_t *data, uint32_t len) {
...
@@ -156,31 +159,32 @@ void nr_nas_proc_dl_transfer_ind (UENAS_msg *msg, Byte_t *data, uint32_t len) {
nr_user_nas_t
UErrc
=
{
0
};
//QUES:user
nr_user_nas_t
UErrc
=
{
0
};
//QUES:user
int
size
;
int
size
;
decodeNasMsg
(
msg
,
data
,
len
);
decodeNasMsg
(
msg
,
data
,
len
);
msg
->
header
.
message_type
=
AUTHENTICATION_REQUEST
;
switch
(
msg
->
header
.
message_type
)
{
switch
(
msg
->
header
.
message_type
)
{
case
IDENTITY_REQUEST
:
{
//send identityResponse in NAS_UPLINK_DATA_REQ
//
case IDENTITY_REQUEST: { //send identityResponse in NAS_UPLINK_DATA_REQ
msg1
->
header
.
ex_protocol_discriminator
=
0
;
//
msg1->header.ex_protocol_discriminator=0;
msg1
->
header
.
security_header_type
=
0
;
//
msg1->header.security_header_type=0;
len1
+=
sizeof
(
uint8_t
);
//
len1 += sizeof(uint8_t);
msg1
->
header
.
message_type
=
IDENTITY_RESPONSE
;
//
msg1->header.message_type = IDENTITY_RESPONSE;
len1
+=
sizeof
(
uint8_t
);
//
len1 += sizeof(uint8_t);
len1
+=
identityResponse
((
void
**
)
&
msg1
->
identity_response
,
&
UErrc
);
//
len1 += identityResponse((void **)&msg1->identity_response, &UErrc);
size
=
encodeNasMsg
(
msg1
,
buffer
,
len1
);
//
size = encodeNasMsg(msg1, buffer, len1);
nas_itti_ul_data_req
(
0
,
buffer
,
size
,
0
);
//
nas_itti_ul_data_req(0,buffer,size,0);
break
;
//
break;
}
//
}
case
AUTHENTICATION_REQUEST
:
{
//send authenticationResponse
case
AUTHENTICATION_REQUEST
:
{
//send authenticationResponse
msg1
->
header
.
ex_protocol_discriminator
=
0
;
msg1
->
header
.
security_header_type
=
0
;
len1
+=
sizeof
(
uint8_t
);
msg1
->
header
.
message_type
=
AUTHENTICATION_RESPONSE
;
len1
+=
sizeof
(
uint8_t
);
len1
+=
authenticationResponse
((
void
**
)
&
msg1
->
identity_response
,
&
UErrc
);
len1
+=
authenticationResponse
((
void
**
)
&
msg1
->
identity_response
,
&
UErrc
);
size
=
encodeNasMsg
(
msg1
,
buffer
,
len1
);
size
=
encodeNasMsg
(
msg1
,
buffer
,
len1
);
nas_itti_ul_data_req
(
0
,
buffer
,
size
,
0
);
nas_itti_ul_data_req
(
0
,
buffer
,
size
,
0
);
break
;
break
;
}
}
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
printf
(
"aaaaaaaaaaaaa%x"
,
*
(
buffer
+
i
));
}
}
}
}
}
...
@@ -213,7 +217,7 @@ int encodeNasMsg(UENAS_msg *msg, uint8_t *buffer, uint32_t len) { //QUES:UENAS_m
...
@@ -213,7 +217,7 @@ int encodeNasMsg(UENAS_msg *msg, uint8_t *buffer, uint32_t len) { //QUES:UENAS_m
int
encode_result
=
0
;
int
encode_result
=
0
;
/* First encode the EMM message header */
/* First encode the EMM message header */
header_result
=
_
e
mm_msg_encode_header
(
&
msg
->
header
,
buffer
,
len
);
header_result
=
_
nas_
mm_msg_encode_header
(
&
msg
->
header
,
buffer
,
len
);
if
(
header_result
<
0
)
{
if
(
header_result
<
0
)
{
LOG_TRACE
(
ERROR
,
"NR_UE - Failed to encode EMM message header "
LOG_TRACE
(
ERROR
,
"NR_UE - Failed to encode EMM message header "
...
@@ -225,20 +229,19 @@ int encodeNasMsg(UENAS_msg *msg, uint8_t *buffer, uint32_t len) { //QUES:UENAS_m
...
@@ -225,20 +229,19 @@ int encodeNasMsg(UENAS_msg *msg, uint8_t *buffer, uint32_t len) { //QUES:UENAS_m
len
-=
header_result
;
len
-=
header_result
;
switch
(
msg
->
header
.
message_type
)
{
switch
(
msg
->
header
.
message_type
)
{
case
IDENTITY_RESPONSE
:
{
//
case IDENTITY_RESPONSE: {
encode_result
=
encode_identity_response
(
&
msg
->
identity_response
,
buffer
,
len
);
//
encode_result = encode_identity_response(&msg->identity_response, buffer, len);
break
;
//
break;
}
//
}
case
AUTHENTICATION_RESPONSE
:
{
case
AUTHENTICATION_RESPONSE
:
{
encode_result
=
encode_authentication_response
(
&
msg
->
authentication_response
,
buffer
,
len
);
encode_result
=
encode_authentication_response
5g
(
&
msg
->
authentication_response
,
buffer
,
len
);
break
;
break
;
}
}
}
}
LOG_FUNC_RETURN
(
header_result
+
encode_result
);
LOG_FUNC_RETURN
(
header_result
+
encode_result
);
}
}
static
int
_nas_mm_msg_decode_header
(
mm_msg_header_t
*
header
,
static
int
_nas_mm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
)
{
//QUES: 静态函数在哪声明?
const
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
int
size
=
0
;
/* Check the buffer length */
/* Check the buffer length */
...
@@ -257,18 +260,48 @@ static int _nas_mm_msg_decode_header(mm_msg_header_t *header,
...
@@ -257,18 +260,48 @@ static int _nas_mm_msg_decode_header(mm_msg_header_t *header,
return
(
size
);
return
(
size
);
}
}
static
int
_emm_msg_encode_header
(
const
emm_msg_header_t
*
header
,
static
int
_nas_mm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
int
size
=
0
;
/* Check the buffer length */
/* Check the buffer length */
if
(
len
<
sizeof
(
mm_msg_header_t
))
{
return
(
TLV_ENCODE_BUFFER_TOO_SHORT
);
}
/* Check the protocol discriminator */
/* Check the protocol discriminator */
if
(
header
->
ex_protocol_discriminator
!=
FGS_MOBILITY_MANAGEMENT_MESSAGE
)
{
LOG_TRACE
(
ERROR
,
"ESM-MSG - Unexpected extened protocol discriminator: 0x%x"
,
header
->
ex_protocol_discriminator
);
return
(
TLV_ENCODE_PROTOCOL_NOT_SUPPORTED
);
}
/* Encode the security header type and the protocol discriminator */
/* Encode the extendedprotocol discriminator */
ENCODE_U8
(
buffer
+
size
,
*
(
uint8_t
*
)(
header
),
size
);
ENCODE_U8
(
buffer
+
size
,
header
->
ex_protocol_discriminator
,
size
);
/* Encode the security header type */
ENCODE_U8
(
buffer
+
size
,
(
header
->
security_header_type
&
0xf
),
size
);
/* Encode the message type */
/* Encode the message type */
ENCODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
ENCODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
return
(
size
);
return
(
size
);
}
}
int
encode_authentication_response5g
(
authenticationresponse_t
*
authentication_response
,
uint8_t
*
buffer
,
uint32_t
len
)
//QUES:AuthenticationResponse.c 中函数同名先编译哪个?
{
int
encoded
=
0
;
if
(
authentication_response
->
iei
>
0
)
{
*
buffer
=
authentication_response
->
iei
;
encoded
++
;
}
*
(
buffer
+
encoded
)
=
authentication_response
->
RESlen
;
encoded
++
;
for
(
int
i
=
0
;
i
<
authentication_response
->
RESlen
;
i
++
)
{
*
(
buffer
+
encoded
)
=
authentication_response
->
RES
[
i
];
encoded
++
;
}
return
encoded
;
}
openair3/NAS/NR_UE/nas_nrue_task.h
View file @
141b56ba
...
@@ -46,7 +46,6 @@ void *nas_nrue_task(void *args_p);
...
@@ -46,7 +46,6 @@ void *nas_nrue_task(void *args_p);
void
nr_nas_proc_dl_transfer_ind
(
UENAS_msg
*
msg
,
Byte_t
*
data
,
uint32_t
len
);
void
nr_nas_proc_dl_transfer_ind
(
UENAS_msg
*
msg
,
Byte_t
*
data
,
uint32_t
len
);
int
decodeNasMsg
(
UENAS_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
int
decodeNasMsg
(
UENAS_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encodeNasMsg
(
UENAS_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encodeNasMsg
(
UENAS_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
static
int
_nas_mm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
);
//QUES: defined in emm_msg.c and no check
int
encode_authentication_response5g
(
authenticationresponse_t
*
authentication_response
,
uint8_t
*
buffer
,
uint32_t
len
);
static
int
_emm_msg_encode_header
(
const
emm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
/* NAS_TASK_H_ */
#endif
/* NAS_TASK_H_ */
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