Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-SMF
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
OpenXG
OpenXG-SMF
Commits
f4ad53db
Commit
f4ad53db
authored
Sep 04, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add license header/format to prepare for release
parent
bfdf5757
Changes
97
Hide whitespace changes
Inline
Side-by-side
Showing
97 changed files
with
4616 additions
and
3018 deletions
+4616
-3018
src/nas/mm/mmData.h
src/nas/mm/mmData.h
+21
-22
src/nas/mm/msg/AuthenticationFailure.c
src/nas/mm/msg/AuthenticationFailure.c
+43
-28
src/nas/mm/msg/AuthenticationFailure.h
src/nas/mm/msg/AuthenticationFailure.h
+34
-11
src/nas/mm/msg/AuthenticationReject.c
src/nas/mm/msg/AuthenticationReject.c
+54
-40
src/nas/mm/msg/AuthenticationReject.h
src/nas/mm/msg/AuthenticationReject.h
+33
-9
src/nas/mm/msg/AuthenticationRequest.c
src/nas/mm/msg/AuthenticationRequest.c
+71
-63
src/nas/mm/msg/AuthenticationRequest.h
src/nas/mm/msg/AuthenticationRequest.h
+41
-18
src/nas/mm/msg/AuthenticationResponse.c
src/nas/mm/msg/AuthenticationResponse.c
+53
-44
src/nas/mm/msg/AuthenticationResponse.h
src/nas/mm/msg/AuthenticationResponse.h
+34
-10
src/nas/mm/msg/AuthenticationResult.c
src/nas/mm/msg/AuthenticationResult.c
+81
-64
src/nas/mm/msg/AuthenticationResult.h
src/nas/mm/msg/AuthenticationResult.h
+35
-10
src/nas/mm/msg/ConfigurationUpdateCommand.c
src/nas/mm/msg/ConfigurationUpdateCommand.c
+217
-201
src/nas/mm/msg/ConfigurationUpdateCommand.h
src/nas/mm/msg/ConfigurationUpdateCommand.h
+46
-22
src/nas/mm/msg/ConfigurationUpdateComplete.c
src/nas/mm/msg/ConfigurationUpdateComplete.c
+57
-41
src/nas/mm/msg/ConfigurationUpdateComplete.h
src/nas/mm/msg/ConfigurationUpdateComplete.h
+31
-7
src/nas/mm/msg/DLNASTransport.c
src/nas/mm/msg/DLNASTransport.c
+127
-111
src/nas/mm/msg/DLNASTransport.h
src/nas/mm/msg/DLNASTransport.h
+37
-13
src/nas/mm/msg/DeregistrationAccept.c
src/nas/mm/msg/DeregistrationAccept.c
+37
-21
src/nas/mm/msg/DeregistrationAccept.h
src/nas/mm/msg/DeregistrationAccept.h
+31
-7
src/nas/mm/msg/DeregistrationRequest.c
src/nas/mm/msg/DeregistrationRequest.c
+86
-67
src/nas/mm/msg/DeregistrationRequest.h
src/nas/mm/msg/DeregistrationRequest.h
+34
-10
src/nas/mm/msg/IdentityRequest.c
src/nas/mm/msg/IdentityRequest.c
+41
-25
src/nas/mm/msg/IdentityRequest.h
src/nas/mm/msg/IdentityRequest.h
+32
-8
src/nas/mm/msg/IdentityResponse.c
src/nas/mm/msg/IdentityResponse.c
+65
-51
src/nas/mm/msg/IdentityResponse.h
src/nas/mm/msg/IdentityResponse.h
+32
-8
src/nas/mm/msg/Notification.c
src/nas/mm/msg/Notification.c
+65
-49
src/nas/mm/msg/Notification.h
src/nas/mm/msg/Notification.h
+32
-8
src/nas/mm/msg/NotificationResponse.c
src/nas/mm/msg/NotificationResponse.c
+65
-49
src/nas/mm/msg/NotificationResponse.h
src/nas/mm/msg/NotificationResponse.h
+32
-8
src/nas/mm/msg/RegistrationAccept.c
src/nas/mm/msg/RegistrationAccept.c
+322
-321
src/nas/mm/msg/RegistrationAccept.h
src/nas/mm/msg/RegistrationAccept.h
+58
-36
src/nas/mm/msg/RegistrationComplete.c
src/nas/mm/msg/RegistrationComplete.c
+65
-49
src/nas/mm/msg/RegistrationComplete.h
src/nas/mm/msg/RegistrationComplete.h
+32
-8
src/nas/mm/msg/RegistrationReject.c
src/nas/mm/msg/RegistrationReject.c
+66
-52
src/nas/mm/msg/RegistrationReject.h
src/nas/mm/msg/RegistrationReject.h
+36
-12
src/nas/mm/msg/RegistrationRequest.c
src/nas/mm/msg/RegistrationRequest.c
+321
-323
src/nas/mm/msg/RegistrationRequest.h
src/nas/mm/msg/RegistrationRequest.h
+56
-32
src/nas/mm/msg/SecurityModeCommand.c
src/nas/mm/msg/SecurityModeCommand.c
+151
-139
src/nas/mm/msg/SecurityModeCommand.h
src/nas/mm/msg/SecurityModeCommand.h
+41
-22
src/nas/mm/msg/SecurityModeComplete.c
src/nas/mm/msg/SecurityModeComplete.c
+67
-51
src/nas/mm/msg/SecurityModeComplete.h
src/nas/mm/msg/SecurityModeComplete.h
+34
-11
src/nas/mm/msg/SecurityModeReject.c
src/nas/mm/msg/SecurityModeReject.c
+41
-25
src/nas/mm/msg/SecurityModeReject.h
src/nas/mm/msg/SecurityModeReject.h
+32
-8
src/nas/mm/msg/SecurityProtected5GSNASMessage.c
src/nas/mm/msg/SecurityProtected5GSNASMessage.c
+73
-57
src/nas/mm/msg/SecurityProtected5GSNASMessage.h
src/nas/mm/msg/SecurityProtected5GSNASMessage.h
+33
-9
src/nas/mm/msg/ServiceAccept.c
src/nas/mm/msg/ServiceAccept.c
+107
-91
src/nas/mm/msg/ServiceAccept.h
src/nas/mm/msg/ServiceAccept.h
+35
-11
src/nas/mm/msg/ServiceReject.c
src/nas/mm/msg/ServiceReject.c
+107
-91
src/nas/mm/msg/ServiceReject.h
src/nas/mm/msg/ServiceReject.h
+35
-11
src/nas/mm/msg/ServiceRequest.c
src/nas/mm/msg/ServiceRequest.c
+137
-118
src/nas/mm/msg/ServiceRequest.h
src/nas/mm/msg/ServiceRequest.h
+38
-14
src/nas/mm/msg/ULNASTransport.c
src/nas/mm/msg/ULNASTransport.c
+139
-122
src/nas/mm/msg/ULNASTransport.h
src/nas/mm/msg/ULNASTransport.h
+38
-14
src/nas/mm/msg/_5GMMStatus.c
src/nas/mm/msg/_5GMMStatus.c
+65
-49
src/nas/mm/msg/_5GMMStatus.h
src/nas/mm/msg/_5GMMStatus.h
+32
-8
src/nas/mm/msg/mmMsgDef.h
src/nas/mm/msg/mmMsgDef.h
+6
-2
src/nas/mm/msg/mm_msg.c
src/nas/mm/msg/mm_msg.c
+133
-187
src/nas/mm/msg/mm_msg.h
src/nas/mm/msg/mm_msg.h
+7
-19
src/nas/nas_message.h
src/nas/nas_message.h
+3
-8
src/nas/security/kdf.c
src/nas/security/kdf.c
+8
-21
src/nas/security/key_nas_deriver.c
src/nas/security/key_nas_deriver.c
+19
-26
src/nas/security/key_nas_encryption.c
src/nas/security/key_nas_encryption.c
+34
-34
src/nas/securityDef.h
src/nas/securityDef.h
+0
-7
src/nas/sm/msg/PDUSessionAuthenticationCommand.c
src/nas/sm/msg/PDUSessionAuthenticationCommand.c
+21
-0
src/nas/sm/msg/PDUSessionAuthenticationCommand.h
src/nas/sm/msg/PDUSessionAuthenticationCommand.h
+21
-0
src/nas/sm/msg/PDUSessionAuthenticationComplete.c
src/nas/sm/msg/PDUSessionAuthenticationComplete.c
+21
-0
src/nas/sm/msg/PDUSessionAuthenticationComplete.h
src/nas/sm/msg/PDUSessionAuthenticationComplete.h
+21
-0
src/nas/sm/msg/PDUSessionAuthenticationResult.c
src/nas/sm/msg/PDUSessionAuthenticationResult.c
+21
-0
src/nas/sm/msg/PDUSessionAuthenticationResult.h
src/nas/sm/msg/PDUSessionAuthenticationResult.h
+21
-0
src/nas/sm/msg/PDUSessionEstablishmentAccept.c
src/nas/sm/msg/PDUSessionEstablishmentAccept.c
+22
-1
src/nas/sm/msg/PDUSessionEstablishmentAccept.h
src/nas/sm/msg/PDUSessionEstablishmentAccept.h
+21
-0
src/nas/sm/msg/PDUSessionEstablishmentReject.c
src/nas/sm/msg/PDUSessionEstablishmentReject.c
+21
-0
src/nas/sm/msg/PDUSessionEstablishmentReject.h
src/nas/sm/msg/PDUSessionEstablishmentReject.h
+21
-0
src/nas/sm/msg/PDUSessionEstablishmentRequest.c
src/nas/sm/msg/PDUSessionEstablishmentRequest.c
+21
-0
src/nas/sm/msg/PDUSessionEstablishmentRequest.h
src/nas/sm/msg/PDUSessionEstablishmentRequest.h
+21
-0
src/nas/sm/msg/PDUSessionModificationCommand.c
src/nas/sm/msg/PDUSessionModificationCommand.c
+21
-0
src/nas/sm/msg/PDUSessionModificationCommand.h
src/nas/sm/msg/PDUSessionModificationCommand.h
+21
-0
src/nas/sm/msg/PDUSessionModificationCommandReject.c
src/nas/sm/msg/PDUSessionModificationCommandReject.c
+21
-0
src/nas/sm/msg/PDUSessionModificationCommandReject.h
src/nas/sm/msg/PDUSessionModificationCommandReject.h
+21
-0
src/nas/sm/msg/PDUSessionModificationComplete.c
src/nas/sm/msg/PDUSessionModificationComplete.c
+21
-0
src/nas/sm/msg/PDUSessionModificationComplete.h
src/nas/sm/msg/PDUSessionModificationComplete.h
+21
-0
src/nas/sm/msg/PDUSessionModificationReject.c
src/nas/sm/msg/PDUSessionModificationReject.c
+21
-0
src/nas/sm/msg/PDUSessionModificationReject.h
src/nas/sm/msg/PDUSessionModificationReject.h
+21
-0
src/nas/sm/msg/PDUSessionModificationRequest.c
src/nas/sm/msg/PDUSessionModificationRequest.c
+21
-0
src/nas/sm/msg/PDUSessionModificationRequest.h
src/nas/sm/msg/PDUSessionModificationRequest.h
+21
-0
src/nas/sm/msg/PDUSessionReleaseCommand.c
src/nas/sm/msg/PDUSessionReleaseCommand.c
+21
-0
src/nas/sm/msg/PDUSessionReleaseCommand.h
src/nas/sm/msg/PDUSessionReleaseCommand.h
+21
-0
src/nas/sm/msg/PDUSessionReleaseComplete.c
src/nas/sm/msg/PDUSessionReleaseComplete.c
+21
-0
src/nas/sm/msg/PDUSessionReleaseComplete.h
src/nas/sm/msg/PDUSessionReleaseComplete.h
+21
-0
src/nas/sm/msg/PDUSessionReleaseReject.c
src/nas/sm/msg/PDUSessionReleaseReject.c
+21
-0
src/nas/sm/msg/PDUSessionReleaseReject.h
src/nas/sm/msg/PDUSessionReleaseReject.h
+21
-0
src/nas/sm/msg/PDUSessionReleaseRequest.c
src/nas/sm/msg/PDUSessionReleaseRequest.c
+21
-0
src/nas/sm/msg/PDUSessionReleaseRequest.h
src/nas/sm/msg/PDUSessionReleaseRequest.h
+21
-0
src/nas/sm/msg/_5GSMStatus.c
src/nas/sm/msg/_5GSMStatus.c
+21
-0
src/nas/sm/msg/_5GSMStatus.h
src/nas/sm/msg/_5GSMStatus.h
+21
-0
src/nas/sm/smMsgDef.h
src/nas/sm/smMsgDef.h
+5
-0
src/nas/sm/sm_msg.h
src/nas/sm/sm_msg.h
+0
-4
No files found.
src/nas/mm/mmData.h
View file @
f4ad53db
...
...
@@ -19,7 +19,6 @@
* contact@openairinterface.org
*/
#ifndef FILE_MM_DATA_H_SEEN
#define FILE_MM_DATA_H_SEEN
...
...
@@ -35,35 +34,35 @@ typedef enum {
}
fivegmm_sc_type_t
;
typedef
struct
fivegmm_security_context_s
{
fivegmm_sc_type_t
sc_type
;
/* Type of security context */
//33401
/* state of security context is implicit due to its storage location (current/non-current)*/
fivegmm_sc_type_t
sc_type
;
/* Type of security context */
//33401
/* state of security context is implicit due to its storage location (current/non-current)*/
#define EKSI_MAX_VALUE 6
ksi_t
ksi
;
/* NAS key set identifier for E-UTRAN */
ksi_t
ksi
;
/* NAS key set identifier for E-UTRAN */
#define FIVEGMM_SECURITY_VECTOR_INDEX_INVALID (-1)
int
vector_index
;
/* Pointer on vector */
int
vector_index
;
/* Pointer on vector */
uint8_t
knas_enc
[
AUTH_KNAS_ENC_SIZE
];
/* NAS cyphering key */
uint8_t
knas_int
[
AUTH_KNAS_INT_SIZE
];
/* NAS integrity key */
struct
count_s
{
uint32_t
spare
:
8
;
uint32_t
overflow
:
16
;
uint32_t
seq_num
:
8
;
}
dl_count
,
ul_count
;
/* Downlink and uplink count parameters */
struct
count_s
{
uint32_t
spare
:
8
;
uint32_t
overflow
:
16
;
uint32_t
seq_num
:
8
;
}
dl_count
,
ul_count
;
/* Downlink and uplink count parameters */
struct
{
uint8_t
fivegs_encryption
;
/* algorithm used for ciphering */
uint8_t
fivegs_integrity
;
/* algorithm used for integrity protection */
uint8_t
umts_encryption
;
/* algorithm used for ciphering */
uint8_t
umts_integrity
;
/* algorithm used for integrity protection */
uint8_t
gprs_encryption
;
/* algorithm used for ciphering */
bool
umts_present
:
1
;
bool
gprs_present
:
1
;
}
capability
;
/* UE network capability */
uint8_t
fivegs_encryption
;
/* algorithm used for ciphering */
uint8_t
fivegs_integrity
;
/* algorithm used for integrity protection */
uint8_t
umts_encryption
;
/* algorithm used for ciphering */
uint8_t
umts_integrity
;
/* algorithm used for integrity protection */
uint8_t
gprs_encryption
;
/* algorithm used for ciphering */
bool
umts_present
:
1
;
bool
gprs_present
:
1
;
}
capability
;
/* UE network capability */
struct
{
uint8_t
encryption
:
4
;
/* algorithm used for ciphering */
uint8_t
integrity
:
4
;
/* algorithm used for integrity protection */
}
selected_algorithms
;
/* AMF selected algorithms */
uint8_t
encryption
:
4
;
/* algorithm used for ciphering */
uint8_t
integrity
:
4
;
/* algorithm used for integrity protection */
}
selected_algorithms
;
/* AMF selected algorithms */
uint8_t
activated
;
uint8_t
activated
;
}
fivegmm_security_context_t
;
#endif
src/nas/mm/msg/AuthenticationFailure.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,65 +27,59 @@
#include "TLVDecoder.h"
#include "AuthenticationFailure.h"
int
decode_authentication_failure
(
authentication_failure_msg
*
authentication_failure
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
decode_authentication_failure
(
authentication_failure_msg
*
authentication_failure
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_FAILURE_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_FAILURE_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode__5gmm_cause
(
&
authentication_failure
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode__5gmm_cause
(
&
authentication_failure
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
decoded
+=
decoded_result
;
/*
* Decoding optional fields
*/
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
break
;
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
)
{
case
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI
:
if
((
decoded_result
=
decode_authentication_failure_parameter
(
&
authentication_failure
->
authenticationfailureparameter
,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<=
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_failure
->
presence
|=
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT
;
}
break
;
case
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI
:
if
((
decoded_result
=
decode_authentication_failure_parameter
(
&
authentication_failure
->
authenticationfailureparameter
,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<=
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_failure
->
presence
|=
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT
;
}
break
;
}
}
return
decoded
;
}
int
encode_authentication_failure
(
authentication_failure_msg
*
authentication_failure
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_authentication_failure
(
authentication_failure_msg
*
authentication_failure
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_FAILURE_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_FAILURE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gmm_cause
(
authentication_failure
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode__5gmm_cause
(
authentication_failure
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
if
((
authentication_failure
->
presence
&
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT
)
==
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT
)
{
if
((
encoded_result
=
encode_authentication_failure_parameter
(
authentication_failure
->
authenticationfailureparameter
,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
authentication_failure
->
presence
&
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT
)
==
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT
)
{
if
((
encoded_result
=
encode_authentication_failure_parameter
(
authentication_failure
->
authenticationfailureparameter
,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
return
encoded
;
}
src/nas/mm/msg/AuthenticationFailure.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef AUTHENTICATION_FAILURE_H_
#define AUTHENTICATION_FAILURE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -6,7 +30,6 @@
#include "_5GMMCause.h"
#include "AuthenticationFailureParameter.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_FAILURE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -28,16 +51,16 @@
#define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT (1<<0)
#define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI 0x21
typedef
struct
authentication_failure_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
uint32_t
presence
;
AuthenticationFailureParameter
authenticationfailureparameter
;
}
authentication_failure_msg
;
typedef
struct
authentication_failure_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
uint32_t
presence
;
AuthenticationFailureParameter
authenticationfailureparameter
;
}
authentication_failure_msg
;
int
decode_authentication_failure
(
authentication_failure_msg
*
authenticationfailure
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_authentication_failure
(
authentication_failure_msg
*
authenticationfailure
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/AuthenticationReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,50 +27,43 @@
#include "TLVDecoder.h"
#include "AuthenticationReject.h"
int
decode_authentication_reject
(
authentication_reject_msg
*
authentication_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_REJECT_MINIMUM_LENGTH
,
len
);
int
decode_authentication_reject
(
authentication_reject_msg
*
authentication_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_REJECT_MINIMUM_LENGTH
,
len
);
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
)
{
case
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI
:
//if((decoded_result = decode_message_type (&authentication_reject->messagetype, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
if
((
decoded_result
=
decode_eap_message
(
&
authentication_reject
->
eapmessage
,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
{
return
decoded_result
;
}
else
{
while
(
len
-
decoded
>
0
){
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
){
case
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI
:
//if((decoded_result = decode_message_type (&authentication_reject->messagetype, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
if
((
decoded_result
=
decode_eap_message
(
&
authentication_reject
->
eapmessage
,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
{
return
decoded_result
;
}
else
{
decoded
+=
decoded_result
;
authentication_reject
->
presence
|=
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT
;
}
decoded
+=
decoded_result
;
authentication_reject
->
presence
|=
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT
;
}
}
return
decoded
;
}
return
decoded
;
}
int
encode_authentication_reject
(
authentication_reject_msg
*
authentication_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_authentication_reject
(
authentication_reject_msg
*
authentication_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_REJECT_MINIMUM_LENGTH
,
len
);
if
((
authentication_reject
->
presence
&
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT
)
==
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT
){
if
((
encoded_result
=
encode_eap_message
(
authentication_reject
->
eapmessage
,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
return
encoded
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_REJECT_MINIMUM_LENGTH
,
len
);
if
((
authentication_reject
->
presence
&
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT
)
==
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT
)
{
if
((
encoded_result
=
encode_eap_message
(
authentication_reject
->
eapmessage
,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
return
encoded
;
}
src/nas/mm/msg/AuthenticationReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef AUTHENTICATION_REJECT_H_
#define AUTHENTICATION_REJECT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_REJECT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -25,14 +48,15 @@
#define AUTHENTICATION_REJECT_EAP_MESSAGE_IEI 0x78
#define AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT (1<<0)
typedef
struct
authentication_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
uint8_t
presence
;
EAPMessage
eapmessage
;
}
authentication_reject_msg
;
typedef
struct
authentication_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
uint8_t
presence
;
EAPMessage
eapmessage
;
}
authentication_reject_msg
;
int
decode_authentication_reject
(
authentication_reject_msg
*
authenticationreject
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_authentication_reject
(
authentication_reject_msg
*
authenticationreject
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/AuthenticationRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -7,107 +28,94 @@
#include "AuthenticationRequest.h"
#include "3gpp_24.501.h"
int
decode_authentication_request
(
authentication_request_msg
*
authentication_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
int
decode_authentication_request
(
authentication_request_msg
*
authentication_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
//printf("decode_authentication_request len:%d\n", len);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_REQUEST_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_REQUEST_MINIMUM_LENGTH
,
len
);
/*
* Decoding mandatory fields
*/
if
((
decoded_result
=
decode_u8_nas_key_set_identifier
(
&
authentication_request
->
naskeysetidentifier
,
0
,
*
(
buffer
+
decoded
)
>>
4
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode_u8_nas_key_set_identifier
(
&
authentication_request
->
naskeysetidentifier
,
0
,
*
(
buffer
+
decoded
)
>>
4
,
len
-
decoded
))
<
0
)
return
decoded_result
;
//printf("naskeysetidentifier decoded_result:%d,tsc:%d\n", decoded_result, authentication_request->naskeysetidentifier.tsc);
decoded
++
;
if
((
decoded_result
=
decode_abba
(
&
authentication_request
->
abba
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
if
((
decoded_result
=
decode_abba
(
&
authentication_request
->
abba
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
while
(
len
-
decoded
>
0
)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
//printf("ieiDecoded(%x)\n",ieiDecoded);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
){
case
AUTHENTICATION_PARAMETER_RAND_IEI
:
if
((
decoded_result
=
decode_authentication_parameter_rand
(
&
authentication_request
->
authenticationparameterrand
,
AUTHENTICATION_PARAMETER_RAND_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_request
->
presence
|=
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT
;
}
break
;
case
AUTHENTICATION_PARAMETER_AUTN_IEI
:
if
((
decoded_result
=
decode_authentication_parameter_autn
(
&
authentication_request
->
authenticationparameterautn
,
AUTHENTICATION_PARAMETER_AUTN_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_request
->
presence
|=
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT
;
}
break
;
case
EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
authentication_request
->
eapmessage
,
EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_request
->
presence
|=
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT
;
}
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
)
{
case
AUTHENTICATION_PARAMETER_RAND_IEI
:
if
((
decoded_result
=
decode_authentication_parameter_rand
(
&
authentication_request
->
authenticationparameterrand
,
AUTHENTICATION_PARAMETER_RAND_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_request
->
presence
|=
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT
;
}
break
;
case
AUTHENTICATION_PARAMETER_AUTN_IEI
:
if
((
decoded_result
=
decode_authentication_parameter_autn
(
&
authentication_request
->
authenticationparameterautn
,
AUTHENTICATION_PARAMETER_AUTN_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_request
->
presence
|=
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT
;
}
break
;
case
EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
authentication_request
->
eapmessage
,
EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_request
->
presence
|=
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT
;
}
break
;
}
}
return
decoded
;
}
int
encode_authentication_request
(
authentication_request_msg
*
authentication_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_authentication_request
(
authentication_request_msg
*
authentication_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_REQUEST_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_REQUEST_MINIMUM_LENGTH
,
len
);
*
(
buffer
+
encoded
)
=
((
encode_u8_nas_key_set_identifier
(
&
authentication_request
->
naskeysetidentifier
)
&
0x0f
)
<<
4
)
|
0x00
;
encoded
++
;
encoded
++
;
if
((
encoded_result
=
encode_abba
(
authentication_request
->
abba
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode_abba
(
authentication_request
->
abba
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
if
((
authentication_request
->
presence
&
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT
)
==
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT
){
if
((
encoded_result
=
encode_authentication_parameter_rand
(
authentication_request
->
authenticationparameterrand
,
AUTHENTICATION_PARAMETER_RAND_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
authentication_request
->
presence
&
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT
)
==
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT
)
{
if
((
encoded_result
=
encode_authentication_parameter_rand
(
authentication_request
->
authenticationparameterrand
,
AUTHENTICATION_PARAMETER_RAND_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
authentication_request
->
presence
&
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT
)
==
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT
){
if
((
encoded_result
=
encode_authentication_parameter_autn
(
authentication_request
->
authenticationparameterautn
,
AUTHENTICATION_PARAMETER_AUTN_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
authentication_request
->
presence
&
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT
)
==
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT
)
{
if
((
encoded_result
=
encode_authentication_parameter_autn
(
authentication_request
->
authenticationparameterautn
,
AUTHENTICATION_PARAMETER_AUTN_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
authentication_request
->
presence
&
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT
)
==
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT
){
if
((
encoded_result
=
encode_eap_message
(
authentication_request
->
eapmessage
,
EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
authentication_request
->
presence
&
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT
)
==
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT
)
{
if
((
encoded_result
=
encode_eap_message
(
authentication_request
->
eapmessage
,
EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
return
encoded
;
}
src/nas/mm/msg/AuthenticationRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef AUTHENTICATION_REQUEST_H_
#define AUTHENTICATION_REQUEST_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -9,7 +33,6 @@
#include "AuthenticationParameterAUTN.h"
#include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_REQUEST_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -19,12 +42,11 @@
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
0)
/*
AUTHENTICATION_PARAMETER_RAND_MINIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_RAND_MINIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_AUTN_MINIMUM_LENGTH + \
EAP_MESSAGE_MINIMUM_LENGTH + \
0)
*/
EAP_MESSAGE_MINIMUM_LENGTH +
0)
*/
/* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_REQUEST_MAXIMUM_LENGTH ( \
...
...
@@ -45,18 +67,19 @@
#define AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT (1<<1)
#define AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT (1<<2)
typedef
struct
authentication_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASKeySetIdentifier
naskeysetidentifier
;
ABBA
abba
;
uint8_t
presence
;
AuthenticationParameterRAND
authenticationparameterrand
;
AuthenticationParameterAUTN
authenticationparameterautn
;
EAPMessage
eapmessage
;
}
authentication_request_msg
;
typedef
struct
authentication_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASKeySetIdentifier
naskeysetidentifier
;
ABBA
abba
;
uint8_t
presence
;
AuthenticationParameterRAND
authenticationparameterrand
;
AuthenticationParameterAUTN
authenticationparameterautn
;
EAPMessage
eapmessage
;
}
authentication_request_msg
;
int
decode_authentication_request
(
authentication_request_msg
*
authenticationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_authentication_request
(
authentication_request_msg
*
authenticationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/AuthenticationResponse.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,76 +27,64 @@
#include "TLVDecoder.h"
#include "AuthenticationResponse.h"
int
decode_authentication_response
(
authentication_response_msg
*
authentication_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
decode_authentication_response
(
authentication_response_msg
*
authentication_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
// uint8_t ieiDecoded = *(buffer+decoded);
// printf("ieiDecoded(%x)\n",ieiDecoded);
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
while
(
len
-
decoded
>
0
)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
printf
(
"ieiDecoded(%x)
\n
"
,
ieiDecoded
);
if
(
ieiDecoded
!=
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
&&
ieiDecoded
!=
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
)
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
printf
(
"ieiDecoded(%x)
\n
"
,
ieiDecoded
);
if
(
ieiDecoded
!=
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
&&
ieiDecoded
!=
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
)
break
;
switch
(
ieiDecoded
)
{
case
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
:
printf
(
"decoding AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
\n
"
);
if
((
decoded_result
=
decode_authentication_response_parameter
(
&
authentication_response
->
authenticationresponseparameter
,
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
printf
(
"decoded(%d)
\n
"
,
decoded
);
authentication_response
->
presence
|=
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
;
}
break
;
case
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
authentication_response
->
eapmessage
,
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_response
->
presence
|=
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
;
}
break
;
switch
(
ieiDecoded
)
{
case
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
:
printf
(
"decoding AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
\n
"
);
if
((
decoded_result
=
decode_authentication_response_parameter
(
&
authentication_response
->
authenticationresponseparameter
,
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
printf
(
"decoded(%d)
\n
"
,
decoded
);
authentication_response
->
presence
|=
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
;
}
break
;
case
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
authentication_response
->
eapmessage
,
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_response
->
presence
|=
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
;
}
break
;
}
}
return
decoded
;
}
int
encode_authentication_response
(
authentication_response_msg
*
authentication_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_authentication_response
(
authentication_response_msg
*
authentication_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
if
((
authentication_response
->
presence
&
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
)
==
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
){
if
((
encoded_result
=
encode_authentication_response_parameter
(
authentication_response
->
authenticationresponseparameter
,
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
authentication_response
->
presence
&
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
)
==
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
)
{
if
((
encoded_result
=
encode_authentication_response_parameter
(
authentication_response
->
authenticationresponseparameter
,
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
authentication_response
->
presence
&
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
)
==
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
){
if
((
encoded_result
=
encode_eap_message
(
authentication_response
->
eapmessage
,
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
authentication_response
->
presence
&
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
)
==
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
)
{
if
((
encoded_result
=
encode_eap_message
(
authentication_response
->
eapmessage
,
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
printf
(
"encoded encode_authentication_response
\n
"
);
...
...
src/nas/mm/msg/AuthenticationResponse.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef AUTHENTICATION_RESPONSE_H_
#define AUTHENTICATION_RESPONSE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -6,7 +30,6 @@
#include "AuthenticationResponseParameter.h"
#include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_RESPONSE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -31,15 +54,16 @@
#define AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT (1<<0)
#define AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT (1<<1)
typedef
struct
authentication_response_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
uint8_t
presence
;
AuthenticationResponseParameter
authenticationresponseparameter
;
EAPMessage
eapmessage
;
}
authentication_response_msg
;
typedef
struct
authentication_response_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
uint8_t
presence
;
AuthenticationResponseParameter
authenticationresponseparameter
;
EAPMessage
eapmessage
;
}
authentication_response_msg
;
int
decode_authentication_response
(
authentication_response_msg
*
authenticationresponse
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_authentication_response
(
authentication_response_msg
*
authenticationresponse
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/AuthenticationResult.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,76 +27,72 @@
#include "TLVDecoder.h"
#include "AuthenticationResult.h"
int
decode_authentication_result
(
authentication_result_msg
*
authentication_result
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
int
decode_authentication_result
(
authentication_result_msg
*
authentication_result
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_RESULT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_u8_nas_key_set_identifier
(
&
authentication_result
->
naskeysetidentifier
,
0
,
*
(
buffer
+
decoded
)
>>
4
,
len
-
decoded
))
<
0
)
return
decoded_result
;
decoded
++
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
AUTHENTICATION_RESULT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_eap_message
(
&
authentication_result
->
eapmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
while
(
len
-
decoded
>
0
){
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
printf
(
"ieiDecoded:0x%x
\n
"
,
ieiDecoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
){
case
AUTHENTICATION_RESULT_ABBA_IEI
:
if
((
decoded_result
=
decode_abba
(
&
authentication_result
->
abba
,
AUTHENTICATION_RESULT_ABBA_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_result
->
presence
|=
AUTHENTICATION_RESULT_ABBA_PRESENT
;
}
}
if
((
decoded_result
=
decode_u8_nas_key_set_identifier
(
&
authentication_result
->
naskeysetidentifier
,
0
,
*
(
buffer
+
decoded
)
>>
4
,
len
-
decoded
))
<
0
)
return
decoded_result
;
decoded
++
;
if
((
decoded_result
=
decode_eap_message
(
&
authentication_result
->
eapmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
printf
(
"ieiDecoded:0x%x
\n
"
,
ieiDecoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
)
{
case
AUTHENTICATION_RESULT_ABBA_IEI
:
if
((
decoded_result
=
decode_abba
(
&
authentication_result
->
abba
,
AUTHENTICATION_RESULT_ABBA_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
authentication_result
->
presence
|=
AUTHENTICATION_RESULT_ABBA_PRESENT
;
}
}
/*
if ((decoded_result = decode_abba (&authentication_result->abba,0 , buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
*/
return
decoded
;
}
/*
if ((decoded_result = decode_abba (&authentication_result->abba,0 , buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
*/
return
decoded
;
}
int
encode_authentication_result
(
authentication_result_msg
*
authentication_result
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_authentication_result
(
authentication_result_msg
*
authentication_result
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_RESULT_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
AUTHENTICATION_RESULT_MINIMUM_LENGTH
,
len
);
*
(
buffer
+
encoded
)
=
((
encode_u8_nas_key_set_identifier
(
&
authentication_result
->
naskeysetidentifier
)
&
0x0f
)
<<
4
)
|
0x00
;
encoded
++
;
if
((
encoded_result
=
encode_eap_message
(
authentication_result
->
eapmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
authentication_result
->
presence
&
AUTHENTICATION_RESULT_ABBA_PRESENT
)
==
AUTHENTICATION_RESULT_ABBA_PRESENT
){
if
((
encoded_result
=
encode_abba
(
authentication_result
->
abba
,
AUTHENTICATION_RESULT_ABBA_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_abba (authentication_result->abba,0, buffer+encoded,len-encoded))<0)
return encoded_result;
*
(
buffer
+
encoded
)
=
((
encode_u8_nas_key_set_identifier
(
&
authentication_result
->
naskeysetidentifier
)
&
0x0f
)
<<
4
)
|
0x00
;
encoded
++
;
if
((
encoded_result
=
encode_eap_message
(
authentication_result
->
eapmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
authentication_result
->
presence
&
AUTHENTICATION_RESULT_ABBA_PRESENT
)
==
AUTHENTICATION_RESULT_ABBA_PRESENT
)
{
if
((
encoded_result
=
encode_abba
(
authentication_result
->
abba
,
AUTHENTICATION_RESULT_ABBA_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
return
encoded
;
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_abba (authentication_result->abba,0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
return
encoded
;
}
src/nas/mm/msg/AuthenticationResult.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef AUTHENTICATION_RESULT_H_
#define AUTHENTICATION_RESULT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -29,16 +53,17 @@
#define AUTHENTICATION_RESULT_ABBA_IEI 0x38
#define AUTHENTICATION_RESULT_ABBA_PRESENT (1<<0)
typedef
struct
authentication_result_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASKeySetIdentifier
naskeysetidentifier
;
EAPMessage
eapmessage
;
uint8_t
presence
;
ABBA
abba
;
}
authentication_result_msg
;
typedef
struct
authentication_result_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASKeySetIdentifier
naskeysetidentifier
;
EAPMessage
eapmessage
;
uint8_t
presence
;
ABBA
abba
;
}
authentication_result_msg
;
int
decode_authentication_result
(
authentication_result_msg
*
authenticationresult
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_authentication_result
(
authentication_result_msg
*
authenticationresult
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/ConfigurationUpdateCommand.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,207 +27,202 @@
#include "TLVDecoder.h"
#include "ConfigurationUpdateCommand.h"
int
decode_configuration_update_command
(
configuration_update_command_msg
*
configuration_update_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
configuration_update_command
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
configuration_update_command
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
configuration_update_command
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_configuration_update_indication
(
&
configuration_update_command
->
configurationupdateindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gs_mobile_identity
(
&
configuration_update_command
->
_5gsmobileidentity
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gs_tracking_area_identity_list
(
&
configuration_update_command
->
_5gstrackingareaidentitylist
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_nssai
(
&
configuration_update_command
->
nssai
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_service_area_list
(
&
configuration_update_command
->
servicearealist
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_network_name
(
&
configuration_update_command
->
networkname
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_time_zone
(
&
configuration_update_command
->
timezone
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_time_zone_and_time
(
&
configuration_update_command
->
timezoneandtime
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_daylight_saving_time
(
&
configuration_update_command
->
daylightsavingtime
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_ladn_information
(
&
configuration_update_command
->
ladninformation
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_mico_indication
(
&
configuration_update_command
->
micoindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_network_slicing_indication
(
&
configuration_update_command
->
networkslicingindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_rejected_nssai
(
&
configuration_update_command
->
rejectednssai
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_operator_defined_access_category_definitions
(
&
configuration_update_command
->
operatordefinedaccesscategorydefinitions
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_sms_indication
(
&
configuration_update_command
->
smsindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
int
decode_configuration_update_command
(
configuration_update_command_msg
*
configuration_update_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
configuration_update_command
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
configuration_update_command
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
configuration_update_command
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_configuration_update_indication
(
&
configuration_update_command
->
configurationupdateindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gs_mobile_identity
(
&
configuration_update_command
->
_5gsmobileidentity
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gs_tracking_area_identity_list
(
&
configuration_update_command
->
_5gstrackingareaidentitylist
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_nssai
(
&
configuration_update_command
->
nssai
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_service_area_list
(
&
configuration_update_command
->
servicearealist
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_network_name
(
&
configuration_update_command
->
networkname
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_time_zone
(
&
configuration_update_command
->
timezone
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_time_zone_and_time
(
&
configuration_update_command
->
timezoneandtime
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_daylight_saving_time
(
&
configuration_update_command
->
daylightsavingtime
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_ladn_information
(
&
configuration_update_command
->
ladninformation
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_mico_indication
(
&
configuration_update_command
->
micoindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_network_slicing_indication
(
&
configuration_update_command
->
networkslicingindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_rejected_nssai
(
&
configuration_update_command
->
rejectednssai
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_operator_defined_access_category_definitions
(
&
configuration_update_command
->
operatordefinedaccesscategorydefinitions
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_sms_indication
(
&
configuration_update_command
->
smsindication
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
}
int
encode_configuration_update_command
(
configuration_update_command_msg
*
configuration_update_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
configuration_update_command
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
configuration_update_command
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
configuration_update_command
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_configuration_update_indication
(
configuration_update_command
->
configurationupdateindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gs_mobile_identity
(
configuration_update_command
->
_5gsmobileidentity
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gs_tracking_area_identity_list
(
configuration_update_command
->
_5gstrackingareaidentitylist
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_nssai
(
configuration_update_command
->
nssai
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_service_area_list
(
configuration_update_command
->
servicearealist
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_network_name
(
configuration_update_command
->
networkname
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_time_zone
(
configuration_update_command
->
timezone
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_time_zone_and_time
(
configuration_update_command
->
timezoneandtime
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_daylight_saving_time
(
configuration_update_command
->
daylightsavingtime
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_ladn_information
(
configuration_update_command
->
ladninformation
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_mico_indication
(
configuration_update_command
->
micoindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_network_slicing_indication
(
configuration_update_command
->
networkslicingindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_rejected_nssai
(
configuration_update_command
->
rejectednssai
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_operator_defined_access_category_definitions
(
configuration_update_command
->
operatordefinedaccesscategorydefinitions
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_sms_indication
(
configuration_update_command
->
smsindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
int
encode_configuration_update_command
(
configuration_update_command_msg
*
configuration_update_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
configuration_update_command
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
configuration_update_command
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
configuration_update_command
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_configuration_update_indication
(
configuration_update_command
->
configurationupdateindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gs_mobile_identity
(
configuration_update_command
->
_5gsmobileidentity
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gs_tracking_area_identity_list
(
configuration_update_command
->
_5gstrackingareaidentitylist
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_nssai
(
configuration_update_command
->
nssai
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_service_area_list
(
configuration_update_command
->
servicearealist
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_network_name
(
configuration_update_command
->
networkname
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_time_zone
(
configuration_update_command
->
timezone
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_time_zone_and_time
(
configuration_update_command
->
timezoneandtime
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_daylight_saving_time
(
configuration_update_command
->
daylightsavingtime
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_ladn_information
(
configuration_update_command
->
ladninformation
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_mico_indication
(
configuration_update_command
->
micoindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_network_slicing_indication
(
configuration_update_command
->
networkslicingindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_rejected_nssai
(
configuration_update_command
->
rejectednssai
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_operator_defined_access_category_definitions
(
configuration_update_command
->
operatordefinedaccesscategorydefinitions
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_sms_indication
(
configuration_update_command
->
smsindication
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
}
src/nas/mm/msg/ConfigurationUpdateCommand.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef CONFIGURATION_UPDATE_COMMAND_H_
#define CONFIGURATION_UPDATE_COMMAND_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -19,7 +43,6 @@
#include "OperatorDefinedAccessCategoryDefinitions.h"
#include "SMSIndication.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -64,27 +87,28 @@
SMS_INDICATION_MAXIMUM_LENGTH + \
0)
typedef
struct
configuration_update_command_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
ConfigurationUpdateIndication
configurationupdateindication
;
_5GSMobileIdentity
_5gsmobileidentity
;
_5GSTrackingAreaIdentityList
_5gstrackingareaidentitylist
;
NSSAI
nssai
;
ServiceAreaList
servicearealist
;
NetworkName
networkname
;
TimeZone
timezone
;
TimeZoneAndTime
timezoneandtime
;
DaylightSavingTime
daylightsavingtime
;
LADNInformation
ladninformation
;
MICOIndication
micoindication
;
NetworkSlicingIndication
networkslicingindication
;
RejectedNSSAI
rejectednssai
;
OperatorDefinedAccessCategoryDefinitions
operatordefinedaccesscategorydefinitions
;
SMSIndication
smsindication
;
}
configuration_update_command_msg
;
typedef
struct
configuration_update_command_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
ConfigurationUpdateIndication
configurationupdateindication
;
_5GSMobileIdentity
_5gsmobileidentity
;
_5GSTrackingAreaIdentityList
_5gstrackingareaidentitylist
;
NSSAI
nssai
;
ServiceAreaList
servicearealist
;
NetworkName
networkname
;
TimeZone
timezone
;
TimeZoneAndTime
timezoneandtime
;
DaylightSavingTime
daylightsavingtime
;
LADNInformation
ladninformation
;
MICOIndication
micoindication
;
NetworkSlicingIndication
networkslicingindication
;
RejectedNSSAI
rejectednssai
;
OperatorDefinedAccessCategoryDefinitions
operatordefinedaccesscategorydefinitions
;
SMSIndication
smsindication
;
}
configuration_update_command_msg
;
int
decode_configuration_update_command
(
configuration_update_command_msg
*
configurationupdatecommand
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_configuration_update_command
(
configuration_update_command_msg
*
configurationupdatecommand
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/ConfigurationUpdateComplete.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,57 +27,52 @@
#include "TLVDecoder.h"
#include "ConfigurationUpdateComplete.h"
int
decode_configuration_update_complete
(
configuration_update_complete_msg
*
configuration_update_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH
,
len
);
int
decode_configuration_update_complete
(
configuration_update_complete_msg
*
configuration_update_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
configuration_update_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_security_header_type
(
&
configuration_update_complete
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
configuration_update_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
configuration_update_complete
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
configuration_update_complete
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
configuration_update_complete
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_configuration_update_complete
(
configuration_update_complete_msg
*
configuration_update_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_configuration_update_complete
(
configuration_update_complete_msg
*
configuration_update_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
configuration_update_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_security_header_type
(
configuration_update_complete
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
configuration_update_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
configuration_update_complete
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
configuration_update_complete
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
configuration_update_complete
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/ConfigurationUpdateComplete.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef CONFIGURATION_UPDATE_COMPLETE_H_
#define CONFIGURATION_UPDATE_COMPLETE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -19,12 +42,13 @@
MESSAGE_TYPE_MAXIMUM_LENGTH + \
0)
typedef
struct
configuration_update_complete_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
}
configuration_update_complete_msg
;
typedef
struct
configuration_update_complete_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
}
configuration_update_complete_msg
;
int
decode_configuration_update_complete
(
configuration_update_complete_msg
*
configurationupdatecomplete
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_configuration_update_complete
(
configuration_update_complete_msg
*
configurationupdatecomplete
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/DLNASTransport.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,117 +27,112 @@
#include "TLVDecoder.h"
#include "DLNASTransport.h"
int
decode_dlnas_transport
(
dlnas_transport_msg
*
dlnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
DLNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
dlnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
dlnas_transport
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
dlnas_transport
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container_type
(
&
dlnas_transport
->
payloadcontainertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container
(
&
dlnas_transport
->
payloadcontainer
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_identity2
(
&
dlnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_additional_information
(
&
dlnas_transport
->
additionalinformation
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
dlnas_transport
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_gprs_timer3
(
&
dlnas_transport
->
gprstimer3
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
int
decode_dlnas_transport
(
dlnas_transport_msg
*
dlnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
DLNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
dlnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
dlnas_transport
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
dlnas_transport
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container_type
(
&
dlnas_transport
->
payloadcontainertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container
(
&
dlnas_transport
->
payloadcontainer
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_identity2
(
&
dlnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_additional_information
(
&
dlnas_transport
->
additionalinformation
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
dlnas_transport
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_gprs_timer3
(
&
dlnas_transport
->
gprstimer3
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
}
int
encode_dlnas_transport
(
dlnas_transport_msg
*
dlnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
DLNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
dlnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
dlnas_transport
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
dlnas_transport
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container_type
(
dlnas_transport
->
payloadcontainertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container
(
dlnas_transport
->
payloadcontainer
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_identity2
(
dlnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_additional_information
(
dlnas_transport
->
additionalinformation
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gmm_cause
(
dlnas_transport
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_gprs_timer3
(
dlnas_transport
->
gprstimer3
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
int
encode_dlnas_transport
(
dlnas_transport_msg
*
dlnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
DLNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
dlnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
dlnas_transport
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
dlnas_transport
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container_type
(
dlnas_transport
->
payloadcontainertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container
(
dlnas_transport
->
payloadcontainer
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_identity2
(
dlnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_additional_information
(
dlnas_transport
->
additionalinformation
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gmm_cause
(
dlnas_transport
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_gprs_timer3
(
dlnas_transport
->
gprstimer3
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
}
src/nas/mm/msg/DLNASTransport.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef DLNAS_TRANSPORT_H_
#define DLNAS_TRANSPORT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -10,7 +34,6 @@
#include "_5GMMCause.h"
#include "GPRSTimer3.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DLNAS_TRANSPORT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -37,18 +60,19 @@
GPRS_TIMER3_MAXIMUM_LENGTH + \
0)
typedef
struct
dlnas_transport_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PayloadContainerType
payloadcontainertype
;
PayloadContainer
payloadcontainer
;
PDUSessionIdentity2
pdusessionidentity2
;
AdditionalInformation
additionalinformation
;
_5GMMCause
_5gmmcause
;
GPRSTimer3
gprstimer3
;
}
dlnas_transport_msg
;
typedef
struct
dlnas_transport_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PayloadContainerType
payloadcontainertype
;
PayloadContainer
payloadcontainer
;
PDUSessionIdentity2
pdusessionidentity2
;
AdditionalInformation
additionalinformation
;
_5GMMCause
_5gmmcause
;
GPRSTimer3
gprstimer3
;
}
dlnas_transport_msg
;
int
decode_dlnas_transport
(
dlnas_transport_msg
*
dlnastransport
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_dlnas_transport
(
dlnas_transport_msg
*
dlnastransport
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/DeregistrationAccept.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,57 +27,52 @@
#include "TLVDecoder.h"
#include "DeregistrationAccept.h"
int
decode_deregistration_accept
(
deregistration_accept_msg
*
deregistration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
decode_deregistration_accept
(
deregistration_accept_msg
*
deregistration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
DEREGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
DEREGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
deregistration_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
deregistration_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
deregistration_accept
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode_security_header_type
(
&
deregistration_accept
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
deregistration_accept
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode_message_type
(
&
deregistration_accept
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
decoded
+=
decoded_result
;
return
decoded
;
}
int
encode_deregistration_accept
(
deregistration_accept_msg
*
deregistration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_deregistration_accept
(
deregistration_accept_msg
*
deregistration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
DEREGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
DEREGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
deregistration_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
deregistration_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
deregistration_accept
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode_security_header_type
(
deregistration_accept
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
deregistration_accept
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode_message_type
(
deregistration_accept
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
return
encoded
;
}
src/nas/mm/msg/DeregistrationAccept.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef DEREGISTRATION_ACCEPT_H_
#define DEREGISTRATION_ACCEPT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DEREGISTRATION_ACCEPT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -19,12 +42,13 @@
MESSAGE_TYPE_MAXIMUM_LENGTH + \
0)
typedef
struct
deregistration_accept_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
}
deregistration_accept_msg
;
typedef
struct
deregistration_accept_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
}
deregistration_accept_msg
;
int
decode_deregistration_accept
(
deregistration_accept_msg
*
deregistrationaccept
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_deregistration_accept
(
deregistration_accept_msg
*
deregistrationaccept
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/DeregistrationRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,86 +27,84 @@
#include "TLVDecoder.h"
#include "DeregistrationRequest.h"
int
decode_deregistration_request
(
deregistration_request_msg
*
deregistration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
//TODO: to be implemeted
int
decode_deregistration_request
(
deregistration_request_msg
*
deregistration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
// int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
DEREGISTRATION_REQUEST_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
DEREGISTRATION_REQUEST_MINIMUM_LENGTH
,
len
);
/*
if((decoded_result = decode_extended_protocol_discriminator (&deregistration_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_security_header_type (&deregistration_request->securityheadertype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_message_type (&deregistration_request->messagetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_deregistration_type (&deregistration_request->deregistrationtype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_key_set_identifier (&deregistration_request->naskeysetidentifier, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode__5gs_mobile_identity (&deregistration_request->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_extended_protocol_discriminator (&deregistration_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_security_header_type (&deregistration_request->securityheadertype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_message_type (&deregistration_request->messagetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_deregistration_type (&deregistration_request->deregistrationtype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_key_set_identifier (&deregistration_request->naskeysetidentifier, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode__5gs_mobile_identity (&deregistration_request->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
}
int
encode_deregistration_request
(
deregistration_request_msg
*
deregistration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_deregistration_request
(
deregistration_request_msg
*
deregistration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
// int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
DEREGISTRATION_REQUEST_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
DEREGISTRATION_REQUEST_MINIMUM_LENGTH
,
len
);
/*
if((encoded_result = encode_extended_protocol_discriminator (deregistration_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_security_header_type (deregistration_request->securityheadertype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_message_type (deregistration_request->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_deregistration_type (deregistration_request->deregistrationtype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_nas_key_set_identifier (deregistration_request->naskeysetidentifier, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode__5gs_mobile_identity (deregistration_request->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_extended_protocol_discriminator (deregistration_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_security_header_type (deregistration_request->securityheadertype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_message_type (deregistration_request->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_deregistration_type (deregistration_request->deregistrationtype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_nas_key_set_identifier (deregistration_request->naskeysetidentifier, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode__5gs_mobile_identity (deregistration_request->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
return
encoded
;
...
...
src/nas/mm/msg/DeregistrationRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef DEREGISTRATION_REQUEST_H_
#define DEREGISTRATION_REQUEST_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -7,7 +31,6 @@
#include "NASKeySetIdentifier.h"
#include "_5GSMobileIdentity.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DEREGISTRATION_REQUEST_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -28,15 +51,16 @@
_5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
0)
typedef
struct
deregistration_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
DeregistrationType
deregistrationtype
;
NASKeySetIdentifier
naskeysetidentifier
;
_5GSMobileIdentity
_5gsmobileidentity
;
}
deregistration_request_msg
;
typedef
struct
deregistration_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
DeregistrationType
deregistrationtype
;
NASKeySetIdentifier
naskeysetidentifier
;
_5GSMobileIdentity
_5gsmobileidentity
;
}
deregistration_request_msg
;
int
decode_deregistration_request
(
deregistration_request_msg
*
deregistrationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_deregistration_request
(
deregistration_request_msg
*
deregistrationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/IdentityRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,37 +27,32 @@
#include "TLVDecoder.h"
#include "IdentityRequest.h"
int
decode_identity_request
(
identity_request_msg
*
identity_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
IDENTITY_REQUEST_MINIMUM_LENGTH
,
len
);
int
decode_identity_request
(
identity_request_msg
*
identity_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode__5gs_identity_type
(
&
identity_request
->
_5gsidentitytype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
IDENTITY_REQUEST_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode__5gs_identity_type
(
&
identity_request
->
_5gsidentitytype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_identity_request
(
identity_request_msg
*
identity_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_identity_request
(
identity_request_msg
*
identity_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
IDENTITY_REQUEST_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gs_identity_type
(
identity_request
->
_5gsidentitytype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
IDENTITY_REQUEST_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gs_identity_type
(
identity_request
->
_5gsidentitytype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/IdentityRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef IDENTITY_REQUEST_H_
#define IDENTITY_REQUEST_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "_5GSIdentityType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define IDENTITY_REQUEST_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
_5GS_IDENTITY_TYPE_MAXIMUM_LENGTH + \
0)
typedef
struct
identity_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSIdentityType
_5gsidentitytype
;
}
identity_request_msg
;
typedef
struct
identity_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSIdentityType
_5gsidentitytype
;
}
identity_request_msg
;
int
decode_identity_request
(
identity_request_msg
*
identityrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_identity_request
(
identity_request_msg
*
identityrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/IdentityResponse.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,69 +27,62 @@
#include "TLVDecoder.h"
#include "IdentityResponse.h"
int
decode_identity_response
(
identity_response_msg
*
identity_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
int
decode_identity_response
(
identity_response_msg
*
identity_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
IDENTITY_RESPONSE_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
IDENTITY_RESPONSE_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
identity_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
identity_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
identity_response
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
identity_response
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
identity_response
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gs_mobile_identity
(
&
identity_response
->
_5gsmobileidentity
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
identity_response
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gs_mobile_identity
(
&
identity_response
->
_5gsmobileidentity
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_identity_response
(
identity_response_msg
*
identity_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_identity_response
(
identity_response_msg
*
identity_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
IDENTITY_RESPONSE_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
IDENTITY_RESPONSE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
identity_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
identity_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
identity_response
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
identity_response
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
identity_response
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gs_mobile_identity
(
identity_response
->
_5gsmobileidentity
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
identity_response
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gs_mobile_identity
(
identity_response
->
_5gsmobileidentity
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/IdentityResponse.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef IDENTITY_RESPONSE_H_
#define IDENTITY_RESPONSE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "_5GSMobileIdentity.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define IDENTITY_RESPONSE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
_5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
0)
typedef
struct
identity_response_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSMobileIdentity
_5gsmobileidentity
;
}
identity_response_msg
;
typedef
struct
identity_response_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSMobileIdentity
_5gsmobileidentity
;
}
identity_response_msg
;
int
decode_identity_response
(
identity_response_msg
*
identityresponse
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_identity_response
(
identity_response_msg
*
identityresponse
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/Notification.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,67 +27,62 @@
#include "TLVDecoder.h"
#include "Notification.h"
int
decode_notification
(
notification_msg
*
notification
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
NOTIFICATION_MINIMUM_LENGTH
,
len
);
int
decode_notification
(
notification_msg
*
notification
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
notification
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
NOTIFICATION_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_security_header_type
(
&
notification
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
notification
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
notification
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
notification
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__access_type
(
&
notification
->
_accesstype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
notification
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__access_type
(
&
notification
->
_accesstype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_notification
(
notification_msg
*
notification
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_notification
(
notification_msg
*
notification
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
NOTIFICATION_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
notification
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
NOTIFICATION_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_security_header_type
(
notification
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
notification
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
notification
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
notification
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__access_type
(
notification
->
_accesstype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
notification
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__access_type
(
notification
->
_accesstype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/Notification.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef NOTIFICATION_H_
#define NOTIFICATION_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "_AccessType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define NOTIFICATION_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
_ACCESS_TYPE_MAXIMUM_LENGTH + \
0)
typedef
struct
notification_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_AccessType
_accesstype
;
}
notification_msg
;
typedef
struct
notification_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_AccessType
_accesstype
;
}
notification_msg
;
int
decode_notification
(
notification_msg
*
notification
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_notification
(
notification_msg
*
notification
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/NotificationResponse.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,67 +27,62 @@
#include "TLVDecoder.h"
#include "NotificationResponse.h"
int
decode_notification_response
(
notification_response_msg
*
notification_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
NOTIFICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
int
decode_notification_response
(
notification_response_msg
*
notification_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
notification_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
NOTIFICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_security_header_type
(
&
notification_response
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
notification_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
notification_response
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
notification_response
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_status
(
&
notification_response
->
pdusessionstatus
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
notification_response
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_status
(
&
notification_response
->
pdusessionstatus
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_notification_response
(
notification_response_msg
*
notification_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_notification_response
(
notification_response_msg
*
notification_response
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
NOTIFICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
notification_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
NOTIFICATION_RESPONSE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_security_header_type
(
notification_response
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
notification_response
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
notification_response
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
notification_response
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_status
(
notification_response
->
pdusessionstatus
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
notification_response
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_status
(
notification_response
->
pdusessionstatus
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/NotificationResponse.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef NOTIFICATION_RESPONSE_H_
#define NOTIFICATION_RESPONSE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "PDUSessionStatus.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define NOTIFICATION_RESPONSE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
PDU_SESSION_STATUS_MAXIMUM_LENGTH + \
0)
typedef
struct
notification_response_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PDUSessionStatus
pdusessionstatus
;
}
notification_response_msg
;
typedef
struct
notification_response_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PDUSessionStatus
pdusessionstatus
;
}
notification_response_msg
;
int
decode_notification_response
(
notification_response_msg
*
notificationresponse
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_notification_response
(
notification_response_msg
*
notificationresponse
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/RegistrationAccept.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,58 +27,57 @@
#include "TLVDecoder.h"
#include "RegistrationAccept.h"
int
decode_registration_accept
(
registration_accept_msg
*
registration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
REGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode__5gs_registration_result
(
&
registration_accept
->
_5gsregistrationresult
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
/*
if((decoded_result = decode__5gs_mobile_identity (®istration_accept->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
while
(
len
-
decoded
>
0
){
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
//printf("ieiDecoded(%x)\n",ieiDecoded&0xf0);
if
(
ieiDecoded
==
0x0
)
break
;
switch
((
ieiDecoded
&
0xf0
)){
case
REGISTRATION_ACCEPT_MICO_INDICATION_IEI
:
if
((
decoded_result
=
decode_mico_indication
(
&
registration_accept
->
micoindication
,
REGISTRATION_ACCEPT_MICO_INDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
int
decode_registration_accept
(
registration_accept_msg
*
registration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
REGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode__5gs_registration_result
(
&
registration_accept
->
_5gsregistrationresult
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
/*
if((decoded_result = decode__5gs_mobile_identity (®istration_accept->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
//printf("ieiDecoded(%x)\n",ieiDecoded&0xf0);
if
(
ieiDecoded
==
0x0
)
break
;
switch
((
ieiDecoded
&
0xf0
))
{
case
REGISTRATION_ACCEPT_MICO_INDICATION_IEI
:
if
((
decoded_result
=
decode_mico_indication
(
&
registration_accept
->
micoindication
,
REGISTRATION_ACCEPT_MICO_INDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_MICO_INDICATION_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_IEI
:
if
((
decoded_result
=
decode_network_slicing_indication
(
&
registration_accept
->
networkslicingindication
,
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_IEI
:
if
((
decoded_result
=
decode_network_slicing_indication
(
&
registration_accept
->
networkslicingindication
,
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI
:
if
((
decoded_result
=
decode_nssai_inclusion_mode
(
&
registration_accept
->
nssaiinclusionmode
,
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT
;
}
case
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI
:
if
((
decoded_result
=
decode_nssai_inclusion_mode
(
&
registration_accept
->
nssaiinclusionmode
,
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT
;
}
break
;
}
#if 0
}
#if 0
switch((ieiDecoded&0xf0)>>4){
case REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI:
if((decoded_result = decode_nssai_inclusion_mode (®istration_accept->nssaiinclusionmode, REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI, buffer+decoded,len-decoded))<0)
...
...
@@ -66,370 +86,351 @@ int decode_registration_accept( registration_accept_msg *registration_accept, ui
decoded+=decoded_result;
registration_accept->presence |= REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT;
}
return decoded;
//0000000000000000000000000000000000000
return decoded;
break;
}
#endif
//printf("ieiDecoded(%x)\n",ieiDecoded);
switch
(
ieiDecoded
)
{
case
REGISTRATION_ACCEPT_PLMN_LIST_IEI
:
if
((
decoded_result
=
decode_plmn_list
(
registration_accept
->
plmnlist
,
REGISTRATION_ACCEPT_PLMN_LIST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
switch
(
ieiDecoded
)
{
case
REGISTRATION_ACCEPT_PLMN_LIST_IEI
:
if
((
decoded_result
=
decode_plmn_list
(
registration_accept
->
plmnlist
,
REGISTRATION_ACCEPT_PLMN_LIST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_PLMN_LIST_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_IEI
:
if
((
decoded_result
=
decode__5gs_tracking_area_identity_list
(
&
registration_accept
->
_5gstrackingareaidentitylist
,
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_IEI
:
if
((
decoded_result
=
decode__5gs_tracking_area_identity_list
(
&
registration_accept
->
_5gstrackingareaidentitylist
,
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_IEI
:
if
((
decoded_result
=
decode__5gs_network_feature_support
(
&
registration_accept
->
_5gsnetworkfeaturesupport
,
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_IEI
:
if
((
decoded_result
=
decode__5gs_network_feature_support
(
&
registration_accept
->
_5gsnetworkfeaturesupport
,
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_IEI
:
if
((
decoded_result
=
decode_pdu_session_status
(
&
registration_accept
->
pdusessionstatus
,
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_IEI
:
if
((
decoded_result
=
decode_pdu_session_status
(
&
registration_accept
->
pdusessionstatus
,
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_IEI
:
if
((
decoded_result
=
decode_pdu_session_reactivation_result
(
&
registration_accept
->
pdusessionreactivationresult
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_IEI
:
if
((
decoded_result
=
decode_pdu_session_reactivation_result
(
&
registration_accept
->
pdusessionreactivationresult
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_PRESENT
;
}
}
break
;
case
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_IEI
:
if
((
decoded_result
=
decode_pdu_session_reactivation_result_error_cause
(
&
registration_accept
->
pdusessionreactivationresulterrorcause
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_IEI
:
if
((
decoded_result
=
decode_pdu_session_reactivation_result_error_cause
(
&
registration_accept
->
pdusessionreactivationresulterrorcause
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_PRESENT
;
}
}
break
;
#if 0
#if 0
case REGISTRATION_ACCEPT_MICO_INDICATION_IEI:
if((decoded_result = decode_mico_indication (®istration_accept->micoindication, REGISTRATION_ACCEPT_MICO_INDICATION_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_accept->presence |= REGISTRATION_ACCEPT_MICO_INDICATION_PRESENT;
return decoded;
//0000000000000000000000000000000000000
return decoded;
}
break;
#endif
case
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_IEI
:
if
((
decoded_result
=
decode_service_area_list
(
&
registration_accept
->
servicearealist
,
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_IEI
:
if
((
decoded_result
=
decode_service_area_list
(
&
registration_accept
->
servicearealist
,
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_PRESENT
;
}
break
;
case
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer3
(
&
registration_accept
->
t3512
,
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer3
(
&
registration_accept
->
t3512
,
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_accept
->
non_3gpp_deregistration_timer
,
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_accept
->
non_3gpp_deregistration_timer
,
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_accept
->
t3502
,
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_accept
->
t3502
,
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_ACCEPT_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
registration_accept
->
eapmessage
,
REGISTRATION_ACCEPT_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
registration_accept
->
eapmessage
,
REGISTRATION_ACCEPT_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_EAP_MESSAGE_PRESENT
;
}
break
;
case
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI
:
if
((
decoded_result
=
decode__5gsdrx_parameters
(
&
registration_accept
->
_5gsdrxparameters
,
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
case
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI
:
if
((
decoded_result
=
decode__5gsdrx_parameters
(
&
registration_accept
->
_5gsdrxparameters
,
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_accept
->
presence
|=
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_PRESENT
;
}
//test need it ;while²»ÄÜÍ˳ö;????????????????????????????
//return decoded;
break
;
}
}
/*
if((decoded_result = decode_nssai (®istration_accept->nssai, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_rejected_nssai (®istration_accept->rejectednssai, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_ladn_information (®istration_accept->ladninformation, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
}
/*
if((decoded_result = decode_nssai (®istration_accept->nssai, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_rejected_nssai (®istration_accept->rejectednssai, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_ladn_information (®istration_accept->ladninformation, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_gprs_timer2 (®istration_accept->gprstimer2, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_emergency_number_list (®istration_accept->emergencynumberlist, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_extended_emergency_number_list (®istration_accept->extendedemergencynumberlist, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_sor_transparent_container (®istration_accept->sortransparentcontainer, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_eap_message (®istration_accept->eapmessage, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nssai_inclusion_mode (®istration_accept->nssaiinclusionmode, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_operator_defined_access_category_definitions (®istration_accept->operatordefinedaccesscategorydefinitions, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
}
if((decoded_result = decode_gprs_timer2 (®istration_accept->gprstimer2, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
int
encode_registration_accept
(
registration_accept_msg
*
registration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
printf
(
"registration_accept->presence(%x)
\n
"
,
registration_accept
->
presence
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gs_registration_result
(
registration_accept
->
_5gsregistrationresult
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
/*
if((encoded_result = encode__5gs_mobile_identity (registration_accept->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PLMN_LIST_PRESENT
)
==
REGISTRATION_ACCEPT_PLMN_LIST_PRESENT
)
{
if
((
encoded_result
=
encode_plmn_list
(
registration_accept
->
plmnlist
,
REGISTRATION_ACCEPT_PLMN_LIST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
encoded
+=
encoded_result
;
}
if((decoded_result = decode_emergency_number_list (®istration_accept->emergencynumberlist, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_PRESENT
)
==
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_PRESENT
)
{
if
((
encoded_result
=
encode__5gs_tracking_area_identity_list
(
registration_accept
->
_5gstrackingareaidentitylist
,
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
if((decoded_result = decode_extended_emergency_number_list (®istration_accept->extendedemergencynumberlist, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_nssai (registration_accept->nssai, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_rejected_nssai (registration_accept->rejectednssai, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_PRESENT
)
==
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_PRESENT
)
{
printf
(
"?????
\n
"
);
if
((
encoded_result
=
encode__5gs_network_feature_support
(
registration_accept
->
_5gsnetworkfeaturesupport
,
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
encoded
+=
encoded_result
;
}
if((decoded_result = decode_sor_transparent_container (®istration_accept->sortransparentcontainer, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_PRESENT
)
==
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_PRESENT
)
{
if
((
encoded_result
=
encode_pdu_session_status
(
registration_accept
->
pdusessionstatus
,
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
encoded
+=
encoded_result
;
}
if((decoded_result = decode_eap_message (®istration_accept->eapmessage, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_PRESENT
)
==
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_PRESENT
)
{
if
((
encoded_result
=
encode_pdu_session_reactivation_result
(
registration_accept
->
pdusessionreactivationresult
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
encoded
+=
encoded_result
;
}
if((decoded_result = decode_nssai_inclusion_mode (®istration_accept->nssaiinclusionmode, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_PRESENT
)
==
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_PRESENT
)
{
if
((
encoded_result
=
encode_pdu_session_reactivation_result_error_cause
(
registration_accept
->
pdusessionreactivationresulterrorcause
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
if((decoded_result = decode_operator_defined_access_category_definitions (®istration_accept->operatordefinedaccesscategorydefinitions, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_ladn_information (registration_accept->ladninformation, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_MICO_INDICATION_PRESENT
)
==
REGISTRATION_ACCEPT_MICO_INDICATION_PRESENT
)
{
if
((
encoded_result
=
encode_mico_indication
(
registration_accept
->
micoindication
,
REGISTRATION_ACCEPT_MICO_INDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
decoded+=decoded_result;
*/
return
decoded
;
}
encoded
+=
encoded_result
;
}
int
encode_registration_accept
(
registration_accept_msg
*
registration_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
printf
(
"registration_accept->presence(%x)
\n
"
,
registration_accept
->
presence
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gs_registration_result
(
registration_accept
->
_5gsregistrationresult
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
/*
if((encoded_result = encode__5gs_mobile_identity (registration_accept->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_PRESENT
)
==
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_PRESENT
)
{
if
((
encoded_result
=
encode_network_slicing_indication
(
registration_accept
->
networkslicingindication
,
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PLMN_LIST_PRESENT
)
==
REGISTRATION_ACCEPT_PLMN_LIST_PRESENT
){
if
((
encoded_result
=
encode_plmn_list
(
registration_accept
->
plmnlist
,
REGISTRATION_ACCEPT_PLMN_LIST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_PRESENT
)
==
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_PRESENT
){
if
((
encoded_result
=
encode__5gs_tracking_area_identity_list
(
registration_accept
->
_5gstrackingareaidentitylist
,
REGISTRATION_ACCEPT_5GS_TRACKING_AREA_IDENTITY_LIST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
/*
encoded
+=
encoded_result
;
}
if((encoded_result = encode_nssai (registration_accept->nssai, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_PRESENT
)
==
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_PRESENT
)
{
if
((
encoded_result
=
encode_service_area_list
(
registration_accept
->
servicearealist
,
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
if((encoded_result = encode_rejected_nssai (registration_accept->rejectednssai, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_PRESENT
)
==
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_PRESENT
)
{
if
((
encoded_result
=
encode_gprs_timer3
(
registration_accept
->
t3512
,
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_PRESENT
)
==
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_PRESENT
){
printf
(
"?????
\n
"
);
if
((
encoded_result
=
encode__5gs_network_feature_support
(
registration_accept
->
_5gsnetworkfeaturesupport
,
REGISTRATION_ACCEPT_5GS_NETWORK_FEATURE_SUPPORT_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_PRESENT
)
==
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_PRESENT
){
if
((
encoded_result
=
encode_pdu_session_status
(
registration_accept
->
pdusessionstatus
,
REGISTRATION_ACCEPT_PDU_SESSION_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_PRESENT
)
==
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_PRESENT
){
if
((
encoded_result
=
encode_pdu_session_reactivation_result
(
registration_accept
->
pdusessionreactivationresult
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_PRESENT
)
==
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_PRESENT
){
if
((
encoded_result
=
encode_pdu_session_reactivation_result_error_cause
(
registration_accept
->
pdusessionreactivationresulterrorcause
,
REGISTRATION_ACCEPT_PDU_SESSION_REACTIVATION_RESULT_ERROR_CAUSE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_ladn_information (registration_accept->ladninformation, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_PRESENT
)
==
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_PRESENT
)
{
if
((
encoded_result
=
encode_gprs_timer2
(
registration_accept
->
non_3gpp_deregistration_timer
,
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_MICO_INDICATION_PRESENT
)
==
REGISTRATION_ACCEPT_MICO_INDICATION_PRESENT
){
if
((
encoded_result
=
encode_mico_indication
(
registration_accept
->
micoindication
,
REGISTRATION_ACCEPT_MICO_INDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_PRESENT
)
==
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_PRESENT
){
if
((
encoded_result
=
encode_network_slicing_indication
(
registration_accept
->
networkslicingindication
,
REGISTRATION_ACCEPT_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_PRESENT
)
==
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_PRESENT
){
if
((
encoded_result
=
encode_service_area_list
(
registration_accept
->
servicearealist
,
REGISTRATION_ACCEPT_SERVICE_AREA_LIST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_PRESENT
)
==
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_PRESENT
){
if
((
encoded_result
=
encode_gprs_timer3
(
registration_accept
->
t3512
,
REGISTRATION_ACCEPT_GPRS_TIMER3_T3512_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_PRESENT
)
==
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_PRESENT
){
if
((
encoded_result
=
encode_gprs_timer2
(
registration_accept
->
non_3gpp_deregistration_timer
,
REGISTRATION_ACCEPT_GPRS_TIMER2_NON_3GPP_DEREGISTRATION_TIMER_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_PRESENT
)
==
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_PRESENT
){
if
((
encoded_result
=
encode_gprs_timer2
(
registration_accept
->
t3502
,
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_emergency_number_list (registration_accept->emergencynumberlist, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_PRESENT
)
==
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_PRESENT
)
{
if
((
encoded_result
=
encode_gprs_timer2
(
registration_accept
->
t3502
,
REGISTRATION_ACCEPT_GPRS_TIMER2_T3502_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
if((encoded_result = encode_extended_emergency_number_list (registration_accept->extendedemergencynumberlist, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_emergency_number_list (registration_accept->emergencynumberlist, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_extended_emergency_number_list (registration_accept->extendedemergencynumberlist, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_sor_transparent_container (registration_accept->sortransparentcontainer, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_EAP_MESSAGE_PRESENT
)
==
REGISTRATION_ACCEPT_EAP_MESSAGE_PRESENT
)
{
if
((
encoded_result
=
encode_eap_message
(
registration_accept
->
eapmessage
,
REGISTRATION_ACCEPT_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
encoded
+=
encoded_result
;
}
if((encoded_result = encode_sor_transparent_container (registration_accept->sortransparentcontainer, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT
)
==
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT
)
{
if
((
encoded_result
=
encode_nssai_inclusion_mode
(
registration_accept
->
nssaiinclusionmode
,
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_EAP_MESSAGE_PRESENT
)
==
REGISTRATION_ACCEPT_EAP_MESSAGE_PRESENT
){
if
((
encoded_result
=
encode_eap_message
(
registration_accept
->
eapmessage
,
REGISTRATION_ACCEPT_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT
)
==
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_PRESENT
){
if
((
encoded_result
=
encode_nssai_inclusion_mode
(
registration_accept
->
nssaiinclusionmode
,
REGISTRATION_ACCEPT_NSSAI_INCLUSION_MODE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_operator_defined_access_category_definitions (registration_accept->operatordefinedaccesscategorydefinitions, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_operator_defined_access_category_definitions (registration_accept->operatordefinedaccesscategorydefinitions, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_PRESENT
)
==
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_PRESENT
)
{
if
((
encoded_result
=
encode__5gsdrx_parameters
(
registration_accept
->
_5gsdrxparameters
,
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
if
((
registration_accept
->
presence
&
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_PRESENT
)
==
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_PRESENT
){
if
((
encoded_result
=
encode__5gsdrx_parameters
(
registration_accept
->
_5gsdrxparameters
,
REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
return
encoded
;
encoded
+=
encoded_result
;
}
return
encoded
;
}
src/nas/mm/msg/RegistrationAccept.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef REGISTRATION_ACCEPT_H_
#define REGISTRATION_ACCEPT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -27,7 +51,6 @@
#include "OperatorDefinedAccessCategoryDefinitions.h"
#include "_5GSDRXParameters.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define REGISTRATION_ACCEPT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -88,7 +111,6 @@
_5GSDRX_PARAMETERS_MAXIMUM_LENGTH + \
0)
#define REGISTRATION_ACCEPT_5GS_MOBILE_IDENTITY_IEI 0x77
#define REGISTRATION_ACCEPT_5GS_MOBILE_IDENTITY_PRESENT (uint32_t)(1<<0)
...
...
@@ -161,40 +183,40 @@
#define REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_IEI 0x51
#define REGISTRATION_ACCEPT_5GS_DRX_PARAMETERS_PRESENT (uint32_t)(1<<23)
typedef
struct
registration_accept_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSRegistrationResult
_5gsregistrationresult
;
uint32_t
presence
;
//_5GSMobileIdentity _5gsmobileidentity;
PLMNList
plmnlist
;
_5GSTrackingAreaIdentityList
_5gstrackingareaidentitylist
;
//NSSAI allowednssai;
//RejectedNSSAI rejectednssai;
//NSSAI configurednssai;
_5GSNetworkFeatureSupport
_5gsnetworkfeaturesupport
;
PDUSessionStatus
pdusessionstatus
;
PDUSessionReactivationResult
pdusessionreactivationresult
;
PDUSessionReactivationResultErrorCause
pdusessionreactivationresulterrorcause
;
//LADNInformation ladninformation;
MICOIndication
micoindication
;
NetworkSlicingIndication
networkslicingindication
;
ServiceAreaList
servicearealist
;
GPRSTimer3
t3512
;
GPRSTimer2
non_3gpp_deregistration_timer
;
GPRSTimer2
t3502
;
//EmergencyNumberList emergencynumberlist;
//ExtendedEmergencyNumberList extendedemergencynumberlist;
//SORTransparentContainer sortransparentcontainer;
EAPMessage
eapmessage
;
NSSAIInclusionMode
nssaiinclusionmode
;
//OperatorDefinedAccessCategoryDefinitions operatordefinedaccesscategorydefinitions;
_5GSDRXParameters
_5gsdrxparameters
;
//Non_3GPP_NW_Provided_Policies non_3gpp_nw_policies;
}
registration_accept_msg
;
typedef
struct
registration_accept_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSRegistrationResult
_5gsregistrationresult
;
uint32_t
presence
;
//_5GSMobileIdentity _5gsmobileidentity;
PLMNList
plmnlist
;
_5GSTrackingAreaIdentityList
_5gstrackingareaidentitylist
;
//NSSAI allowednssai;
//RejectedNSSAI rejectednssai;
//NSSAI configurednssai;
_5GSNetworkFeatureSupport
_5gsnetworkfeaturesupport
;
PDUSessionStatus
pdusessionstatus
;
PDUSessionReactivationResult
pdusessionreactivationresult
;
PDUSessionReactivationResultErrorCause
pdusessionreactivationresulterrorcause
;
//LADNInformation ladninformation;
MICOIndication
micoindication
;
NetworkSlicingIndication
networkslicingindication
;
ServiceAreaList
servicearealist
;
GPRSTimer3
t3512
;
GPRSTimer2
non_3gpp_deregistration_timer
;
GPRSTimer2
t3502
;
//EmergencyNumberList emergencynumberlist;
//ExtendedEmergencyNumberList extendedemergencynumberlist;
//SORTransparentContainer sortransparentcontainer;
EAPMessage
eapmessage
;
NSSAIInclusionMode
nssaiinclusionmode
;
//OperatorDefinedAccessCategoryDefinitions operatordefinedaccesscategorydefinitions;
_5GSDRXParameters
_5gsdrxparameters
;
//Non_3GPP_NW_Provided_Policies non_3gpp_nw_policies;
}
registration_accept_msg
;
int
decode_registration_accept
(
registration_accept_msg
*
registrationaccept
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_registration_accept
(
registration_accept_msg
*
registrationaccept
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/RegistrationComplete.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,67 +27,62 @@
#include "TLVDecoder.h"
#include "RegistrationComplete.h"
int
decode_registration_complete
(
registration_complete_msg
*
registration_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
REGISTRATION_COMPLETE_MINIMUM_LENGTH
,
len
);
int
decode_registration_complete
(
registration_complete_msg
*
registration_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
registration_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
REGISTRATION_COMPLETE_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_security_header_type
(
&
registration_complete
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
registration_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
registration_complete
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
registration_complete
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_sor_transparent_container
(
&
registration_complete
->
sortransparentcontainer
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
registration_complete
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_sor_transparent_container
(
&
registration_complete
->
sortransparentcontainer
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_registration_complete
(
registration_complete_msg
*
registration_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_registration_complete
(
registration_complete_msg
*
registration_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_COMPLETE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
registration_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_COMPLETE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_security_header_type
(
registration_complete
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
registration_complete
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
registration_complete
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
registration_complete
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_sor_transparent_container
(
registration_complete
->
sortransparentcontainer
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
registration_complete
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_sor_transparent_container
(
registration_complete
->
sortransparentcontainer
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/RegistrationComplete.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef REGISTRATION_COMPLETE_H_
#define REGISTRATION_COMPLETE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "SORTransparentContainer.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define REGISTRATION_COMPLETE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
SOR_TRANSPARENT_CONTAINER_MAXIMUM_LENGTH + \
0)
typedef
struct
registration_complete_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
SORTransparentContainer
sortransparentcontainer
;
}
registration_complete_msg
;
typedef
struct
registration_complete_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
SORTransparentContainer
sortransparentcontainer
;
}
registration_complete_msg
;
int
decode_registration_complete
(
registration_complete_msg
*
registrationcomplete
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_registration_complete
(
registration_complete_msg
*
registrationcomplete
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/RegistrationReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,92 +27,85 @@
#include "TLVDecoder.h"
#include "RegistrationReject.h"
int
decode_registration_reject
(
registration_reject_msg
*
registration_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
decode_registration_reject
(
registration_reject_msg
*
registration_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
REGISTRATION_REJECT_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
REGISTRATION_REJECT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode__5gmm_cause
(
&
registration_reject
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode__5gmm_cause
(
&
registration_reject
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
decoded
+=
decoded_result
;
while
(
len
-
decoded
>
0
){
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
((
ieiDecoded
!=
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
)
&&
(
ieiDecoded
!=
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
)
&&
(
ieiDecoded
!=
REGISTRATION_REJECT_EAP_MESSAGE_IEI
))
break
;
switch
(
ieiDecoded
){
case
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_reject
->
t3346
,
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_reject
->
presence
|=
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_reject
->
t3502
,
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_reject
->
presence
|=
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_REJECT_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
registration_reject
->
eapmessage
,
REGISTRATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_reject
->
presence
|=
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT
;
}
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
((
ieiDecoded
!=
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
)
&&
(
ieiDecoded
!=
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
)
&&
(
ieiDecoded
!=
REGISTRATION_REJECT_EAP_MESSAGE_IEI
))
break
;
switch
(
ieiDecoded
)
{
case
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_reject
->
t3346
,
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_reject
->
presence
|=
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
:
if
((
decoded_result
=
decode_gprs_timer2
(
&
registration_reject
->
t3502
,
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_reject
->
presence
|=
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT
;
}
break
;
case
REGISTRATION_REJECT_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
registration_reject
->
eapmessage
,
REGISTRATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_reject
->
presence
|=
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT
;
}
break
;
}
}
return
decoded
;
}
int
encode_registration_reject
(
registration_reject_msg
*
registration_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_registration_reject
(
registration_reject_msg
*
registration_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_REJECT_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_REJECT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gmm_cause
(
registration_reject
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode__5gmm_cause
(
registration_reject
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
if
((
registration_reject
->
presence
&
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
)
==
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
){
if
((
encoded_result
=
encode_gprs_timer2
(
registration_reject
->
t3346
,
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_reject
->
presence
&
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
)
==
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
)
{
if
((
encoded_result
=
encode_gprs_timer2
(
registration_reject
->
t3346
,
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_reject
->
presence
&
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT
)
==
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT
){
if
((
encoded_result
=
encode_gprs_timer2
(
registration_reject
->
t3502
,
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_reject
->
presence
&
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT
)
==
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT
)
{
if
((
encoded_result
=
encode_gprs_timer2
(
registration_reject
->
t3502
,
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_reject
->
presence
&
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT
)
==
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT
){
if
((
encoded_result
=
encode_eap_message
(
registration_reject
->
eapmessage
,
REGISTRATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_reject
->
presence
&
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT
)
==
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT
)
{
if
((
encoded_result
=
encode_eap_message
(
registration_reject
->
eapmessage
,
REGISTRATION_REJECT_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
return
encoded
;
}
src/nas/mm/msg/RegistrationReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef REGISTRATION_REJECT_H_
#define REGISTRATION_REJECT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -7,7 +31,6 @@
#include "GPRSTimer2.h"
#include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define REGISTRATION_REJECT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -37,18 +60,19 @@
#define REGISTRATION_REJECT_EAP_MESSAGE_IEI 0x78
#define REGISTRATION_REJECT_EAP_MESSAGE_PRESENT (1<<2)
typedef
struct
registration_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
uint8_t
presence
;
GPRSTimer2
t3346
;
GPRSTimer2
t3502
;
EAPMessage
eapmessage
;
}
registration_reject_msg
;
typedef
struct
registration_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
uint8_t
presence
;
GPRSTimer2
t3346
;
GPRSTimer2
t3502
;
EAPMessage
eapmessage
;
}
registration_reject_msg
;
int
decode_registration_reject
(
registration_reject_msg
*
registrationreject
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_registration_reject
(
registration_reject_msg
*
registrationreject
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/RegistrationRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,8 +27,7 @@
#include "TLVDecoder.h"
#include "RegistrationRequest.h"
int
decode_registration_request
(
registration_request_msg
*
registration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
decode_registration_request
(
registration_request_msg
*
registration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
printf
(
"decode_registration_request len:%d
\n
"
,
len
);
...
...
@@ -15,442 +35,420 @@ int decode_registration_request( registration_request_msg *registration_request,
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
//CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, REGISTRATION_REQUEST_MINIMUM_LENGTH, len);
if
((
decoded_result
=
decode__5gs_registration_type
(
&
registration_request
->
_5gsregistrationtype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode__5gs_registration_type
(
&
registration_request
->
_5gsregistrationtype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_u8_nas_key_set_identifier
(
&
registration_request
->
naskeysetidentifier
,
0
,
*
(
buffer
+
decoded
)
>>
4
,
len
-
decoded
))
<
0
)
if
((
decoded_result
=
decode_u8_nas_key_set_identifier
(
&
registration_request
->
naskeysetidentifier
,
0
,
*
(
buffer
+
decoded
)
>>
4
,
len
-
decoded
))
<
0
)
return
decoded_result
;
decoded
++
;
return
decoded
;
/*
if ((decoded_result = decode__5gs_mobile_identity (®istration_request->_5gsmobileidentity, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode__5gs_mobile_identity (®istration_request->_5gsmobileidentity, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
decoded++;
*/
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
ieiDecoded
==
0
)
break
;
switch
(
ieiDecoded
&
0xf0
)
{
case
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI
:
if
((
decoded_result
=
decode_nas_key_set_identifier
(
&
registration_request
->
non_current_native_nas_key_set_identifier
,
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_MICO_IDICATION_IEI
:
if
((
decoded_result
=
decode_mico_indication
(
&
registration_request
->
micoindication
,
REGISTRATION_REQUEST_MICO_IDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_MICO_IDICATION_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI
:
if
((
decoded_result
=
decode_payload_container_type
(
&
registration_request
->
payloadcontainertype
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI
:
if
((
decoded_result
=
decode_network_slicing_indication
(
&
registration_request
->
networkslicingindication
,
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT
;
}
break
;
switch
(
ieiDecoded
&
0xf0
)
{
case
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI
:
if
((
decoded_result
=
decode_nas_key_set_identifier
(
&
registration_request
->
non_current_native_nas_key_set_identifier
,
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_MICO_IDICATION_IEI
:
if
((
decoded_result
=
decode_mico_indication
(
&
registration_request
->
micoindication
,
REGISTRATION_REQUEST_MICO_IDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_MICO_IDICATION_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI
:
if
((
decoded_result
=
decode_payload_container_type
(
&
registration_request
->
payloadcontainertype
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI
:
if
((
decoded_result
=
decode_network_slicing_indication
(
&
registration_request
->
networkslicingindication
,
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT
;
}
break
;
}
switch
(
ieiDecoded
)
{
/*
case REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI:
if((decoded_result = decode_nas_key_set_identifier(®istration_request->non_current_native_nas_key_set_identifier,REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI,buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT;
}
break;
*/
case
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
:
if
((
decoded_result
=
decode__5gmm_capability
(
&
registration_request
->
_5gmmcapability
,
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
:
if
((
decoded_result
=
decode_ue_security_capability
(
&
registration_request
->
uesecuritycapability
,
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_IEI
:
if
((
decoded_result
=
decode__5gs_tracking_area_identity
(
&
registration_request
->
_5gstrackingareaidentity
,
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI
:
if
((
decoded_result
=
decode_s1_ue_network_capability
(
&
registration_request
->
s1uenetworkcapability
,
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI
:
if
((
decoded_result
=
decode_uplink_data_status
(
&
registration_request
->
uplinkdatastatus
,
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI
:
if
((
decoded_result
=
decode_pdu_session_status
(
&
registration_request
->
pdusessionstatus
,
REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT
;
}
break
;
switch
(
ieiDecoded
)
{
/*
case REGISTRATION_REQUEST_MICO_IDICATION
_IEI:
if((decoded_result = decode_mico_indication (®istration_request->micoindication, REGISTRATION_REQUEST_MICO_IDICATION_IEI,
buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_MICO_IDICATION
_PRESENT;
}
break;
case REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER
_IEI:
if((decoded_result = decode_nas_key_set_identifier(®istration_request->non_current_native_nas_key_set_identifier,REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI,
buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER
_PRESENT;
}
break;
*/
case
REGISTRATION_REQUEST_UE_STATUS_IEI
:
if
((
decoded_result
=
decode_ue_status
(
&
registration_request
->
uestatus
,
REGISTRATION_REQUEST_UE_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UE_STATUS_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI
:
if
((
decoded_result
=
decode_allowed_pdu_session_status
(
&
registration_request
->
allowedpdusessionstatus
,
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI
:
if
((
decoded_result
=
decode_ues_usage_setting
(
&
registration_request
->
uesusagesetting
,
REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_IEI
:
if
((
decoded_result
=
decode__5gsdrx_parameters
(
&
registration_request
->
_5gsdrxparameters
,
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_PRESENT
;
}
case
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
:
if
((
decoded_result
=
decode__5gmm_capability
(
&
registration_request
->
_5gmmcapability
,
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
:
if
((
decoded_result
=
decode_ue_security_capability
(
&
registration_request
->
uesecuritycapability
,
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_IEI
:
if
((
decoded_result
=
decode__5gs_tracking_area_identity
(
&
registration_request
->
_5gstrackingareaidentity
,
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI
:
if
((
decoded_result
=
decode_s1_ue_network_capability
(
&
registration_request
->
s1uenetworkcapability
,
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI
:
if
((
decoded_result
=
decode_uplink_data_status
(
&
registration_request
->
uplinkdatastatus
,
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI
:
if
((
decoded_result
=
decode_pdu_session_status
(
&
registration_request
->
pdusessionstatus
,
REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT
;
}
break
;
/*
case REGISTRATION_REQUEST_MICO_IDICATION_IEI:
if((decoded_result = decode_mico_indication (®istration_request->micoindication, REGISTRATION_REQUEST_MICO_IDICATION_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_MICO_IDICATION_PRESENT;
}
break;
*/
case
REGISTRATION_REQUEST_UE_STATUS_IEI
:
if
((
decoded_result
=
decode_ue_status
(
&
registration_request
->
uestatus
,
REGISTRATION_REQUEST_UE_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UE_STATUS_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI
:
if
((
decoded_result
=
decode_allowed_pdu_session_status
(
&
registration_request
->
allowedpdusessionstatus
,
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI
:
if
((
decoded_result
=
decode_epsnas_message_container
(
&
registration_request
->
epsnasmessagecontainer
,
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT
;
}
break
;
/*
case REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI:
if((decoded_result = decode_payload_container_type (®istration_request->payloadcontainer, REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT;
}
break
;
*/
case
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI
:
if
((
decoded_result
=
decode_payload_container
(
&
registration_request
->
payloadcontainer
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT
;
}
case
REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI
:
if
((
decoded_result
=
decode_ues_usage_setting
(
&
registration_request
->
uesusagesetting
,
REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_IEI
:
if
((
decoded_result
=
decode__5gsdrx_parameters
(
&
registration_request
->
_5gsdrxparameters
,
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_PRESENT
;
}
break
;
/*
case REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI:
if((decoded_result = decode_network_slicing_indication (®istration_request->networkslicingindication, REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT;
}
break
;
*/
case
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI
:
if
((
decoded_result
=
decode__5gs_update_type
(
&
registration_request
->
_5gsupdatetype
,
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT
;
}
break
;
case
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI
:
if
((
decoded_result
=
decode_nas_message_container
(
&
registration_request
->
nasmessagecontainer
,
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT
;
}
printf
(
"nasmessagecontainer:0x%x
\n
"
,
*
(
unsigned
char
*
)((
registration_request
->
nasmessagecontainer
)
->
data
));
break
;
/*
case REGISTRATION_REQUEST_NSSAI_IEI:
if((decoded_result = decode_nssai(®istration_request->nssai, REGISTRATION_REQUEST_NSSAI_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_NSSAI_PRESENT;
}
case
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI
:
if
((
decoded_result
=
decode_epsnas_message_container
(
&
registration_request
->
epsnasmessagecontainer
,
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT
;
}
break
;
/*
case REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI:
if((decoded_result = decode_payload_container_type (®istration_request->payloadcontainer, REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT;
}
break;
*/
case
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI
:
if
((
decoded_result
=
decode_payload_container
(
&
registration_request
->
payloadcontainer
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT
;
}
break
;
case REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_IEI:
if((decoded_result = decode__5gs_mobile_identity(®istration_request->AdditionalGUTI, REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_PRESENT;
}
/*
case REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI:
if((decoded_result = decode_network_slicing_indication (®istration_request->networkslicingindication, REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT;
}
break;
*/
case
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI
:
if
((
decoded_result
=
decode__5gs_update_type
(
&
registration_request
->
_5gsupdatetype
,
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT
;
}
break
;
case REGISTRATION_REQUEST_LADN_INDICATION_IEI:
if((decoded_result = decode_ladn_indication(®istration_request->ladnindication, REGISTRATION_REQUEST_LADN_INDICATION_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_LADN_INDICATION_PRESENT;
}
case
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI
:
if
((
decoded_result
=
decode_nas_message_container
(
&
registration_request
->
nasmessagecontainer
,
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
registration_request
->
presence
|=
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT
;
}
break
;
*/
/*
case REGISTRATION_REQUEST_NSSAI_IEI:
if((decoded_result = decode_nssai(®istration_request->nssai, REGISTRATION_REQUEST_NSSAI_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_NSSAI_PRESENT;
}
break;
case REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_IEI:
if((decoded_result = decode__5gs_mobile_identity(®istration_request->AdditionalGUTI, REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_PRESENT;
}
break;
case REGISTRATION_REQUEST_LADN_INDICATION_IEI:
if((decoded_result = decode_ladn_indication(®istration_request->ladnindication, REGISTRATION_REQUEST_LADN_INDICATION_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_request->presence |= REGISTRATION_REQUEST_LADN_INDICATION_PRESENT;
}
break;
*/
}
}
return
decoded
;
}
int
encode_registration_request
(
registration_request_msg
*
registration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
encode_registration_request
(
registration_request_msg
*
registration_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_REQUEST_MINIMUM_LENGTH
,
len
);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
REGISTRATION_REQUEST_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gs_registration_type
(
&
registration_request
->
_5gsregistrationtype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
encoded_result
=
encode__5gs_registration_type
(
&
registration_request
->
_5gsregistrationtype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
*
(
buffer
+
encoded
)
=
((
encode_u8_nas_key_set_identifier
(
&
registration_request
->
naskeysetidentifier
)
&
0x0f
)
<<
4
)
|
0x00
;
encoded
++
;
encoded
++
;
//encode mobile identity
/*
if((encoded_result = encode__5gs_mobile_identity(®istration_request->_5gsmobileidentity,0,buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode__5gs_mobile_identity(®istration_request->_5gsmobileidentity,0,buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT
)
==
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT
){
if
((
encoded_result
=
encode_nas_key_set_identifier
(
&
registration_request
->
non_current_native_nas_key_set_identifier
,
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT
)
==
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_PRESENT
)
{
if
((
encoded_result
=
encode_nas_key_set_identifier
(
&
registration_request
->
non_current_native_nas_key_set_identifier
,
REGISTRATION_REQUEST_NAS_KEY_SET_IDENTIFIER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
){
if
((
encoded_result
=
encode__5gmm_capability
(
registration_request
->
_5gmmcapability
,
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT
)
{
if
((
encoded_result
=
encode__5gmm_capability
(
registration_request
->
_5gmmcapability
,
REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
){
if
((
encoded_result
=
encode_ue_security_capability
(
registration_request
->
uesecuritycapability
,
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT
)
{
if
((
encoded_result
=
encode_ue_security_capability
(
registration_request
->
uesecuritycapability
,
REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
//encode nssai
/*
if(registration_request->presence & REGISTRATION_REQUEST_NSSAI_PRESENT
== REGISTRATION_REQUEST_NSSAI_PRESENT){
if((encoded_result = encode_nssai (registration_request->nssai, REGISTRATION_REQUEST_NSSAI_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
if(registration_request->presence & REGISTRATION_REQUEST_NSSAI_PRESENT
== REGISTRATION_REQUEST_NSSAI_PRESENT){
if((encoded_result = encode_nssai (registration_request->nssai, REGISTRATION_REQUEST_NSSAI_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
*/
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_PRESENT
)
==
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_PRESENT
){
if
((
encoded_result
=
encode__5gs_tracking_area_identity
(
registration_request
->
_5gstrackingareaidentity
,
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_PRESENT
)
==
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_PRESENT
)
{
if
((
encoded_result
=
encode__5gs_tracking_area_identity
(
registration_request
->
_5gstrackingareaidentity
,
REGISTRATION_REQUEST_5GS_TRACKING_AREA_IDENTITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT
){
if
((
encoded_result
=
encode_s1_ue_network_capability
(
registration_request
->
s1uenetworkcapability
,
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT
)
==
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT
)
{
if
((
encoded_result
=
encode_s1_ue_network_capability
(
registration_request
->
s1uenetworkcapability
,
REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT
){
if
((
encoded_result
=
encode_uplink_data_status
(
registration_request
->
uplinkdatastatus
,
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT
)
{
if
((
encoded_result
=
encode_uplink_data_status
(
registration_request
->
uplinkdatastatus
,
REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT
){
if
((
encoded_result
=
encode_pdu_session_status
(
registration_request
->
pdusessionstatus
,
REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT
)
{
if
((
encoded_result
=
encode_pdu_session_status
(
registration_request
->
pdusessionstatus
,
REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_MICO_IDICATION_PRESENT
)
==
REGISTRATION_REQUEST_MICO_IDICATION_PRESENT
){
if
((
encoded_result
=
encode_mico_indication
(
registration_request
->
micoindication
,
REGISTRATION_REQUEST_MICO_IDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_MICO_IDICATION_PRESENT
)
==
REGISTRATION_REQUEST_MICO_IDICATION_PRESENT
)
{
if
((
encoded_result
=
encode_mico_indication
(
registration_request
->
micoindication
,
REGISTRATION_REQUEST_MICO_IDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UE_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_UE_STATUS_PRESENT
){
if
((
encoded_result
=
encode_ue_status
(
registration_request
->
uestatus
,
REGISTRATION_REQUEST_UE_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UE_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_UE_STATUS_PRESENT
)
{
if
((
encoded_result
=
encode_ue_status
(
registration_request
->
uestatus
,
REGISTRATION_REQUEST_UE_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
//encode
/*
if(registration_request->presence & REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_PRESENT
== REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_PRESENT){
if((encoded_result = encode__5gs_mobile_identity (registration_request->AdditionalGUTI, REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
if(registration_request->presence & REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_PRESENT
== REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_PRESENT){
if((encoded_result = encode__5gs_mobile_identity (registration_request->AdditionalGUTI, REGISTRATION_REQUEST_5GS_MOBILE_IDENTITY_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
*/
//test
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
){
if
((
encoded_result
=
encode_allowed_pdu_session_status
(
registration_request
->
allowedpdusessionstatus
,
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
)
==
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT
)
{
if
((
encoded_result
=
encode_allowed_pdu_session_status
(
registration_request
->
allowedpdusessionstatus
,
REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
//test
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT
)
==
REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT
){
if
((
encoded_result
=
encode_ues_usage_setting
(
registration_request
->
uesusagesetting
,
REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT
)
==
REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT
)
{
if
((
encoded_result
=
encode_ues_usage_setting
(
registration_request
->
uesusagesetting
,
REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
//test
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_PRESENT
)
==
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_PRESENT
){
if
((
encoded_result
=
encode__5gsdrx_parameters
(
registration_request
->
_5gsdrxparameters
,
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_PRESENT
)
==
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_PRESENT
)
{
if
((
encoded_result
=
encode__5gsdrx_parameters
(
registration_request
->
_5gsdrxparameters
,
REGISTRATION_REQUEST_5GS_DRX_PARAMETERS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT
)
==
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT
){
if
((
encoded_result
=
encode_epsnas_message_container
(
registration_request
->
epsnasmessagecontainer
,
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT
)
==
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT
)
{
if
((
encoded_result
=
encode_epsnas_message_container
(
registration_request
->
epsnasmessagecontainer
,
REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
/*
if(registration_request->presence & REGISTRATION_REQUEST_LADN_INDICATION_PRESENT
== REGISTRATION_REQUEST_LADN_INDICATION_PRESENT){
if((encoded_result = encode_ladn_indication(registration_request->ladnindication, REGISTRATION_REQUEST_LADN_INDICATION_PRESENT, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
if(registration_request->presence & REGISTRATION_REQUEST_LADN_INDICATION_PRESENT
== REGISTRATION_REQUEST_LADN_INDICATION_PRESENT){
if((encoded_result = encode_ladn_indication(registration_request->ladnindication, REGISTRATION_REQUEST_LADN_INDICATION_PRESENT, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
*/
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT
)
==
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT
){
if
((
encoded_result
=
encode_payload_container_type
(
registration_request
->
payloadcontainertype
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT
)
==
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT
)
{
if
((
encoded_result
=
encode_payload_container_type
(
registration_request
->
payloadcontainertype
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT
)
==
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT
){
if
((
encoded_result
=
encode_payload_container
(
registration_request
->
payloadcontainer
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT
)
==
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT
)
{
if
((
encoded_result
=
encode_payload_container
(
registration_request
->
payloadcontainer
,
REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT
)
==
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT
){
if
((
encoded_result
=
encode_network_slicing_indication
(
registration_request
->
networkslicingindication
,
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT
)
==
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT
)
{
if
((
encoded_result
=
encode_network_slicing_indication
(
registration_request
->
networkslicingindication
,
REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT
)
==
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT
){
if
((
encoded_result
=
encode__5gs_update_type
(
registration_request
->
_5gsupdatetype
,
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT
)
==
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT
)
{
if
((
encoded_result
=
encode__5gs_update_type
(
registration_request
->
_5gsupdatetype
,
REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT
)
==
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT
){
if
((
encoded_result
=
encode_nas_message_container
(
registration_request
->
nasmessagecontainer
,
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
if
((
registration_request
->
presence
&
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT
)
==
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT
)
{
if
((
encoded_result
=
encode_nas_message_container
(
registration_request
->
nasmessagecontainer
,
REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
encoded
+=
encoded_result
;
}
return
encoded
;
...
...
src/nas/mm/msg/RegistrationRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef REGISTRATION_REQUEST_H_
#define REGISTRATION_REQUEST_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -26,7 +50,6 @@
#include "_5GSUpdateType.h"
#include "NASMessageContainer.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define REGISTRATION_REQUEST_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -127,37 +150,38 @@
#define REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT (1<<20)
#define REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT (1<<21)
typedef
struct
registration_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSRegistrationType
_5gsregistrationtype
;
NASKeySetIdentifier
naskeysetidentifier
;
//_5GSMobileIdentity _5gsmobileidentity;
uint32_t
presence
;
NASKeySetIdentifier
non_current_native_nas_key_set_identifier
;
_5GMMCapability
_5gmmcapability
;
UESecurityCapability
uesecuritycapability
;
//NSSAI nssai;
_5GSTrackingAreaIdentity
_5gstrackingareaidentity
;
S1UENetworkCapability
s1uenetworkcapability
;
UplinkDataStatus
uplinkdatastatus
;
PDUSessionStatus
pdusessionstatus
;
MICOIndication
micoindication
;
UEStatus
uestatus
;
//_5GSMobileIdentity AdditionalGUTI;
AllowedPDUSessionStatus
allowedpdusessionstatus
;
UESUsageSetting
uesusagesetting
;
_5GSDRXParameters
_5gsdrxparameters
;
EPSNASMessageContainer
epsnasmessagecontainer
;
//LADNIndication ladnindication;
PayloadContainerType
payloadcontainertype
;
PayloadContainer
payloadcontainer
;
NetworkSlicingIndication
networkslicingindication
;
_5GSUpdateType
_5gsupdatetype
;
NASMessageContainer
nasmessagecontainer
;
}
registration_request_msg
;
typedef
struct
registration_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GSRegistrationType
_5gsregistrationtype
;
NASKeySetIdentifier
naskeysetidentifier
;
//_5GSMobileIdentity _5gsmobileidentity;
uint32_t
presence
;
NASKeySetIdentifier
non_current_native_nas_key_set_identifier
;
_5GMMCapability
_5gmmcapability
;
UESecurityCapability
uesecuritycapability
;
//NSSAI nssai;
_5GSTrackingAreaIdentity
_5gstrackingareaidentity
;
S1UENetworkCapability
s1uenetworkcapability
;
UplinkDataStatus
uplinkdatastatus
;
PDUSessionStatus
pdusessionstatus
;
MICOIndication
micoindication
;
UEStatus
uestatus
;
//_5GSMobileIdentity AdditionalGUTI;
AllowedPDUSessionStatus
allowedpdusessionstatus
;
UESUsageSetting
uesusagesetting
;
_5GSDRXParameters
_5gsdrxparameters
;
EPSNASMessageContainer
epsnasmessagecontainer
;
//LADNIndication ladnindication;
PayloadContainerType
payloadcontainertype
;
PayloadContainer
payloadcontainer
;
NetworkSlicingIndication
networkslicingindication
;
_5GSUpdateType
_5gsupdatetype
;
NASMessageContainer
nasmessagecontainer
;
}
registration_request_msg
;
int
decode_registration_request
(
registration_request_msg
*
registrationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_registration_request
(
registration_request_msg
*
registrationrequest
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/SecurityModeCommand.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,161 +27,152 @@
#include "TLVDecoder.h"
#include "SecurityModeCommand.h"
int
decode_security_mode_command
(
security_mode_command_msg
*
security_mode_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
int
decode_security_mode_command
(
security_mode_command_msg
*
security_mode_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_MODE_COMMAND_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_MODE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_nas_security_algorithms
(
&
security_mode_command
->
nassecurityalgorithms
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_nas_key_set_identifier
(
&
security_mode_command
->
naskeysetidentifier
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_nas_security_algorithms
(
&
security_mode_command
->
nassecurityalgorithms
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_ue_security_capability
(
&
security_mode_command
->
uesecuritycapability
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_nas_key_set_identifier
(
&
security_mode_command
->
naskeysetidentifier
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
while
(
len
-
decoded
>
0
){
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
!
ieiDecoded
)
if
((
decoded_result
=
decode_ue_security_capability
(
&
security_mode_command
->
uesecuritycapability
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
!
ieiDecoded
)
break
;
switch
(
ieiDecoded
&
0xf0
)
{
case
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI
:
if
((
decoded_result
=
decode_imeisv_request
(
&
security_mode_command
->
imeisvrequest
,
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT
;
}
break
;
switch
(
ieiDecoded
&
0xf0
){
case
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI
:
if
((
decoded_result
=
decode_imeisv_request
(
&
security_mode_command
->
imeisvrequest
,
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT
;
}
break
;
}
switch
(
ieiDecoded
){
case
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI
:
if
((
decoded_result
=
decode_epsnas_security_algorithms
(
&
security_mode_command
->
epsnassecurityalgorithms
,
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT
;
}
break
;
case
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI
:
if
((
decoded_result
=
decode_additional_5g_security_information
(
&
security_mode_command
->
additional5gsecurityinformation
,
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
}
switch
(
ieiDecoded
)
{
case
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI
:
if
((
decoded_result
=
decode_epsnas_security_algorithms
(
&
security_mode_command
->
epsnassecurityalgorithms
,
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT
;
}
break
;
case
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI
:
if
((
decoded_result
=
decode_additional_5g_security_information
(
&
security_mode_command
->
additional5gsecurityinformation
,
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT
;
}
break
;
case
SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
security_mode_command
->
eapmessage
,
SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT
;
}
break
;
case
SECURITY_MODE_COMMAND_ABBA_IEI
:
if
((
decoded_result
=
decode_abba
(
&
security_mode_command
->
abba
,
SECURITY_MODE_COMMAND_ABBA_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_ABBA_PRESENT
;
}
break
;
}
}
break
;
case
SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI
:
if
((
decoded_result
=
decode_eap_message
(
&
security_mode_command
->
eapmessage
,
SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT
;
}
break
;
case
SECURITY_MODE_COMMAND_ABBA_IEI
:
if
((
decoded_result
=
decode_abba
(
&
security_mode_command
->
abba
,
SECURITY_MODE_COMMAND_ABBA_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_command
->
presence
|=
SECURITY_MODE_COMMAND_ABBA_PRESENT
;
}
break
;
}
/*
if((decoded_result = decode_s1_ue_security_capability (&security_mode_command->s1uesecuritycapability, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
}
/*
if((decoded_result = decode_s1_ue_security_capability (&security_mode_command->s1uesecuritycapability, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
}
int
encode_security_mode_command
(
security_mode_command_msg
*
security_mode_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_MODE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_nas_security_algorithms
(
security_mode_command
->
nassecurityalgorithms
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
int
encode_security_mode_command
(
security_mode_command_msg
*
security_mode_command
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_MODE_COMMAND_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_nas_security_algorithms
(
security_mode_command
->
nassecurityalgorithms
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
if
((
encoded_result
=
encode_nas_key_set_identifier
(
&
security_mode_command
->
naskeysetidentifier
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_ue_security_capability
(
security_mode_command
->
uesecuritycapability
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT
)
==
SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT
)
{
if
((
encoded_result
=
encode_imeisv_request
(
security_mode_command
->
imeisvrequest
,
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_nas_key_set_identifier
(
&
security_mode_command
->
naskeysetidentifier
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT
)
==
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT
)
{
if
((
encoded_result
=
encode_epsnas_security_algorithms
(
security_mode_command
->
epsnassecurityalgorithms
,
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_ue_security_capability
(
security_mode_command
->
uesecuritycapability
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT
)
==
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT
)
{
if
((
encoded_result
=
encode_additional_5g_security_information
(
security_mode_command
->
additional5gsecurityinformation
,
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT
)
==
SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT
){
if
((
encoded_result
=
encode_imeisv_request
(
security_mode_command
->
imeisvrequest
,
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT
)
==
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT
){
if
((
encoded_result
=
encode_epsnas_security_algorithms
(
security_mode_command
->
epsnassecurityalgorithms
,
SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT
)
==
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT
){
if
((
encoded_result
=
encode_additional_5g_security_information
(
security_mode_command
->
additional5gsecurityinformation
,
SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT
)
==
SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT
){
if
((
encoded_result
=
encode_eap_message
(
security_mode_command
->
eapmessage
,
SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_ABBA_PRESENT
)
==
SECURITY_MODE_COMMAND_ABBA_PRESENT
){
if
((
encoded_result
=
encode_abba
(
security_mode_command
->
abba
,
SECURITY_MODE_COMMAND_ABBA_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_s1_ue_security_capability (security_mode_command->s1uesecuritycapability, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT
)
==
SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT
)
{
if
((
encoded_result
=
encode_eap_message
(
security_mode_command
->
eapmessage
,
SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
if
((
security_mode_command
->
presence
&
SECURITY_MODE_COMMAND_ABBA_PRESENT
)
==
SECURITY_MODE_COMMAND_ABBA_PRESENT
)
{
if
((
encoded_result
=
encode_abba
(
security_mode_command
->
abba
,
SECURITY_MODE_COMMAND_ABBA_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
encoded
+=
encoded_result
;
}
/*
if((encoded_result = encode_s1_ue_security_capability (security_mode_command->s1uesecuritycapability, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
return
encoded
;
*/
return
encoded
;
}
src/nas/mm/msg/SecurityModeCommand.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SECURITY_MODE_COMMAND_H_
#define SECURITY_MODE_COMMAND_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -13,7 +37,6 @@
#include "ABBA.h"
#include "S1UESecurityCapability.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_COMMAND_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -46,7 +69,6 @@
S1_UE_SECURITY_CAPABILITY_MAXIMUM_LENGTH + \
0)
#define SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI 0xE0
#define SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT (1<<0)
#define SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI 0x57
...
...
@@ -60,26 +82,23 @@
#define SECURITY_MODE_COMMAND_S1_UE_SECURITY_CAPABILITY_IEI 0x19
#define SECURITY_MODE_COMMAND_S1_UE_SECURITY_CAPABILITY_PRESENT (1<<5)
typedef
struct
security_mode_command_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASSecurityAlgorithms
nassecurityalgorithms
;
NASKeySetIdentifier
naskeysetidentifier
;
UESecurityCapability
uesecuritycapability
;
uint8_t
presence
;
IMEISVRequest
imeisvrequest
;
EPSNASSecurityAlgorithms
epsnassecurityalgorithms
;
Additional5GSecurityInformation
additional5gsecurityinformation
;
EAPMessage
eapmessage
;
ABBA
abba
;
//S1UESecurityCapability s1uesecuritycapability;
}
security_mode_command_msg
;
typedef
struct
security_mode_command_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASSecurityAlgorithms
nassecurityalgorithms
;
NASKeySetIdentifier
naskeysetidentifier
;
UESecurityCapability
uesecuritycapability
;
uint8_t
presence
;
IMEISVRequest
imeisvrequest
;
EPSNASSecurityAlgorithms
epsnassecurityalgorithms
;
Additional5GSecurityInformation
additional5gsecurityinformation
;
EAPMessage
eapmessage
;
ABBA
abba
;
//S1UESecurityCapability s1uesecuritycapability;
}
security_mode_command_msg
;
int
decode_security_mode_command
(
security_mode_command_msg
*
securitymodecommand
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_security_mode_command
(
security_mode_command_msg
*
securitymodecommand
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/SecurityModeComplete.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,66 +27,61 @@
#include "TLVDecoder.h"
#include "SecurityModeComplete.h"
int
decode_security_mode_complete
(
security_mode_complete_msg
*
security_mode_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
int
decode_security_mode_complete
(
security_mode_complete_msg
*
security_mode_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_MODE_COMPLETE_MINIMUM_LENGTH
,
len
);
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_MODE_COMPLETE_MINIMUM_LENGTH
,
len
);
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
!
ieiDecoded
)
break
;
switch
(
ieiDecoded
)
{
case
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI
:
if
((
decoded_result
=
decode_nas_message_container
(
&
security_mode_complete
->
nasmessagecontainer
,
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_complete
->
presence
|=
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT
;
}
while
(
len
-
decoded
>
0
)
{
uint8_t
ieiDecoded
=
*
(
buffer
+
decoded
);
if
(
!
ieiDecoded
)
break
;
switch
(
ieiDecoded
)
{
case
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI
:
if
((
decoded_result
=
decode_nas_message_container
(
&
security_mode_complete
->
nasmessagecontainer
,
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
{
decoded
+=
decoded_result
;
security_mode_complete
->
presence
|=
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT
;
}
break
;
}
}
/*
if((decoded_result = decode__5gs_mobile_identity (&security_mode_complete->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
}
/*
if((decoded_result = decode__5gs_mobile_identity (&security_mode_complete->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_message_container (&security_mode_complete->nasmessagecontainer, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
if((decoded_result = decode_nas_message_container (&security_mode_complete->nasmessagecontainer, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
return
decoded
;
}
int
encode_security_mode_complete
(
security_mode_complete_msg
*
security_mode_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_security_mode_complete
(
security_mode_complete_msg
*
security_mode_complete
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_MODE_COMPLETE_MINIMUM_LENGTH
,
len
);
/*
if((encoded_result = encode__5gs_mobile_identity (security_mode_complete->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_MODE_COMPLETE_MINIMUM_LENGTH
,
len
);
/*
if((encoded_result = encode__5gs_mobile_identity (security_mode_complete->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
if
((
security_mode_complete
->
presence
&
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT
)
==
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT
)
{
if
((
encoded_result
=
encode_nas_message_container
(
security_mode_complete
->
nasmessagecontainer
,
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded+=encoded_result;
*/
if
((
security_mode_complete
->
presence
&
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT
)
==
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT
){
if
((
encoded_result
=
encode_nas_message_container
(
security_mode_complete
->
nasmessagecontainer
,
SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
}
encoded
+=
encoded_result
;
}
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/SecurityModeComplete.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SECURITY_MODE_COMPLETE_H_
#define SECURITY_MODE_COMPLETE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -6,7 +30,6 @@
#include "_5GSMobileIdentity.h"
#include "NASMessageContainer.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_COMPLETE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -30,16 +53,16 @@
#define SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_IEI 0x71
#define SECURITY_MODE_COMPLETE_NAS_MESSAGE_CONTAINER_PRESENT (1<<1)
typedef
struct
security_mode_complete_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
uint8_t
presence
;
//_5GSMobileIdentity _5gsmobileidentity;
NASMessageContainer
nasmessagecontainer
;
}
security_mode_complete_msg
;
typedef
struct
security_mode_complete_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
uint8_t
presence
;
//_5GSMobileIdentity _5gsmobileidentity;
NASMessageContainer
nasmessagecontainer
;
}
security_mode_complete_msg
;
int
decode_security_mode_complete
(
security_mode_complete_msg
*
securitymodecomplete
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_security_mode_complete
(
security_mode_complete_msg
*
securitymodecomplete
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/SecurityModeReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,37 +27,32 @@
#include "TLVDecoder.h"
#include "SecurityModeReject.h"
int
decode_security_mode_reject
(
security_mode_reject_msg
*
security_mode_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_MODE_REJECT_MINIMUM_LENGTH
,
len
);
int
decode_security_mode_reject
(
security_mode_reject_msg
*
security_mode_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
security_mode_reject
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_MODE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode__5gmm_cause
(
&
security_mode_reject
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_security_mode_reject
(
security_mode_reject_msg
*
security_mode_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_security_mode_reject
(
security_mode_reject_msg
*
security_mode_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_MODE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gmm_cause
(
security_mode_reject
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_MODE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode__5gmm_cause
(
security_mode_reject
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/SecurityModeReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SECURITY_MODE_REJECT_H_
#define SECURITY_MODE_REJECT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "_5GMMCause.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_REJECT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
_5GMM_CAUSE_MAXIMUM_LENGTH + \
0)
typedef
struct
security_mode_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
}
security_mode_reject_msg
;
typedef
struct
security_mode_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
}
security_mode_reject_msg
;
int
decode_security_mode_reject
(
security_mode_reject_msg
*
securitymodereject
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_security_mode_reject
(
security_mode_reject_msg
*
securitymodereject
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/SecurityProtected5GSNASMessage.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,77 +27,72 @@
#include "TLVDecoder.h"
#include "SecurityProtected5GSNASMessage.h"
int
decode_security_protected5_gsnas_message
(
security_protected5_gsnas_message_msg
*
security_protected5_gsnas_message
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_PROTECTED5_GSNAS_MESSAGE_MINIMUM_LENGTH
,
len
);
int
decode_security_protected5_gsnas_message
(
security_protected5_gsnas_message_msg
*
security_protected5_gsnas_message
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
security_protected5_gsnas_message
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SECURITY_PROTECTED5_GSNAS_MESSAGE_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_security_header_type
(
&
security_protected5_gsnas_message
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
security_protected5_gsnas_message
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_authentication_code
(
&
security_protected5_gsnas_message
->
messageauthenticationcode
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
security_protected5_gsnas_message
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_sequence_number
(
&
security_protected5_gsnas_message
->
sequencenumber
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_authentication_code
(
&
security_protected5_gsnas_message
->
messageauthenticationcode
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_plain_5gsnas_message
(
&
security_protected5_gsnas_message
->
plain5gsnasmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_sequence_number
(
&
security_protected5_gsnas_message
->
sequencenumber
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_plain_5gsnas_message
(
&
security_protected5_gsnas_message
->
plain5gsnasmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode_security_protected5_gsnas_message
(
security_protected5_gsnas_message_msg
*
security_protected5_gsnas_message
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode_security_protected5_gsnas_message
(
security_protected5_gsnas_message_msg
*
security_protected5_gsnas_message
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_PROTECTED5_GSNAS_MESSAGE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
security_protected5_gsnas_message
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SECURITY_PROTECTED5_GSNAS_MESSAGE_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_security_header_type
(
security_protected5_gsnas_message
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
security_protected5_gsnas_message
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_authentication_code
(
security_protected5_gsnas_message
->
messageauthenticationcode
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
security_protected5_gsnas_message
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_sequence_number
(
security_protected5_gsnas_message
->
sequencenumber
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_authentication_code
(
security_protected5_gsnas_message
->
messageauthenticationcode
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_plain_5gsnas_message
(
security_protected5_gsnas_message
->
plain5gsnasmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_sequence_number
(
security_protected5_gsnas_message
->
sequencenumber
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_plain_5gsnas_message
(
security_protected5_gsnas_message
->
plain5gsnasmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/SecurityProtected5GSNASMessage.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SECURITY_PROTECTED_5GS_NAS_MESSAGE_H_
#define SECURITY_PROTECTED_5GS_NAS_MESSAGE_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -6,7 +30,6 @@
#include "SequenceNumber.h"
#include "Plain5GSNASMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_PROTECTED5_GSNAS_MESSAGE_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -25,14 +48,15 @@
PLAIN_5GSNAS_MESSAGE_MAXIMUM_LENGTH + \
0)
typedef
struct
security_protected5_gsnas_message_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageAuthenticationCode
messageauthenticationcode
;
SequenceNumber
sequencenumber
;
Plain5GSNASMessage
plain5gsnasmessage
;
}
security_protected5_gsnas_message_msg
;
typedef
struct
security_protected5_gsnas_message_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageAuthenticationCode
messageauthenticationcode
;
SequenceNumber
sequencenumber
;
Plain5GSNASMessage
plain5gsnasmessage
;
}
security_protected5_gsnas_message_msg
;
int
decode_security_protected5_gsnas_message
(
security_protected5_gsnas_message_msg
*
securityprotected5gsnasmessage
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_security_protected5_gsnas_message
(
security_protected5_gsnas_message_msg
*
securityprotected5gsnasmessage
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/ServiceAccept.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,97 +27,92 @@
#include "TLVDecoder.h"
#include "ServiceAccept.h"
int
decode_service_accept
(
service_accept_msg
*
service_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SERVICE_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
service_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
service_accept
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
service_accept
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_status
(
&
service_accept
->
pdusessionstatus
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_reactivation_result
(
&
service_accept
->
pdusessionreactivationresult
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_reactivation_result_error_cause
(
&
service_accept
->
pdusessionreactivationresulterrorcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_eap_message
(
&
service_accept
->
eapmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
int
decode_service_accept
(
service_accept_msg
*
service_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SERVICE_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
service_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
service_accept
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
service_accept
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_status
(
&
service_accept
->
pdusessionstatus
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_reactivation_result
(
&
service_accept
->
pdusessionreactivationresult
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_reactivation_result_error_cause
(
&
service_accept
->
pdusessionreactivationresulterrorcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_eap_message
(
&
service_accept
->
eapmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
}
int
encode_service_accept
(
service_accept_msg
*
service_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SERVICE_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
service_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
service_accept
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
service_accept
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_status
(
service_accept
->
pdusessionstatus
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_reactivation_result
(
service_accept
->
pdusessionreactivationresult
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_reactivation_result_error_cause
(
service_accept
->
pdusessionreactivationresulterrorcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_eap_message
(
service_accept
->
eapmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
int
encode_service_accept
(
service_accept_msg
*
service_accept
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SERVICE_ACCEPT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
service_accept
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
service_accept
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
service_accept
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_status
(
service_accept
->
pdusessionstatus
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_reactivation_result
(
service_accept
->
pdusessionreactivationresult
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_reactivation_result_error_cause
(
service_accept
->
pdusessionreactivationresulterrorcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_eap_message
(
service_accept
->
eapmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
}
src/nas/mm/msg/ServiceAccept.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SERVICE_ACCEPT_H_
#define SERVICE_ACCEPT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -8,7 +32,6 @@
#include "PDUSessionReactivationResultErrorCause.h"
#include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SERVICE_ACCEPT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -31,16 +54,17 @@
EAP_MESSAGE_MAXIMUM_LENGTH + \
0)
typedef
struct
service_accept_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PDUSessionStatus
pdusessionstatus
;
PDUSessionReactivationResult
pdusessionreactivationresult
;
PDUSessionReactivationResultErrorCause
pdusessionreactivationresulterrorcause
;
EAPMessage
eapmessage
;
}
service_accept_msg
;
typedef
struct
service_accept_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PDUSessionStatus
pdusessionstatus
;
PDUSessionReactivationResult
pdusessionreactivationresult
;
PDUSessionReactivationResultErrorCause
pdusessionreactivationresulterrorcause
;
EAPMessage
eapmessage
;
}
service_accept_msg
;
int
decode_service_accept
(
service_accept_msg
*
serviceaccept
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_service_accept
(
service_accept_msg
*
serviceaccept
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/ServiceReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,97 +27,92 @@
#include "TLVDecoder.h"
#include "ServiceReject.h"
int
decode_service_reject
(
service_reject_msg
*
service_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SERVICE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
service_reject
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
service_reject
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
service_reject
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
service_reject
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_status
(
&
service_reject
->
pdusessionstatus
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_gprs_timer2
(
&
service_reject
->
gprstimer2
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_eap_message
(
&
service_reject
->
eapmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
int
decode_service_reject
(
service_reject_msg
*
service_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SERVICE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
service_reject
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
service_reject
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
service_reject
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
service_reject
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_status
(
&
service_reject
->
pdusessionstatus
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_gprs_timer2
(
&
service_reject
->
gprstimer2
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_eap_message
(
&
service_reject
->
eapmessage
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
}
int
encode_service_reject
(
service_reject_msg
*
service_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SERVICE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
service_reject
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
service_reject
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
service_reject
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gmm_cause
(
service_reject
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_status
(
service_reject
->
pdusessionstatus
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_gprs_timer2
(
service_reject
->
gprstimer2
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_eap_message
(
service_reject
->
eapmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
int
encode_service_reject
(
service_reject_msg
*
service_reject
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SERVICE_REJECT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
service_reject
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
service_reject
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
service_reject
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gmm_cause
(
service_reject
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_status
(
service_reject
->
pdusessionstatus
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_gprs_timer2
(
service_reject
->
gprstimer2
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_eap_message
(
service_reject
->
eapmessage
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
}
src/nas/mm/msg/ServiceReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SERVICE_REJECT_H_
#define SERVICE_REJECT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -8,7 +32,6 @@
#include "GPRSTimer2.h"
#include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SERVICE_REJECT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -31,16 +54,17 @@
EAP_MESSAGE_MAXIMUM_LENGTH + \
0)
typedef
struct
service_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
PDUSessionStatus
pdusessionstatus
;
GPRSTimer2
gprstimer2
;
EAPMessage
eapmessage
;
}
service_reject_msg
;
typedef
struct
service_reject_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
PDUSessionStatus
pdusessionstatus
;
GPRSTimer2
gprstimer2
;
EAPMessage
eapmessage
;
}
service_reject_msg
;
int
decode_service_reject
(
service_reject_msg
*
servicereject
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_service_reject
(
service_reject_msg
*
servicereject
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/ServiceRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,127 +27,125 @@
#include "TLVDecoder.h"
#include "ServiceRequest.h"
int
decode_service_request
(
service_request_msg
*
service_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
//TODO: to be implemented
int
decode_service_request
(
service_request_msg
*
service_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
// int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SERVICE_REQUEST_MINIMUM_LENGTH
,
len
);
/*
if((decoded_result = decode_extended_protocol_discriminator (&service_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_security_header_type (&service_request->securityheadertype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_message_type (&service_request->messagetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_key_set_identifier (&service_request->naskeysetidentifier, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_service_type (&service_request->servicetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode__5gs_mobile_identity (&service_request->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_uplink_data_status (&service_request->uplinkdatastatus, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_pdu_session_status (&service_request->pdusessionstatus, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_allowed_pdu_session_status (&service_request->allowedpdusessionstatus, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_message_container (&service_request->nasmessagecontainer, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
SERVICE_REQUEST_MINIMUM_LENGTH
,
len
);
/*
if((decoded_result = decode_extended_protocol_discriminator (&service_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_security_header_type (&service_request->securityheadertype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_message_type (&service_request->messagetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_key_set_identifier (&service_request->naskeysetidentifier, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_service_type (&service_request->servicetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode__5gs_mobile_identity (&service_request->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_uplink_data_status (&service_request->uplinkdatastatus, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_pdu_session_status (&service_request->pdusessionstatus, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_allowed_pdu_session_status (&service_request->allowedpdusessionstatus, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
if((decoded_result = decode_nas_message_container (&service_request->nasmessagecontainer, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
*/
return
decoded
;
}
int
encode_service_request
(
service_request_msg
*
service_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encode_service_request
(
service_request_msg
*
service_request
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
// int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SERVICE_REQUEST_MINIMUM_LENGTH
,
len
);
/*
if((encoded_result = encode_extended_protocol_discriminator (service_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_security_header_type (service_request->securityheadertype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_message_type (service_request->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_nas_key_set_identifier (service_request->naskeysetidentifier, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_service_type (service_request->servicetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode__5gs_mobile_identity (service_request->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_uplink_data_status (service_request->uplinkdatastatus, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_pdu_session_status (service_request->pdusessionstatus, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_allowed_pdu_session_status (service_request->allowedpdusessionstatus, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_nas_message_container (service_request->nasmessagecontainer, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
return
encoded
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
SERVICE_REQUEST_MINIMUM_LENGTH
,
len
);
/*
if((encoded_result = encode_extended_protocol_discriminator (service_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_security_header_type (service_request->securityheadertype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_message_type (service_request->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_nas_key_set_identifier (service_request->naskeysetidentifier, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_service_type (service_request->servicetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode__5gs_mobile_identity (service_request->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_uplink_data_status (service_request->uplinkdatastatus, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_pdu_session_status (service_request->pdusessionstatus, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_allowed_pdu_session_status (service_request->allowedpdusessionstatus, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((encoded_result = encode_nas_message_container (service_request->nasmessagecontainer, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
*/
return
encoded
;
}
src/nas/mm/msg/ServiceRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef SERVICE_REQUEST_H_
#define SERVICE_REQUEST_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -11,7 +35,6 @@
#include "AllowedPDUSessionStatus.h"
#include "NASMessageContainer.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SERVICE_REQUEST_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -40,19 +63,20 @@
NAS_MESSAGE_CONTAINER_MAXIMUM_LENGTH + \
0)
typedef
struct
service_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASKeySetIdentifier
naskeysetidentifier
;
ServiceType
servicetype
;
_5GSMobileIdentity
_5gsmobileidentity
;
UplinkDataStatus
uplinkdatastatus
;
PDUSessionStatus
pdusessionstatus
;
AllowedPDUSessionStatus
allowedpdusessionstatus
;
NASMessageContainer
nasmessagecontainer
;
}
service_request_msg
;
typedef
struct
service_request_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
NASKeySetIdentifier
naskeysetidentifier
;
ServiceType
servicetype
;
_5GSMobileIdentity
_5gsmobileidentity
;
UplinkDataStatus
uplinkdatastatus
;
PDUSessionStatus
pdusessionstatus
;
AllowedPDUSessionStatus
allowedpdusessionstatus
;
NASMessageContainer
nasmessagecontainer
;
}
service_request_msg
;
int
decode_service_request
(
service_request_msg
*
servicerequest
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_service_request
(
service_request_msg
*
servicerequest
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/ULNASTransport.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "ULNASTransport.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ULNASTransport.h"
int
decode_ulnas_transport
(
ulnas_transport_msg
*
ulnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
ULNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
ulnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
ulnas_transport
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
ulnas_transport
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container_type
(
&
ulnas_transport
->
payloadcontainertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container
(
&
ulnas_transport
->
payloadcontainer
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_identity2
(
&
ulnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_request_type
(
&
ulnas_transport
->
requesttype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_snssai
(
&
ulnas_transport
->
snssai
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_dnn
(
&
ulnas_transport
->
dnn
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_additional_information
(
&
ulnas_transport
->
additionalinformation
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
int
decode_ulnas_transport
(
ulnas_transport_msg
*
ulnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
ULNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
ulnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
ulnas_transport
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
ulnas_transport
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container_type
(
&
ulnas_transport
->
payloadcontainertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_payload_container
(
&
ulnas_transport
->
payloadcontainer
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_pdu_session_identity2
(
&
ulnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_request_type
(
&
ulnas_transport
->
requesttype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_snssai
(
&
ulnas_transport
->
snssai
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_dnn
(
&
ulnas_transport
->
dnn
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_additional_information
(
&
ulnas_transport
->
additionalinformation
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
}
int
encode_ulnas_transport
(
ulnas_transport_msg
*
ulnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
ULNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
ulnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
ulnas_transport
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
ulnas_transport
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container_type
(
ulnas_transport
->
payloadcontainertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container
(
ulnas_transport
->
payloadcontainer
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_identity2
(
ulnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_request_type
(
ulnas_transport
->
requesttype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_snssai
(
ulnas_transport
->
snssai
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_dnn
(
ulnas_transport
->
dnn
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_additional_information
(
ulnas_transport
->
additionalinformation
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
int
encode_ulnas_transport
(
ulnas_transport_msg
*
ulnas_transport
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
ULNAS_TRANSPORT_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
ulnas_transport
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
ulnas_transport
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
ulnas_transport
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container_type
(
ulnas_transport
->
payloadcontainertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_payload_container
(
ulnas_transport
->
payloadcontainer
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_pdu_session_identity2
(
ulnas_transport
->
pdusessionidentity2
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_request_type
(
ulnas_transport
->
requesttype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_snssai
(
ulnas_transport
->
snssai
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_dnn
(
ulnas_transport
->
dnn
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_additional_information
(
ulnas_transport
->
additionalinformation
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
}
src/nas/mm/msg/ULNASTransport.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef ULNAS_TRANSPORT_H_
#define ULNAS_TRANSPORT_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -11,7 +35,6 @@
#include "DNN.h"
#include "AdditionalInformation.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ULNAS_TRANSPORT_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -40,19 +63,20 @@
ADDITIONAL_INFORMATION_MAXIMUM_LENGTH + \
0)
typedef
struct
ulnas_transport_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PayloadContainerType
payloadcontainertype
;
PayloadContainer
payloadcontainer
;
PDUSessionIdentity2
pdusessionidentity2
;
RequestType
requesttype
;
SNSSAI
snssai
;
DNN
dnn
;
AdditionalInformation
additionalinformation
;
}
ulnas_transport_msg
;
typedef
struct
ulnas_transport_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
PayloadContainerType
payloadcontainertype
;
PayloadContainer
payloadcontainer
;
PDUSessionIdentity2
pdusessionidentity2
;
RequestType
requesttype
;
SNSSAI
snssai
;
DNN
dnn
;
AdditionalInformation
additionalinformation
;
}
ulnas_transport_msg
;
int
decode_ulnas_transport
(
ulnas_transport_msg
*
ulnastransport
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode_ulnas_transport
(
ulnas_transport_msg
*
ulnastransport
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/_5GMMStatus.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -6,67 +27,62 @@
#include "TLVDecoder.h"
#include "_5GMMStatus.h"
int
decode__5gmm_status
(
_5gmm_status_msg
*
_5gmm_status
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
_5GMM_STATUS_MINIMUM_LENGTH
,
len
);
int
decode__5gmm_status
(
_5gmm_status_msg
*
_5gmm_status
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
decoded
=
0
;
int
decoded_result
=
0
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
_5gmm_status
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER
(
buffer
,
_5GMM_STATUS_MINIMUM_LENGTH
,
len
);
if
((
decoded_result
=
decode_security_header_type
(
&
_5gmm_status
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_extended_protocol_discriminator
(
&
_5gmm_status
->
extendedprotocoldiscriminator
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
_5gmm_status
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_security_header_type
(
&
_5gmm_status
->
securityheadertype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
_5gmm_status
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode_message_type
(
&
_5gmm_status
->
messagetype
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
if
((
decoded_result
=
decode__5gmm_cause
(
&
_5gmm_status
->
_5gmmcause
,
0
,
buffer
+
decoded
,
len
-
decoded
))
<
0
)
return
decoded_result
;
else
decoded
+=
decoded_result
;
return
decoded
;
return
decoded
;
}
int
encode__5gmm_status
(
_5gmm_status_msg
*
_5gmm_status
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
int
encode__5gmm_status
(
_5gmm_status_msg
*
_5gmm_status
,
uint8_t
*
buffer
,
uint32_t
len
)
{
uint32_t
encoded
=
0
;
int
encoded_result
=
0
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
_5GMM_STATUS_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
_5gmm_status
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER
(
buffer
,
_5GMM_STATUS_MINIMUM_LENGTH
,
len
);
if
((
encoded_result
=
encode_security_header_type
(
_5gmm_status
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_extended_protocol_discriminator
(
_5gmm_status
->
extendedprotocoldiscriminator
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
_5gmm_status
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_security_header_type
(
_5gmm_status
->
securityheadertype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gmm_cause
(
_5gmm_status
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode_message_type
(
_5gmm_status
->
messagetype
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
if
((
encoded_result
=
encode__5gmm_cause
(
_5gmm_status
->
_5gmmcause
,
0
,
buffer
+
encoded
,
len
-
encoded
))
<
0
)
return
encoded_result
;
else
encoded
+=
encoded_result
;
return
encoded
;
return
encoded
;
}
src/nas/mm/msg/_5GMMStatus.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __5GMM_STATUS_H_
#define __5GMM_STATUS_H_
#include <stdint.h>
#include "ExtendedProtocolDiscriminator.h"
...
...
@@ -5,7 +29,6 @@
#include "MessageType.h"
#include "_5GMMCause.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define _5GMM_STATUS_MINIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
...
...
@@ -22,13 +45,14 @@
_5GMM_CAUSE_MAXIMUM_LENGTH + \
0)
typedef
struct
_5gmm_status_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
}
_5gmm_status_msg
;
typedef
struct
_5gmm_status_msg_tag
{
ExtendedProtocolDiscriminator
extendedprotocoldiscriminator
;
SecurityHeaderType
securityheadertype
;
MessageType
messagetype
;
_5GMMCause
_5gmmcause
;
}
_5gmm_status_msg
;
int
decode__5gmm_status
(
_5gmm_status_msg
*
_5gmmstatus
,
uint8_t
*
buffer
,
uint32_t
len
);
int
encode__5gmm_status
(
_5gmm_status_msg
*
_5gmmstatus
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/mm/msg/mmMsgDef.h
View file @
f4ad53db
...
...
@@ -19,10 +19,12 @@
* contact@openairinterface.org
*/
#ifndef MM_MSG_DEF_H_
#define MM_MSG_DEF_H_
#include <stdint.h>
#include <asm/byteorder.h>
typedef
struct
{
#ifdef __LITTLE_ENDIAN_BITFIELD
uint8_t
extended_protocol_discriminator
;
...
...
@@ -34,4 +36,6 @@ typedef struct {
uint8_t
security_header_type
:
4
;
#endif
uint8_t
message_type
;
}
__attribute__
((
__packed__
))
mm_msg_header_t
;
}
__attribute__
((
__packed__
))
mm_msg_header_t
;
#endif
src/nas/mm/msg/mm_msg.c
View file @
f4ad53db
...
...
@@ -19,7 +19,6 @@
* contact@openairinterface.org
*/
#include "common_types.h"
#include "mm_msg.h"
#include "TLVDecoder.h"
...
...
@@ -29,147 +28,110 @@
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
static
int
_fivegmm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
);
static
int
_fivegmm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
);
static
int
_fivegmm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
);
static
int
_fivegmm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
);
/****************************************************************************
** **
** Name: emm_msg_encode() **
** **
** Description: Encode EPS Mobility Management messages **
** **
** Inputs: msg: The EMM message structure to encode **
** length: Maximal capacity of the output buffer **
** Others: None **
** **
** Outputs: buffer: Pointer to the encoded data buffer **
** Return: The number of bytes in the buffer if data **
** have been successfully encoded; **
** A negative error code otherwise. **
** Others: None **
** **
***************************************************************************/
int
fivegmm_msg_encode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
)
{
/*
* fivegmm_msg_encode
* Encode EPS Mobility Management messages
* @param [msg] The EMM message structure to encode
* @param [length] Maximal capacity of the output buffer
* @return The number of bytes in the buffer if data have been successfully encoded; A negative error code otherwise.
* @return buffer: Pointer to the encoded data buffer
*
*/
int
fivegmm_msg_encode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
)
{
//OAILOG_FUNC_IN (LOG_NAS_EMM);
int
header_result
;
int
encode_result
;
// uint8_t *buffer_log = buffer;
// bool is_down_link = true;
int
header_result
;
int
encode_result
;
/*
* First encode the EMM message header
*/
//printf("_fivegmm_msg_encode_header\n");
header_result
=
_fivegmm_msg_encode_header
(
&
msg
->
header
,
buffer
,
len
);
header_result
=
_fivegmm_msg_encode_header
(
&
msg
->
header
,
buffer
,
len
);
if
(
header_result
<
0
)
{
//OAILOG_ERROR (LOG_NAS_EMM, "EMM-MSG - Failed to encode EMM message header " "(%d)\n", header_result);
//OAILOG_FUNC_RETURN (LOG_NAS_EMM, header_result);
return
header_result
;
}
buffer
+=
header_result
;
len
-=
header_result
;
switch
(
msg
->
header
.
message_type
)
{
//need more msg encode
switch
(
msg
->
header
.
message_type
)
{
//need more msg encode
//case AuthenticationRequest:
//encode_result = encode_authentication_request(&msg->authentication_request,buffer,len);/* msg define in openair5g-cn/src/amf/nas/mm/msg */
//break;
case
AUTHENTICATION_REQUEST
:
encode_result
=
encode_authentication_request
(
&
msg
->
authentication_request
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESPONSE
:
encode_result
=
encode_authentication_response
(
&
msg
->
authentication_response
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESULT
:
encode_result
=
encode_authentication_result
(
&
msg
->
authentication_result
,
buffer
,
len
);
break
;
case
AUTHENTICATION_REJECT
:
encode_result
=
encode_authentication_reject
(
&
msg
->
authentication_reject
,
buffer
,
len
);
break
;
case
AUTHENTICATION_FAILURE
:
encode_result
=
encode_authentication_failure
(
&
msg
->
authentication_failure
,
buffer
,
len
);
break
;
case
REGISTRATION_REQUEST
:
encode_result
=
encode_registration_request
(
&
msg
->
registration_request
,
buffer
,
len
);
break
;
case
REGISTRATION_ACCEPT
:
encode_result
=
encode_registration_accept
(
&
msg
->
registration_accept
,
buffer
,
len
);
break
;
case
REGISTRATION_COMPLETE
:
encode_result
=
encode_registration_complete
(
&
msg
->
registration_complete
,
buffer
,
len
);
break
;
case
REGISTRATION_REJECT
:
encode_result
=
encode_registration_reject
(
&
msg
->
registration_reject
,
buffer
,
len
);
break
;
case
IDENTITY_REQUEST
:
encode_result
=
encode_identity_request
(
&
msg
->
identity_request
,
buffer
,
len
);
break
;
case
IDENTITY_RESPONSE
:
encode_result
=
encode_identity_response
(
&
msg
->
identity_response
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMMAND
:
encode_result
=
encode_security_mode_command
(
&
msg
->
security_mode_command
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMPLETE
:
encode_result
=
encode_security_mode_complete
(
&
msg
->
security_mode_complete
,
buffer
,
len
);
break
;
case
SECURITY_MODE_REJECT
:
encode_result
=
encode_security_mode_reject
(
&
msg
->
security_mode_reject
,
buffer
,
len
);
break
;
//encode_result = encode_authentication_request(&msg->authentication_request,buffer,len);/* msg define in openair5g-cn/src/amf/nas/mm/msg */
//break;
case
AUTHENTICATION_REQUEST
:
encode_result
=
encode_authentication_request
(
&
msg
->
authentication_request
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESPONSE
:
encode_result
=
encode_authentication_response
(
&
msg
->
authentication_response
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESULT
:
encode_result
=
encode_authentication_result
(
&
msg
->
authentication_result
,
buffer
,
len
);
break
;
case
AUTHENTICATION_REJECT
:
encode_result
=
encode_authentication_reject
(
&
msg
->
authentication_reject
,
buffer
,
len
);
break
;
case
AUTHENTICATION_FAILURE
:
encode_result
=
encode_authentication_failure
(
&
msg
->
authentication_failure
,
buffer
,
len
);
break
;
case
REGISTRATION_REQUEST
:
encode_result
=
encode_registration_request
(
&
msg
->
registration_request
,
buffer
,
len
);
break
;
case
REGISTRATION_ACCEPT
:
encode_result
=
encode_registration_accept
(
&
msg
->
registration_accept
,
buffer
,
len
);
break
;
case
REGISTRATION_COMPLETE
:
encode_result
=
encode_registration_complete
(
&
msg
->
registration_complete
,
buffer
,
len
);
break
;
case
REGISTRATION_REJECT
:
encode_result
=
encode_registration_reject
(
&
msg
->
registration_reject
,
buffer
,
len
);
break
;
case
IDENTITY_REQUEST
:
encode_result
=
encode_identity_request
(
&
msg
->
identity_request
,
buffer
,
len
);
break
;
case
IDENTITY_RESPONSE
:
encode_result
=
encode_identity_response
(
&
msg
->
identity_response
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMMAND
:
encode_result
=
encode_security_mode_command
(
&
msg
->
security_mode_command
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMPLETE
:
encode_result
=
encode_security_mode_complete
(
&
msg
->
security_mode_complete
,
buffer
,
len
);
break
;
case
SECURITY_MODE_REJECT
:
encode_result
=
encode_security_mode_reject
(
&
msg
->
security_mode_reject
,
buffer
,
len
);
break
;
}
if
(
encode_result
<
0
)
{
//OAILOG_ERROR (LOG_NAS_EMM, "EMM-MSG - Failed to encode L3 EMM message 0x%x " "(%d)\n", msg->header.message_type, encode_result);
}
else
{
//nas_itti_plain_msg ((char *)buffer_log, (nas_message_t *) msg, header_result + encode_result, is_down_link);
}
//printf("plain mm msg header result(%d),encode result(%d)\n",header_result,encode_result);
return
header_result
+
encode_result
;
return
header_result
+
encode_result
;
//OAILOG_FUNC_RETURN (LOG_NAS_EMM, header_result + encode_result);
}
/****************************************************************************
** **
** Name: _emm_msg_encode_header() **
** **
** The protocol discriminator and the security header type **
** have already been encoded. **
** **
** Inputs: header: The EMM message header to encode **
** len: Maximal capacity of the output buffer **
** Others: None **
** **
** Outputs: buffer: Pointer to the encoded data buffer **
** Return: The number of bytes in the buffer if data **
** have been successfully encoded; **
** A negative error code otherwise. **
** Others: None **
** **
***************************************************************************/
static
int
_fivegmm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
/*
* _fivegmm_msg_encode_header
* The protocol discriminator and the security header type have already been encoded
* @param [header] The EMM message header to encode
* @param [len] Maximal capacity of the output buffer
* @return The number of bytes in the buffer if data have been successfully encoded, A negative error code otherwise.
* @return buffer: Pointer to the encoded data buffer
*
*/
static
int
_fivegmm_msg_encode_header
(
const
mm_msg_header_t
*
header
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
/*
* Check the buffer length
*/
if
(
len
<
sizeof
(
mm_msg_header_t
))
{
if
(
len
<
sizeof
(
mm_msg_header_t
))
{
return
(
TLV_BUFFER_TOO_SHORT
);
}
/*
...
...
@@ -184,36 +146,25 @@ _fivegmm_msg_encode_header (
* Encode the security header type and the protocol discriminator
*/
//ENCODE_U8 (buffer + size, *(uint8_t *) (header), size);
ENCODE_U8
(
buffer
+
size
,
header
->
extended_protocol_discriminator
,
size
);
ENCODE_U8
(
buffer
+
size
,
header
->
security_header_type
,
size
);
ENCODE_U8
(
buffer
+
size
,
header
->
extended_protocol_discriminator
,
size
);
ENCODE_U8
(
buffer
+
size
,
header
->
security_header_type
,
size
);
/*
* Encode the message type
*/
ENCODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
ENCODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
return
(
size
);
}
int
mm_msg_decode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
)
{
int
mm_msg_decode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
)
{
//OAILOG_FUNC_IN (LOG_NAS);
int
header_result
=
0
;
int
decode_result
=
0
;
// uint8_t *buffer_log = buffer;
// uint32_t len_log = len;
// bool is_down_link = false;
int
header_result
=
0
;
int
decode_result
=
0
;
/*
* First decode the MM message header
*/
header_result
=
_fivegmm_msg_decode_header
(
&
msg
->
header
,
buffer
,
len
);
header_result
=
_fivegmm_msg_decode_header
(
&
msg
->
header
,
buffer
,
len
);
//OAILOG_DEBUG(LOG_NAS,"header_result(%d)\n",header_result);
//printf("after _fivegmm_msg_decode_header,decoded protocol %x\n",msg->header.extended_protocol_discriminator);
//printf("after _fivegmm_msg_decode_header,decoded security type %x\n",msg->header.security_header_type);
//printf("after _fivegmm_msg_decode_header,decoded message type %x\n",msg->header.message_type);
if
(
header_result
<
0
)
{
//OAILOG_ERROR (LOG_NAS_EMM, "EMM-MSG - Failed to decode MM message header " "(%d)\n", header_result);
//OAILOG_FUNC_RETURN (LOG_NAS_EMM, header_result);
...
...
@@ -223,49 +174,49 @@ mm_msg_decode (
buffer
+=
header_result
;
len
-=
header_result
;
//OAILOG_INFO (LOG_NAS_EMM, "EMM-MSG - Message Type 0x%02x\n", msg->header.message_type);
switch
(
msg
->
header
.
message_type
)
{
//plain nas message e.g. registrationrequest message
case
AUTHENTICATION_REQUEST
:
decode_result
=
decode_authentication_request
(
&
msg
->
authentication_request
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESPONSE
:
decode_result
=
decode_authentication_response
(
&
msg
->
authentication_response
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESULT
:
decode_result
=
decode_authentication_result
(
&
msg
->
authentication_result
,
buffer
,
len
);
break
;
case
AUTHENTICATION_REJECT
:
decode_result
=
decode_authentication_reject
(
&
msg
->
authentication_reject
,
buffer
,
len
);
break
;
case
AUTHENTICATION_FAILURE
:
decode_result
=
decode_authentication_failure
(
&
msg
->
authentication_failure
,
buffer
,
len
);
break
;
case
REGISTRATION_REQUEST
:
decode_result
=
decode_registration_request
(
&
msg
->
registration_request
,
buffer
,
len
);
break
;
case
REGISTRATION_ACCEPT
:
decode_result
=
decode_registration_accept
(
&
msg
->
registration_accept
,
buffer
,
len
);
break
;
case
REGISTRATION_COMPLETE
:
decode_result
=
decode_registration_complete
(
&
msg
->
registration_complete
,
buffer
,
len
);
break
;
case
REGISTRATION_REJECT
:
decode_result
=
decode_registration_reject
(
&
msg
->
registration_reject
,
buffer
,
len
);
break
;
case
IDENTITY_REQUEST
:
decode_result
=
decode_identity_request
(
&
msg
->
identity_request
,
buffer
,
len
);
break
;
case
IDENTITY_RESPONSE
:
decode_result
=
decode_identity_response
(
&
msg
->
identity_response
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMMAND
:
decode_result
=
decode_security_mode_command
(
&
msg
->
security_mode_command
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMPLETE
:
decode_result
=
decode_security_mode_complete
(
&
msg
->
security_mode_complete
,
buffer
,
len
);
break
;
case
SECURITY_MODE_REJECT
:
decode_result
=
decode_security_mode_reject
(
&
msg
->
security_mode_reject
,
buffer
,
len
);
break
;
switch
(
msg
->
header
.
message_type
)
{
//plain nas message e.g. registrationrequest message
case
AUTHENTICATION_REQUEST
:
decode_result
=
decode_authentication_request
(
&
msg
->
authentication_request
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESPONSE
:
decode_result
=
decode_authentication_response
(
&
msg
->
authentication_response
,
buffer
,
len
);
break
;
case
AUTHENTICATION_RESULT
:
decode_result
=
decode_authentication_result
(
&
msg
->
authentication_result
,
buffer
,
len
);
break
;
case
AUTHENTICATION_REJECT
:
decode_result
=
decode_authentication_reject
(
&
msg
->
authentication_reject
,
buffer
,
len
);
break
;
case
AUTHENTICATION_FAILURE
:
decode_result
=
decode_authentication_failure
(
&
msg
->
authentication_failure
,
buffer
,
len
);
break
;
case
REGISTRATION_REQUEST
:
decode_result
=
decode_registration_request
(
&
msg
->
registration_request
,
buffer
,
len
);
break
;
case
REGISTRATION_ACCEPT
:
decode_result
=
decode_registration_accept
(
&
msg
->
registration_accept
,
buffer
,
len
);
break
;
case
REGISTRATION_COMPLETE
:
decode_result
=
decode_registration_complete
(
&
msg
->
registration_complete
,
buffer
,
len
);
break
;
case
REGISTRATION_REJECT
:
decode_result
=
decode_registration_reject
(
&
msg
->
registration_reject
,
buffer
,
len
);
break
;
case
IDENTITY_REQUEST
:
decode_result
=
decode_identity_request
(
&
msg
->
identity_request
,
buffer
,
len
);
break
;
case
IDENTITY_RESPONSE
:
decode_result
=
decode_identity_response
(
&
msg
->
identity_response
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMMAND
:
decode_result
=
decode_security_mode_command
(
&
msg
->
security_mode_command
,
buffer
,
len
);
break
;
case
SECURITY_MODE_COMPLETE
:
decode_result
=
decode_security_mode_complete
(
&
msg
->
security_mode_complete
,
buffer
,
len
);
break
;
case
SECURITY_MODE_REJECT
:
decode_result
=
decode_security_mode_reject
(
&
msg
->
security_mode_reject
,
buffer
,
len
);
break
;
}
if
(
decode_result
<
0
)
{
//OAILOG_ERROR (LOG_NAS_EMM, "EMM-MSG - Failed to decode L3 EMM message 0x%x " "(%d)\n", msg->header.message_type, decode_result);
...
...
@@ -276,22 +227,17 @@ mm_msg_decode (
*/
//nas_itti_plain_msg ((char *)buffer_log, (nas_message_t *) msg, len_log, is_down_link);
}
return
header_result
+
decode_result
;
return
header_result
+
decode_result
;
//OAILOG_FUNC_RETURN (LOG_NAS_EMM, header_result + decode_result);
}
static
int
_fivegmm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
static
int
_fivegmm_msg_decode_header
(
mm_msg_header_t
*
header
,
const
uint8_t
*
buffer
,
uint32_t
len
)
{
int
size
=
0
;
/*
* Check the buffer length
*/
if
(
len
<
sizeof
(
mm_msg_header_t
))
{
if
(
len
<
sizeof
(
mm_msg_header_t
))
{
return
(
TLV_BUFFER_TOO_SHORT
);
}
...
...
@@ -304,7 +250,7 @@ _fivegmm_msg_decode_header (
/*
* Decode the message type
*/
DECODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
DECODE_U8
(
buffer
+
size
,
header
->
message_type
,
size
);
/*
* Check the protocol discriminator
...
...
@@ -313,6 +259,6 @@ _fivegmm_msg_decode_header (
//OAILOG_ERROR (LOG_NAS_EMM, "ESM-MSG - Unexpected protocol discriminator: 0x%x\n", header->protocol_discriminator);
return
(
TLV_PROTOCOL_NOT_SUPPORTED
);
}
//printf("decoded plain msg header size %d\n",size);
return
(
size
);
}
src/nas/mm/msg/mm_msg.h
View file @
f4ad53db
...
...
@@ -19,11 +19,9 @@
* contact@openairinterface.org
*/
#ifndef MM_MSG_H_
#define MM_MSG_H_
#include "mmMsgDef.h"
#include "AuthenticationRequest.h"
#include "AuthenticationResponse.h"
...
...
@@ -51,22 +49,19 @@
#include "SecurityModeReject.h"
#include "_5GMMStatus.h"
/*
* Structure of EMM plain NAS message
* ----------------------------------
*/
typedef
union
{
mm_msg_header_t
header
;
authentication_request_msg
authentication_request
;
//Done 19/03/2019
authentication_response_msg
authentication_response
;
//Done 19/03/2019
authentication_request_msg
authentication_request
;
authentication_response_msg
authentication_response
;
authentication_result_msg
authentication_result
;
authentication_failure_msg
authentication_failure
;
//Done 19/03/2019
authentication_reject_msg
authentication_reject
;
//Done 19/03/2019
authentication_failure_msg
authentication_failure
;
authentication_reject_msg
authentication_reject
;
registration_request_msg
registration_request
;
registration_accept_msg
registration_accept
;
registration_complete_msg
registration_complete
;
registration_reject_msg
registration_reject
;
...
...
@@ -88,17 +83,10 @@ typedef union {
security_mode_reject_msg
security_mode_reject
;
_5gmm_status_msg
_5gmm_status
;
}
MM_msg
;
int
mm_msg_decode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
}
MM_msg
;
int
fivegmm_msg_encode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
int
mm_msg_decode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
int
fivegmm_msg_encode
(
MM_msg
*
msg
,
uint8_t
*
buffer
,
uint32_t
len
);
#endif
src/nas/nas_message.h
View file @
f4ad53db
...
...
@@ -26,21 +26,16 @@
#include "sm_msg.h"
#include "common_types.h"
/***********************************/
/********test mac and encrypt/decrypt********/
/***********************************/
//test mac and encrypt/decrypt
#define DIRECTION__ 1//SECU_DIRECTION_DOWNLINK
#define TEST_MAC_ENCRYPT_DECRYPT__ 0
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 7
/*********************************************************/
/************************* 9.1 24501**********************/
//Section 9.1 3GPP TS 24.501
/* Structure of security protected header */
typedef
struct
nas_message_security_header_s
{
#ifdef __LITTLE_ENDIAN_BITFIELD
extended_protocol_discriminator_t
extended_protocol_discriminator
;
//3gpp_24.501.h
extended_protocol_discriminator_t
extended_protocol_discriminator
;
uint8_t
security_header_type
:
4
;
uint8_t
spare_half_octet
:
4
;
#endif
...
...
src/nas/security/kdf.c
View file @
f4ad53db
...
...
@@ -29,31 +29,18 @@
#include "secu_defs.h"
#include "dynamic_memory_check.h"
void
kdf
(
const
uint8_t
*
key
,
const
unsigned
key_len
,
uint8_t
*
s
,
const
unsigned
s_len
,
uint8_t
*
out
,
const
unsigned
out_len
)
{
struct
hmac_sha256_ctx
*
ctx
=
calloc
(
1
,
sizeof
(
struct
hmac_sha256_ctx
));
void
kdf
(
const
uint8_t
*
key
,
const
unsigned
key_len
,
uint8_t
*
s
,
const
unsigned
s_len
,
uint8_t
*
out
,
const
unsigned
out_len
)
{
struct
hmac_sha256_ctx
*
ctx
=
calloc
(
1
,
sizeof
(
struct
hmac_sha256_ctx
));
//memset (&ctx, 0, sizeof (ctx));
hmac_sha256_set_key
(
ctx
,
key_len
,
key
);
hmac_sha256_update
(
ctx
,
s_len
,
s
);
hmac_sha256_digest
(
ctx
,
out_len
,
out
);
hmac_sha256_set_key
(
ctx
,
key_len
,
key
);
hmac_sha256_update
(
ctx
,
s_len
,
s
);
hmac_sha256_digest
(
ctx
,
out_len
,
out
);
free_wrapper
((
void
**
)
&
ctx
);
}
int
derive_keNB
(
const
uint8_t
*
kasme_32
,
const
uint32_t
nas_count
,
uint8_t
*
keNB
)
{
uint8_t
s
[
7
]
=
{
0
};
int
derive_keNB
(
const
uint8_t
*
kasme_32
,
const
uint32_t
nas_count
,
uint8_t
*
keNB
)
{
uint8_t
s
[
7
]
=
{
0
};
// FC
s
[
0
]
=
FC_KENB
;
...
...
@@ -65,6 +52,6 @@ derive_keNB (
// Length of NAS count
s
[
5
]
=
0x00
;
s
[
6
]
=
0x04
;
kdf
(
kasme_32
,
32
,
s
,
7
,
keNB
,
32
);
kdf
(
kasme_32
,
32
,
s
,
7
,
keNB
,
32
);
return
0
;
}
src/nas/security/key_nas_deriver.c
View file @
f4ad53db
...
...
@@ -27,31 +27,24 @@
#include "security_types.h"
#include "secu_defs.h"
#include "secu_defs.h"
//#include "log.h"
/*!
@brief Derive the kNASenc from kasme and perform truncate on the generated key to
reduce his size to 128 bits. Definition of the derivation function can
be found in 3GPP TS.33401 #A.7
@param[in] nas_alg_type NAS algorithm distinguisher
@param[in] nas_enc_alg_id NAS encryption/integrity algorithm identifier.
Possible values are:
- 0 for EIA0 algorithm (Null Integrity Protection algorithm)
- 1 for 128-EIA1 SNOW 3G
- 2 for 128-EIA2 AES
@param[in] kasme Key for MME as provided by AUC
@param[out] knas Pointer to reference where output of KDF will be stored.
NOTE: knas is dynamically allocated by the KDF function
*/
int
derive_key_nas
(
algorithm_type_dist_t
nas_alg_type
,
uint8_t
nas_enc_alg_id
,
const
uint8_t
*
kasme_32
,
uint8_t
*
knas
)
{
uint8_t
s
[
7
]
=
{
0
};
uint8_t
out
[
32
]
=
{
0
};
@brief Derive the kNASenc from kasme and perform truncate on the generated key to
reduce his size to 128 bits. Definition of the derivation function can
be found in 3GPP TS.33401 #A.7
@param[in] nas_alg_type NAS algorithm distinguisher
@param[in] nas_enc_alg_id NAS encryption/integrity algorithm identifier.
Possible values are:
- 0 for EIA0 algorithm (Null Integrity Protection algorithm)
- 1 for 128-EIA1 SNOW 3G
- 2 for 128-EIA2 AES
@param[in] kasme Key for MME as provided by AUC
@param[out] knas Pointer to reference where output of KDF will be stored.
NOTE: knas is dynamically allocated by the KDF function
*/
int
derive_key_nas
(
algorithm_type_dist_t
nas_alg_type
,
uint8_t
nas_enc_alg_id
,
const
uint8_t
*
kasme_32
,
uint8_t
*
knas
)
{
uint8_t
s
[
7
]
=
{
0
};
uint8_t
out
[
32
]
=
{
0
};
/*
* FC
...
...
@@ -60,7 +53,7 @@ derive_key_nas (
/*
* P0 = algorithm type distinguisher
*/
s
[
1
]
=
(
uint8_t
)
(
nas_alg_type
&
0xFF
);
s
[
1
]
=
(
uint8_t
)(
nas_alg_type
&
0xFF
);
/*
* L0 = length(P0) = 1
*/
...
...
@@ -78,7 +71,7 @@ derive_key_nas (
//OAILOG_TRACE (LOG_NAS, "FC %d nas_alg_type distinguisher %d nas_enc_alg_identity %d\n", FC_ALG_KEY_DER, nas_alg_type, nas_enc_alg_id);
//OAILOG_STREAM_HEX(OAILOG_LEVEL_TRACE, LOG_NAS, "s:", s, 7);
//OAILOG_STREAM_HEX(OAILOG_LEVEL_TRACE, LOG_NAS, "kasme_32:", kasme_32, 32);
kdf
(
kasme_32
,
32
,
&
s
[
0
],
7
,
&
out
[
0
],
32
);
memcpy
(
knas
,
&
out
[
31
-
16
+
1
],
16
);
kdf
(
kasme_32
,
32
,
&
s
[
0
],
7
,
&
out
[
0
],
32
);
memcpy
(
knas
,
&
out
[
31
-
16
+
1
],
16
);
return
0
;
}
src/nas/security/key_nas_encryption.c
View file @
f4ad53db
...
...
@@ -23,47 +23,47 @@
#include "secu_defs.h"
/*!
Derive the kNASenc from kasme and perform truncate on the generated key to
reduce his size to 128 bits. Definition of the derivation function can
be found in 3GPP TS.33401 #A.7
@param[in] nas_alg_type NAS algorithm distinguisher
@param[in] nas_enc_alg_id NAS encryption/integrity algorithm identifier.
Possible values are:
- 0 for EIA0 algorithm (Null Integrity Protection algorithm)
- 1 for 128-EIA1 SNOW 3G
- 2 for 128-EIA2 AES
@param[in] kasme Key for MME as provided by AUC
@param[out] knas Truncated ouput key as derived by KDF
*/
Derive the kNASenc from kasme and perform truncate on the generated key to
reduce his size to 128 bits. Definition of the derivation function can
be found in 3GPP TS.33401 #A.7
@param[in] nas_alg_type NAS algorithm distinguisher
@param[in] nas_enc_alg_id NAS encryption/integrity algorithm identifier.
Possible values are:
- 0 for EIA0 algorithm (Null Integrity Protection algorithm)
- 1 for 128-EIA1 SNOW 3G
- 2 for 128-EIA2 AES
@param[in] kasme Key for MME as provided by AUC
@param[out] knas Truncated ouput key as derived by KDF
*/
/*int derive_key_nas(algorithm_type_dist_t nas_alg_type, uint8_t nas_enc_alg_id,
const uint8_t kasme[32], uint8_t** knas)
{
uint8_t s[7];
uint8_t knas_temp[32];
const uint8_t kasme[32], uint8_t** knas)
{
uint8_t s[7];
uint8_t knas_temp[32];
// FC
s[0] = 0x15;
// FC
s[0] = 0x15;
// P0 = algorithm type distinguisher
s[1] = nas_alg_type & 0xFF;
// P0 = algorithm type distinguisher
s[1] = nas_alg_type & 0xFF;
// L0 = length(P0) = 1
s[2] = 0x00;
s[3] = 0x01;
// L0 = length(P0) = 1
s[2] = 0x00;
s[3] = 0x01;
// P1
s[4] = nas_enc_alg_id;
// P1
s[4] = nas_enc_alg_id;
// L1 = length(P1) = 1
s[5] = 0x00;
s[6] = 0x01;
// L1 = length(P1) = 1
s[5] = 0x00;
s[6] = 0x01;
kdf((uint8_t*)kasme, 32, s, 7, (uint8_t**)&knas_temp, 32);
kdf((uint8_t*)kasme, 32, s, 7, (uint8_t**)&knas_temp, 32);
// Truncate the generate key to 128 bits
memcpy(knas, knas_temp, 16);
// Truncate the generate key to 128 bits
memcpy(knas, knas_temp, 16);
return 0;
}
*/
return 0;
}
*/
src/nas/securityDef.h
View file @
f4ad53db
...
...
@@ -21,19 +21,12 @@
/*****************************************************************************
Source securityDef.h
Version 0.1
Date 2013/05/02
Product NAS stack
Subsystem include
Author Frederic Maurel
Description Contains global security definitions
*****************************************************************************/
#ifndef FILE_SECURITYDEF_SEEN
#define FILE_SECURITYDEF_SEEN
...
...
src/nas/sm/msg/PDUSessionAuthenticationCommand.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionAuthenticationCommand.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONAUTHENTICATIONCOMMAND_H_
#define _PDUSESSIONAUTHENTICATIONCOMMAND_H_
...
...
src/nas/sm/msg/PDUSessionAuthenticationComplete.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionAuthenticationComplete.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONAUTHENTICATIONCOMPLETE_H_
#define _PDUSESSIONAUTHENTICATIONCOMPLETE_H_
...
...
src/nas/sm/msg/PDUSessionAuthenticationResult.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionAuthenticationResult.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONAUTHENTICATIONRESULT_H_
#define _PDUSESSIONAUTHENTICATIONRESULT_H_
...
...
src/nas/sm/msg/PDUSessionEstablishmentAccept.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -197,7 +218,7 @@ int encode_pdu_session_establishment_accept(
return
encoded_result
;
else
encoded
+=
encoded_result
;
//TODO: In Wireshark Version 3.2.2 (Git commit a3efece3d640), SSC Mode (4 bit) + PDU sessi
i
on type (4 bit) = 1 byte,
//TODO: In Wireshark Version 3.2.2 (Git commit a3efece3d640), SSC Mode (4 bit) + PDU session type (4 bit) = 1 byte,
//so disable encode SSC Mode for the moment, Should be verified later
/* if((encoded_result = encode_ssc_mode (pdu_session_establishment_accept->sscmode, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
...
...
src/nas/sm/msg/PDUSessionEstablishmentAccept.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONESTABLISHMENTACCEPT_H_
#define _PDUSESSIONESTABLISHMENTACCEPT_H_
...
...
src/nas/sm/msg/PDUSessionEstablishmentReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionEstablishmentReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONESTABLISHMENTREJECT_H_
#define _PDUSESSIONESTABLISHMENTREJECT_H_
...
...
src/nas/sm/msg/PDUSessionEstablishmentRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionEstablishmentRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONESTABLISHMENTREQUEST_H_
#define _PDUSESSIONESTABLISHMENTREQUEST_H_
...
...
src/nas/sm/msg/PDUSessionModificationCommand.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionModificationCommand.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONMODIFICATIONCOMMAND_H_
#define _PDUSESSIONMODIFICATIONCOMMAND_H_
...
...
src/nas/sm/msg/PDUSessionModificationCommandReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionModificationCommandReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONMODIFICATIONCOMMANDREJECT_H_
#define _PDUSESSIONMODIFICATIONCOMMANDREJECT_H_
...
...
src/nas/sm/msg/PDUSessionModificationComplete.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionModificationComplete.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONMODIFICATIONCOMPLETE_H_
#define _PDUSESSIONMODIFICATIONCOMPLETE_H_
...
...
src/nas/sm/msg/PDUSessionModificationReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionModificationReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONMODIFICATIONREJECT_H_
#define _PDUSESSIONMODIFICATIONREJECT_H_
...
...
src/nas/sm/msg/PDUSessionModificationRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionModificationRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONMODIFICATIONREQUEST_H_
#define _PDUSESSIONMODIFICATIONREQUEST_H_
...
...
src/nas/sm/msg/PDUSessionReleaseCommand.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionReleaseCommand.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONRELEASECOMMAND_H_
#define _PDUSESSIONRELEASECOMMAND_H_
...
...
src/nas/sm/msg/PDUSessionReleaseComplete.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionReleaseComplete.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONRELEASECOMPLETE_H_
#define _PDUSESSIONRELEASECOMPLETE_H_
...
...
src/nas/sm/msg/PDUSessionReleaseReject.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionReleaseReject.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONRELEASEREJECT_H_
#define _PDUSESSIONRELEASEREJECT_H_
...
...
src/nas/sm/msg/PDUSessionReleaseRequest.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/PDUSessionReleaseRequest.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _PDUSESSIONRELEASEREQUEST_H_
#define _PDUSESSIONRELEASEREQUEST_H_
...
...
src/nas/sm/msg/_5GSMStatus.c
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
src/nas/sm/msg/_5GSMStatus.h
View file @
f4ad53db
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __5GSMSTATUS_H_
#define __5GSMSTATUS_H_
...
...
src/nas/sm/smMsgDef.h
View file @
f4ad53db
...
...
@@ -19,8 +19,12 @@
* contact@openairinterface.org
*/
#ifndef SM_MSG_DEF_H_
#define SM_MSG_DEF_H_
#include <stdint.h>
#include <asm/byteorder.h>
typedef
struct
{
uint8_t
extended_protocol_discriminator
;
uint8_t
pdu_session_identity
;
...
...
@@ -28,3 +32,4 @@ typedef struct {
uint8_t
message_type
;
}
__attribute__
((
__packed__
))
sm_msg_header_t
;
#endif
src/nas/sm/sm_msg.h
View file @
f4ad53db
...
...
@@ -26,22 +26,18 @@
#include "PDUSessionEstablishmentRequest.h"
#include "PDUSessionEstablishmentAccept.h"
#include "PDUSessionEstablishmentReject.h"
#include "PDUSessionAuthenticationCommand.h"
#include "PDUSessionAuthenticationComplete.h"
#include "PDUSessionAuthenticationResult.h"
#include "PDUSessionModificationRequest.h"
#include "PDUSessionModificationReject.h"
#include "PDUSessionModificationComplete.h"
#include "PDUSessionModificationCommand.h"
#include "PDUSessionModificationCommandReject.h"
#include "PDUSessionReleaseRequest.h"
#include "PDUSessionReleaseReject.h"
#include "PDUSessionReleaseCommand.h"
#include "PDUSessionReleaseComplete.h"
#include "_5GSMStatus.h"
typedef
union
{
...
...
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