renamed openair-cn to openair3

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7886 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
gauthier
2015-10-06 16:53:42 +00:00
parent c7518ecf42
commit 7b5431a62c
705 changed files with 206 additions and 208 deletions
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
+22
View File
@@ -0,0 +1,22 @@
ifndef PROJDIR
PROJDIR = $(PWD)/../../..
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR) -I$(EMMMSGDIR) -I$(ESMMSGDIR)
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
all: $(OBJS)
%.o: %.c Makefile
@echo Compiling $<
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
$(RM) $(OBJS) *.bak *~
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
@@ -0,0 +1,374 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source as_message.c
Version 0.1
Date 2012/11/06
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines the messages supported by the Access Stratum sublayer
protocol (usually RRC and S1AP for E-UTRAN) and functions used
to encode and decode
*****************************************************************************/
#include "as_message.h"
#include "commonDef.h"
#include "nas_log.h"
#include <string.h> // memcpy
#include <stdlib.h> // free
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: as_message_decode() **
** **
** Description: Decode AS message and accordingly fills data structure **
** **
** Inputs: buffer: Pointer to the buffer containing the **
** message **
** length: Number of bytes that should be decoded **
** Others: None **
** **
** Outputs: msg: AS message structure to be filled **
** Return: The AS message identifier when the buffer **
** has been successfully decoded; **
** RETURNerror otherwise. **
** Others: None **
** **
***************************************************************************/
int as_message_decode(const char* buffer, as_message_t* msg, int length)
{
LOG_FUNC_IN;
int bytes;
Byte_t** data = NULL;
/* Get the message type */
msg->msgID = *(uint16_t*)(buffer);
bytes = sizeof(uint16_t);
switch (msg->msgID) {
case AS_NAS_ESTABLISH_REQ:
/* NAS signalling connection establish request */
bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_req.initialNasMsg.data;
break;
case AS_NAS_ESTABLISH_IND:
/* NAS signalling connection establishment indication */
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_ind.initialNasMsg.data;
break;
case AS_NAS_ESTABLISH_RSP:
/* NAS signalling connection establishment response */
bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_rsp.nasMsg.data;
break;
case AS_NAS_ESTABLISH_CNF:
/* NAS signalling connection establishment confirm */
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_cnf.nasMsg.data;
break;
case AS_UL_INFO_TRANSFER_REQ:
/* Uplink L3 data transfer request */
bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*);
data = &msg->msg.ul_info_transfer_req.nasMsg.data;
break;
case AS_UL_INFO_TRANSFER_IND:
/* Uplink L3 data transfer indication */
bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*);
data = &msg->msg.ul_info_transfer_ind.nasMsg.data;
break;
case AS_DL_INFO_TRANSFER_REQ:
/* Downlink L3 data transfer request */
bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*);
data = &msg->msg.dl_info_transfer_req.nasMsg.data;
break;
case AS_DL_INFO_TRANSFER_IND:
/* Downlink L3 data transfer indication */
bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*);
data = &msg->msg.dl_info_transfer_ind.nasMsg.data;
break;
case AS_BROADCAST_INFO_IND:
case AS_CELL_INFO_REQ:
case AS_CELL_INFO_CNF:
case AS_CELL_INFO_IND:
case AS_PAGING_REQ:
case AS_PAGING_IND:
case AS_NAS_RELEASE_REQ:
case AS_UL_INFO_TRANSFER_CNF:
case AS_DL_INFO_TRANSFER_CNF:
case AS_NAS_RELEASE_IND:
case AS_RAB_ESTABLISH_REQ:
case AS_RAB_ESTABLISH_IND:
case AS_RAB_ESTABLISH_RSP:
case AS_RAB_ESTABLISH_CNF:
case AS_RAB_RELEASE_REQ:
case AS_RAB_RELEASE_IND:
/* Messages without dedicated NAS information */
bytes = length;
break;
default:
bytes = 0;
LOG_TRACE(WARNING, "NET-API - AS message 0x%x is not valid",
msg->msgID);
break;
}
if (bytes > 0) {
if (data) {
/* Set the pointer to dedicated NAS information */
*data = (Byte_t*)(buffer + bytes);
}
/* Decode the message */
memcpy(msg, (as_message_t*)buffer, bytes);
LOG_FUNC_RETURN (msg->msgID);
}
LOG_TRACE(WARNING, "NET-API - Failed to decode AS message 0x%x",
msg->msgID);
LOG_FUNC_RETURN (RETURNerror);
}
/****************************************************************************
** **
** Name: as_message_encode() **
** **
** Description: Encode AS message **
** **
** Inputs: msg: AS 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 characters in the buffer **
** when data have been successfully encoded; **
** RETURNerror otherwise. **
** Others: None **
** **
***************************************************************************/
int as_message_encode(char* buffer, as_message_t* msg, int length)
{
LOG_FUNC_IN;
int bytes = sizeof(msg->msgID);
as_nas_info_t* nas_msg = NULL;
switch (msg->msgID) {
case AS_BROADCAST_INFO_IND:
/* Broadcast information */
bytes += sizeof(broadcast_info_ind_t);
break;
case AS_CELL_INFO_REQ:
/* Cell information request */
bytes += sizeof(cell_info_req_t);
break;
case AS_CELL_INFO_CNF:
/* Cell information response */
bytes += sizeof(cell_info_cnf_t);
break;
case AS_CELL_INFO_IND:
/* Cell information indication */
bytes += sizeof(cell_info_ind_t);
break;
case AS_PAGING_REQ:
/* Paging information request */
bytes += sizeof(paging_req_t);
break;
case AS_PAGING_IND:
/* Paging information indication */
bytes += sizeof(paging_ind_t);
break;
case AS_NAS_ESTABLISH_REQ:
/* NAS signalling connection establish request */
bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_req.initialNasMsg;
break;
case AS_NAS_ESTABLISH_IND:
/* NAS signalling connection establish indication */
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_ind.initialNasMsg;
break;
case AS_NAS_ESTABLISH_RSP:
/* NAS signalling connection establish response */
bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_rsp.nasMsg;
break;
case AS_NAS_ESTABLISH_CNF:
/* NAS signalling connection establish confirm */
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_cnf.nasMsg;
break;
case AS_NAS_RELEASE_REQ:
/* NAS signalling connection release request */
bytes += sizeof(nas_release_req_t);
break;
case AS_NAS_RELEASE_IND:
/* NAS signalling connection release indication */
bytes += sizeof(nas_release_ind_t);
break;
case AS_UL_INFO_TRANSFER_REQ:
/* Uplink L3 data transfer request */
bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.ul_info_transfer_req.nasMsg;
break;
case AS_UL_INFO_TRANSFER_CNF:
/* Uplink L3 data transfer confirm */
bytes += sizeof(ul_info_transfer_cnf_t);
break;
case AS_UL_INFO_TRANSFER_IND:
/* Uplink L3 data transfer indication */
bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.ul_info_transfer_ind.nasMsg;
break;
case AS_DL_INFO_TRANSFER_REQ:
/* Downlink L3 data transfer */
bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.dl_info_transfer_req.nasMsg;
break;
case AS_DL_INFO_TRANSFER_CNF:
/* Downlink L3 data transfer confirm */
bytes += sizeof(dl_info_transfer_cnf_t);
break;
case AS_DL_INFO_TRANSFER_IND:
/* Downlink L3 data transfer indication */
bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.dl_info_transfer_ind.nasMsg;
break;
case AS_RAB_ESTABLISH_REQ:
/* Radio Access Bearer establishment request */
bytes += sizeof(rab_establish_req_t);
break;
case AS_RAB_ESTABLISH_IND:
/* Radio Access Bearer establishment indication */
bytes += sizeof(rab_establish_ind_t);
break;
case AS_RAB_ESTABLISH_RSP:
/* Radio Access Bearer establishment response */
bytes += sizeof(rab_establish_rsp_t);
break;
case AS_RAB_ESTABLISH_CNF:
/* Radio Access Bearer establishment confirm */
bytes += sizeof(rab_establish_cnf_t);
break;
case AS_RAB_RELEASE_REQ:
/* Radio Access Bearer release request */
bytes += sizeof(rab_release_req_t);
break;
case AS_RAB_RELEASE_IND:
/* Radio Access Bearer release indication */
bytes += sizeof(rab_release_ind_t);
break;
default:
LOG_TRACE(WARNING, "NET-API - AS message 0x%x is not valid",
msg->msgID);
bytes = length;
break;
}
if (length > bytes) {
/* Encode the AS message */
memcpy(buffer, (unsigned char*)msg, bytes);
if ( nas_msg && (nas_msg->length > 0) ) {
/* Copy the NAS message */
memcpy(buffer + bytes, nas_msg->data, nas_msg->length);
bytes += nas_msg->length;
/* Release NAS message memory */
free(nas_msg->data);
nas_msg->length = 0;
nas_msg->data = NULL;
}
LOG_FUNC_RETURN (bytes);
}
LOG_TRACE(WARNING, "NET-API - Failed to encode AS message 0x%x",
msg->msgID);
LOG_FUNC_RETURN (RETURNerror);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
+1
View File
@@ -0,0 +1 @@
../../../../../openair2/COMMON/as_message.h
@@ -0,0 +1,309 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source as_message.h
Version 0.1
Date 2012/10/18
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines the messages supported by the Access Stratum sublayer
protocol (usually RRC and S1AP for E-UTRAN) and functions used
to encode and decode
*****************************************************************************/
#ifndef __AS_MESSAGE_H__
#define __AS_MESSAGE_H__
#include "commonDef.h"
#include "networkDef.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/* Access Stratum Message types */
#define AS_REQUEST 0x0100
#define AS_RESPONSE 0x0200
#define AS_INDICATION 0x0400
#define AS_CONFIRM 0x0800
/*
* Access Stratum Message identifiers
* ----------------------------------
*/
/* Cell information relevant for cell selection processing */
#define AS_CELL_INFO 0x01
#define AS_CELL_INFO_REQ (AS_CELL_INFO | AS_REQUEST)
#define AS_CELL_INFO_RSP (AS_CELL_INFO | AS_RESPONSE)
#define AS_CELL_INFO_IND (AS_CELL_INFO | AS_INDICATION)
/* Security mode control */
#define AS_SECURITY 0x02
#define AS_SECURITY_REQ (AS_SECURITY | AS_REQUEST)
#define AS_SECURITY_RSP (AS_SECURITY | AS_RESPONSE)
/* Paging information */
#define AS_PAGING 0x03
#define AS_PAGING_IND (AS_PAGING | AS_INDICATION)
/* NAS signalling connection establishment */
#define AS_NAS_ESTABLISH 0x04
#define AS_NAS_ESTABLISH_REQ (AS_NAS_ESTABLISH | AS_REQUEST)
#define AS_NAS_ESTABLISH_RSP (AS_NAS_ESTABLISH | AS_RESPONSE)
/* NAS signalling connection release */
#define AS_NAS_RELEASE 0x05
#define AS_NAS_RELEASE_REQ (AS_NAS_RELEASE | AS_REQUEST)
#define AS_NAS_RELEASE_IND (AS_NAS_RELEASE | AS_INDICATION)
/* NAS information transfer */
#define AS_INFO_TRANSFER 0x10
#define AS_UL_INFO_TRANSFER (AS_INFO_TRANSFER | AS_REQUEST)
#define AS_DL_INFO_TRANSFER (AS_INFO_TRANSFER | AS_INDICATION)
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* --------------------------------------------------------------------------
* Available PLMNs and cell Information
* --------------------------------------------------------------------------
*/
/* Radio access technologies supported by the network */
#define AS_GSM (1 << NET_ACCESS_GSM)
#define AS_COMPACT (1 << NET_ACCESS_COMPACT)
#define AS_UTRAN (1 << NET_ACCESS_UTRAN)
#define AS_EGPRS (1 << NET_ACCESS_EGPRS)
#define AS_HSDPA (1 << NET_ACCESS_HSDPA)
#define AS_HSUPA (1 << NET_ACCESS_HSUPA)
#define AS_HSDUPA (1 << NET_ACCESS_HSDUPA)
#define AS_EUTRAN (1 << NET_ACCESS_EUTRAN)
/*
* NAS->AS - Cell Information request
* NAS request AS to search for a suitable cell belonging to the selected
* PLMN to camp on.
*/
typedef struct {
plmn_t plmnID; /* PLMN identifier */
Byte_t rat; /* Bitmap - set of radio access technologies */
} cell_info_req_t;
/*
* AS->NAS - Cell Information response
* AS search for a suitable cell and respond to NAS. If found, the cell
* is selected to camp on.
*/
typedef struct {
plmn_t plmnID; /* PLMN identifier */
TAC_t tac; /* identifies a tracking area the PLMN belongs to */
CI_t cellID; /* identifies a cell within a PLMN */
AcT_t rat; /* radio access technology supported by the cell */
} cell_info_rsp_t;
/*
* AS->NAS - Cell Information indication
* AS Reports available PLMNs with associated Radio Access Technologies
* to NAS on request from NAS or autonomously.
*/
typedef struct {
#define PLMN_LIST_MAX_SIZE 6
PLMN_LIST_T(PLMN_LIST_MAX_SIZE) plmnIDs; /* List of PLMN identifiers */
Byte_t rat[PLMN_LIST_MAX_SIZE]; /* Radio access technologies */
TAC_t tac; /* identifies a tracking area within a scope of PLMNs */
CI_t cellID; /* identifies a cell within a PLMN */
} cell_info_ind_t;
/*
* --------------------------------------------------------------------------
* Security mode control
* --------------------------------------------------------------------------
*/
/*
* TODO: NAS->AS - Security command request
*/
typedef struct {} security_req_t;
/*
* TODO: AS->NAS - Security command response
*/
typedef struct {} security_rsp_t;
/*
* --------------------------------------------------------------------------
* Paging information
* --------------------------------------------------------------------------
*/
/*
* TODO: AS->NAS - Paging Information indication
*/
typedef struct {} paging_ind_t;
/*
* --------------------------------------------------------------------------
* NAS signalling connection establishment
* --------------------------------------------------------------------------
*/
/* Cause of RRC connection establishment */
#define AS_CAUSE_EMERGENCY (NET_ESTABLISH_CAUSE_EMERGENCY)
#define AS_CAUSE_HIGH_PRIO (NET_ESTABLISH_CAUSE_HIGH_PRIO)
#define AS_CAUSE_MT_ACCESS (NET_ESTABLISH_CAUSE_MT_ACCESS)
#define AS_CAUSE_MO_SIGNAL (NET_ESTABLISH_CAUSE_MO_SIGNAL)
#define AS_CAUSE_MO_DATA (NET_ESTABLISH_CAUSE_MO_DATA)
#define AS_CAUSE_V1020 (NET_ESTABLISH_CAUSE_V1020)
/* Type of the call associated to the RRC connection establishment */
#define AS_TYPE_ORIGINATING_SIGNAL (NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL)
#define AS_TYPE_EMERGENCY_CALLS (NET_ESTABLISH_TYPE_EMERGENCY_CALLS)
#define AS_TYPE_ORIGINATING_CALLS (NET_ESTABLISH_TYPE_ORIGINATING_CALLS)
#define AS_TYPE_TERMINATING_CALLS (NET_ESTABLISH_TYPE_TERMINATING_CALLS)
#define AS_TYPE_MO_CS_FALLBACK (NET_ESTABLISH_TYPE_MO_CS_FALLBACK)
/* Structure of the SAE Temporary Mobile Subscriber Identity */
typedef struct {
uint8_t MMEcode; /* MME code that allocated the GUTI */
uint32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */
} as_stmsi_t;
/* Structure of the dedicated NAS information */
typedef struct {
uint32_t length; /* Length of the NAS information data */
Byte_t* data; /* Dedicated NAS information data container */
} as_nas_info_t;
/*
* NAS->AS - NAS signalling connection establishment request
* NAS request AS to perform the RRC connection establishment procedure
* to transfer initial NAS message to the network while UE is in IDLE mode.
*/
typedef struct {
uint8_t cause; /* Connection establishment cause */
uint8_t type; /* Associated call type */
plmn_t plmnID; /* Identifier of the selected PLMN */
as_stmsi_t s_tmsi; /* SAE Temporary Mobile Subscriber Identity */
as_nas_info_t initialNasMsg;/* Initial NAS message to transfer */
} nas_establish_req_t;
/*
* TODO: AS->NAS - NAS signalling connection establishment response
*/
typedef struct {} nas_establish_rsp_t;
/*
* --------------------------------------------------------------------------
* NAS signalling connection release
* --------------------------------------------------------------------------
*/
/*
* TODO: NAS->AS - NAS signalling connection release request
*/
typedef struct {} nas_release_req_t;
/*
* TODO: AS->NAS - NAS signalling connection release indication
*/
typedef struct {} nas_release_ind_t;
/*
* --------------------------------------------------------------------------
* NAS information transfer
* --------------------------------------------------------------------------
*/
/*
* AS->NAS - Downlink data transfer
* AS notifies upper layer that NAS or non-3GPP dedicated downlink information
* has to be transfered to NAS.
*/
typedef as_nas_info_t dl_info_transfer_t;
/*
* NAS->AS - Uplink data transfer request
* NAS requests under layer to transfer NAS or non-3GPP dedicated uplink
* information to AS.
*/
typedef as_nas_info_t ul_info_transfer_t;
/*
* --------------------------------------------------------------------------
* Structure of the AS messages handled by the network sublayer
* --------------------------------------------------------------------------
*/
typedef struct {
uint16_t msgID;
union {
cell_info_req_t cell_info_req;
cell_info_rsp_t cell_info_rsp;
cell_info_ind_t cell_info_ind;
security_req_t security_req;
security_rsp_t security_rsp;
paging_ind_t paging_ind;
nas_establish_req_t nas_establish_req;
nas_establish_rsp_t nas_establish_rsp;
nas_release_req_t nas_release_req;
nas_release_ind_t nas_release_ind;
ul_info_transfer_t ul_info_transfer;
dl_info_transfer_t dl_info_transfer;
} __attribute__((__packed__)) msg;
} as_message_t;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int as_message_decode(const char* buffer, int length, as_message_t* msg);
int as_message_encode(char* buffer, int length, const as_message_t* msg);
/* Implemented in the network_api.c body file */
int as_message_send(as_message_t* as_msg, const void* nas_msg);
#endif /* __AS_MESSAGE_H__*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,135 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source nas_message.h
Version 0.1
Date 2012/26/09
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Defines the layer 3 messages supported by the NAS sublayer
protocol and functions used to encode and decode
*****************************************************************************/
#ifndef __NAS_MESSAGE_H__
#define __NAS_MESSAGE_H__
#include "commonDef.h"
#include "emm_msg.h"
#if defined(NAS_BUILT_IN_EPC)
#include "emmData.h"
#endif
#include "esm_msg.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 6
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/* Structure of security protected header */
typedef struct {
#ifdef __LITTLE_ENDIAN_BITFIELD
eps_protocol_discriminator_t protocol_discriminator:4;
uint8_t security_header_type:4;
#endif
#ifdef __BIG_ENDIAN_BITFIELD
uint8_t security_header_type:4;
uint8_t protocol_discriminator:4;
#endif
uint32_t message_authentication_code;
uint8_t sequence_number;
} nas_message_security_header_t;
/* Structure of plain NAS message */
typedef union {
EMM_msg emm; /* EPS Mobility Management messages */
ESM_msg esm; /* EPS Session Management messages */
} nas_message_plain_t;
/* Structure of security protected NAS message */
typedef struct {
nas_message_security_header_t header;
nas_message_plain_t plain;
} nas_message_security_protected_t;
/*
* Structure of a layer 3 NAS message
*/
typedef union {
nas_message_security_header_t header;
nas_message_security_protected_t security_protected;
nas_message_plain_t plain;
} nas_message_t;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int nas_message_encrypt(
const char *inbuf,
char *outbuf,
const nas_message_security_header_t *header,
int length,
void *security);
int nas_message_decrypt(const char *inbuf,
char *outbuf,
nas_message_security_header_t *header,
int length,
void *security);
int nas_message_decode(
const char * const buffer,
nas_message_t *msg,
int length,
void *security);
int nas_message_encode(
char *buffer,
const nas_message_t * const msg,
int length,
void *security);
#endif /* __NAS_MESSAGE_H__*/
@@ -0,0 +1,447 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source network_api.c
Version 0.1
Date 2012/03/01
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Implements the API used by the NAS layer to send/receive
message to/from the network sublayer
*****************************************************************************/
#include "network_api.h"
#include "commonDef.h"
#include "nas_log.h"
#include "socket.h"
#include "as_message.h"
#include <string.h> // strerror, memset
#include <netdb.h> // gai_strerror
#include <errno.h> // errno
#include <unistd.h> // gethostname
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
/* -------------------
* Connection endpoint
* -------------------
* The connection endpoint is used to send/receive data to/from the
* network sublayer. Its definition depends on the underlaying mechanism
* chosen to communicate (network socket, I/O terminal device, async FIFO).
* A connection endpoint is handled using an identifier, and functions
* used to retreive the file descriptor actually allocated by the system,
* to receive data, to send data, and to perform clean up when connection
* is shut down.
* Only one single end to end connection with the network sublayer is
* managed at a time.
*/
static struct {
/* Connection endpoint reference */
void* endpoint;
/* Connection endpoint handlers */
void* (*open) (int, const char*, const char*);
int (*getfd)(const void*);
ssize_t (*recv) (void*, char*, size_t);
ssize_t (*send) (const void*, const char*, size_t);
void (*close)(void*);
} _network_api_id;
#define NETWORK_API_OPEN(a, b, c) _network_api_id.open(a, b, c)
#define NETWORK_API_GETFD() _network_api_id.getfd(_network_api_id.endpoint)
#define NETWORK_API_RECV(a, b) _network_api_id.recv(_network_api_id.endpoint, a, b)
#define NETWORK_API_SEND(a, b) _network_api_id.send(_network_api_id.endpoint, a, b)
#define NETWORK_API_CLOSE() _network_api_id.close(_network_api_id.endpoint)
/*
* The buffer used to receive data from the network sublayer
*/
#define NETWORK_API_RECV_BUFFER_SIZE 4096
static char _network_api_recv_buffer[NETWORK_API_RECV_BUFFER_SIZE];
/*
* The buffer used to send data to the network sublayer
*/
#define NETWORK_API_SEND_BUFFER_SIZE NETWORK_API_RECV_BUFFER_SIZE
static char _network_api_send_buffer[NETWORK_API_SEND_BUFFER_SIZE];
/*
* The decoded data received from the network sublayer
*/
static as_message_t _as_data = {}; /* Access Stratum message */
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: network_api_initialize() **
** **
** Description: Initializes the network API from which the NAS layer **
** will send/receive messages to/from the network sublayer **
** **
** Inputs: host: The name of the host from which the net- **
** work sublayer will connect **
** port: The local port number **
** Others: None **
** **
** Outputs: Return: RETURNerror, RETURNok **
** Others: _network_api_id **
** **
***************************************************************************/
int network_api_initialize(const char* host, const char* port)
{
LOG_FUNC_IN;
/* Initialize network socket handlers */
_network_api_id.open = socket_udp_open;
_network_api_id.getfd = socket_get_fd;
_network_api_id.recv = socket_recv;
_network_api_id.send = socket_send;
_network_api_id.close = socket_close;
/* Initialize UDP communication channel with the network layer */
#ifdef NAS_UE
_network_api_id.endpoint = NETWORK_API_OPEN(SOCKET_CLIENT, host, port);
#endif
#ifdef NAS_MME
_network_api_id.endpoint = NETWORK_API_OPEN(SOCKET_SERVER, NULL, port);
#endif
if (_network_api_id.endpoint == NULL) {
const char* error = ( (errno < 0) ?
gai_strerror(errno) : strerror(errno) );
LOG_TRACE(ERROR, "NET-API - Failed to open connection endpoint, %s",
error);
LOG_FUNC_RETURN (RETURNerror);
}
gethostname(_network_api_send_buffer, NETWORK_API_SEND_BUFFER_SIZE);
LOG_TRACE(INFO, "NET-API - Network's UDP socket %d is BOUND to %s/%s",
network_api_get_fd(), _network_api_send_buffer, port);
LOG_FUNC_RETURN (RETURNok);
}
/****************************************************************************
** **
** Name: network_api_get_fd() **
** **
** Description: Get the file descriptor of the connection endpoint used **
** to send/receive messages to/from the network sublayer **
** **
** Inputs: None **
** Others: _network_api_id **
** **
** Outputs: Return: The file descriptor of the connection end- **
** point used by the network sublayer **
** Others: None **
** **
***************************************************************************/
int network_api_get_fd(void)
{
LOG_FUNC_IN;
LOG_FUNC_RETURN (NETWORK_API_GETFD());
}
/****************************************************************************
** **
** Name: network_api_get_data() **
** **
** Description: Get a generic pointer to the network data structure. **
** Casting to the proper type is necessary before its usage. **
** **
** Inputs: None **
** Others: _as_data **
** **
** Outputs: Return: A generic pointer to the network data **
** structure **
** Others: None **
** **
***************************************************************************/
const void* network_api_get_data(void)
{
LOG_FUNC_IN;
LOG_FUNC_RETURN ((void*)(&_as_data));
}
/****************************************************************************
** **
** Name: network_api_read_data() **
** **
** Description: Read data received from the network sublayer **
** **
** Inputs: fd: File descriptor of the connection endpoint **
** from which data have been received **
** Others: _network_api_id **
** **
** Outputs: Return: The number of bytes read when success; **
** RETURNerror otherwise **
** Others: _network_api_recv_buffer, _network_api_id **
** **
***************************************************************************/
int network_api_read_data(int fd)
{
LOG_FUNC_IN;
int rbytes;
/* Sanity check */
int sfd = network_api_get_fd();
if (fd != sfd) {
LOG_TRACE(ERROR, "NET-API - Endpoint %d is not the one created for communication with the network sublayer (%d)", fd, sfd);
LOG_FUNC_RETURN (RETURNerror);
}
memset(_network_api_recv_buffer, 0, NETWORK_API_RECV_BUFFER_SIZE);
/* Receive data from the network sublayer */
rbytes = NETWORK_API_RECV(_network_api_recv_buffer,
NETWORK_API_RECV_BUFFER_SIZE);
if (rbytes == RETURNerror) {
LOG_TRACE(ERROR, "NET-API - recv() failed, %s", strerror(errno));
LOG_FUNC_RETURN (RETURNerror);
} else if (rbytes == 0) {
LOG_TRACE(WARNING, "NET-API - A signal was caught");
} else {
LOG_TRACE(INFO, "NET-API - %d bytes received from the network "
"sublayer", rbytes);
LOG_DUMP(_network_api_recv_buffer, rbytes);
}
LOG_FUNC_RETURN (rbytes);
}
/****************************************************************************
** **
** Name: network_api_send_data() **
** **
** Description: Send data to the network sublayer **
** **
** Inputs: fd: File descriptor of the connection endpoint **
** to which data have to be sent **
** length: Number of bytes to send **
** Others: _network_api_send_buffer, _network_api_id **
** **
** Outputs: Return: The number of bytes sent when success; **
** RETURNerror otherwise **
** Others: None **
** **
***************************************************************************/
int network_api_send_data(int fd, int length)
{
LOG_FUNC_IN;
int sbytes;
/* Sanity check */
int sfd = network_api_get_fd();
if (fd != sfd) {
LOG_TRACE(ERROR, "NET-API - Endpoint %d is not the one created for communication with the network sublayer (%d)", fd, sfd);
LOG_FUNC_RETURN (RETURNerror);
}
/* Send data to the network sublayer */
sbytes = NETWORK_API_SEND(_network_api_send_buffer, length);
if (sbytes == RETURNerror) {
LOG_TRACE(ERROR, "NET-API - send() failed, %s", strerror(errno));
LOG_FUNC_RETURN (RETURNerror);
} else if (sbytes == 0) {
LOG_TRACE(WARNING, "NET-API - A signal was caught");
} else {
LOG_TRACE(INFO, "NET-API - %d bytes sent to the network sublayer",
sbytes);
LOG_DUMP(_network_api_send_buffer, sbytes);
}
LOG_FUNC_RETURN (sbytes);
}
/****************************************************************************
** **
** Name: network_api_close() **
** **
** Description: Clean the network API from which the NAS layer sent/recei-**
** ved messages to/from the network sublayer **
** **
** Inputs: fd: File descriptor of the connection endpoint **
** allocated by the system to communicate **
** with the network sublayer **
** Others: None **
** **
** Outputs: Return: None **
** Others: _network_api_id **
** **
***************************************************************************/
void network_api_close(int fd)
{
LOG_FUNC_IN;
/* Sanity check */
int sfd = network_api_get_fd();
if (fd != sfd) {
LOG_TRACE(ERROR, "NET-API - Endpoint %d is not the one created for communication with the network sublayer (%d)", fd, sfd);
LOG_FUNC_OUT;
return;
}
/* Cleanup the connection endpoint */
NETWORK_API_CLOSE();
_network_api_id.endpoint = NULL;
LOG_FUNC_OUT;
}
/****************************************************************************
** **
** Name: network_api_decode_data() **
** **
** Description: Decodes the message received from the network and fills **
** the corresponding network data structure. **
** **
** Inputs: length: Number of bytes to decode **
** Others: _network_api_recv_buffer **
** **
** Outputs: Return: The identifier of the received AS **
** message when successfully decoded; **
** RETURNerror otherwise **
** Others: _as_data **
** **
***************************************************************************/
int network_api_decode_data(int length)
{
LOG_FUNC_IN;
/* Decode the Access Stratum message received from the network */
int as_id = as_message_decode(_network_api_recv_buffer, &_as_data, length);
if (as_id != RETURNerror) {
LOG_TRACE(INFO, "NET-API - AS message id=0x%x successfully decoded",
as_id);
}
LOG_FUNC_RETURN (as_id);
}
/****************************************************************************
** **
** Name: network_api_encode_data() **
** **
** Description: Encodes Access Stratum message to be sent to the network **
** **
** Inputs data: Generic pointer to the AS data to encode **
** Others: None **
** **
** Outputs: Return: The number of characters that have been **
** successfully encoded; **
** RETURNerror otherwise. **
** Others: _network_api_send_buffer **
** **
***************************************************************************/
int network_api_encode_data(void* data)
{
LOG_FUNC_IN;
/* Encode the Access Stratum message */
int bytes = as_message_encode(_network_api_send_buffer,
(as_message_t*)(data),
NETWORK_API_SEND_BUFFER_SIZE);
if (bytes != RETURNerror) {
LOG_TRACE(INFO, "NET-API - %d bytes encoded", bytes);
}
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************
** **
** Name: as_message_send() **
** **
** Description: Service provided to the EPS Mobility Management protocol **
** at the EMMAS Access Point (EMMAS-SAP) to send AS messages **
** to the Access Stratum sublayer. **
** **
** Inputs: as_msg: The AS message to send **
** Others: _network_api_send_buffer, _network_api_id **
** **
** Outputs: Return: The number of bytes sent when success; **
** RETURNerror Otherwise **
** Others: _network_api_send_buffer **
** **
***************************************************************************/
int as_message_send(as_message_t* as_msg)
{
int bytes;
LOG_FUNC_IN;
LOG_TRACE(INFO, "NET-API - Send message 0x%.4x to the Access Stratum "
"layer", as_msg->msgID);
/* Encode the AS message */
bytes = network_api_encode_data(as_msg);
if (bytes > 0) {
/* Get the network file descriptor */
int fd = network_api_get_fd();
if (fd != RETURNerror) {
/* Send the AS message to the network */
bytes = network_api_send_data(fd, bytes);
}
}
LOG_FUNC_RETURN (bytes);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source network_api.h
Version 0.1
Date 2012/03/01
Product NAS stack
Subsystem Application Programming Interface
Author Frederic Maurel
Description Implements the API used by the NAS layer to send/receive
message to/from the network layer
*****************************************************************************/
#ifndef __NETWORK_API_H__
#define __NETWORK_API_H__
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int network_api_initialize(const char* host, const char* port);
int network_api_get_fd(void);
const void* network_api_get_data(void);
int network_api_read_data(int fd);
int network_api_send_data(int fd, int length);
void network_api_close(int fd);
int network_api_decode_data(int length);
int network_api_encode_data(void* data);
#endif /* __NETWORK_API_H__*/
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
+373
View File
@@ -0,0 +1,373 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AttachAccept.h"
int decode_attach_accept(attach_accept_msg *attach_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, ATTACH_ACCEPT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_eps_attach_result(&attach_accept->epsattachresult, 0, *(buffer + decoded), len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_gprs_timer(&attach_accept->t3412value, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_tracking_area_identity_list(&attach_accept->tailist, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_esm_message_container(&attach_accept->esmmessagecontainer, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ATTACH_ACCEPT_GUTI_IEI:
if ((decoded_result =
decode_eps_mobile_identity(&attach_accept->guti,
ATTACH_ACCEPT_GUTI_IEI, buffer + decoded, len - decoded))
<= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_GUTI_PRESENT;
break;
case ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI:
if ((decoded_result =
decode_location_area_identification(&attach_accept->locationareaidentification,
ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT;
break;
case ATTACH_ACCEPT_MS_IDENTITY_IEI:
if ((decoded_result =
decode_mobile_identity(&attach_accept->msidentity,
ATTACH_ACCEPT_MS_IDENTITY_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_MS_IDENTITY_PRESENT;
break;
case ATTACH_ACCEPT_EMM_CAUSE_IEI:
if ((decoded_result = decode_emm_cause(&attach_accept->emmcause,
ATTACH_ACCEPT_EMM_CAUSE_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_EMM_CAUSE_PRESENT;
break;
case ATTACH_ACCEPT_T3402_VALUE_IEI:
if ((decoded_result =
decode_gprs_timer(&attach_accept->t3402value,
ATTACH_ACCEPT_T3402_VALUE_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_T3402_VALUE_PRESENT;
break;
case ATTACH_ACCEPT_T3423_VALUE_IEI:
if ((decoded_result =
decode_gprs_timer(&attach_accept->t3423value,
ATTACH_ACCEPT_T3423_VALUE_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_T3423_VALUE_PRESENT;
break;
case ATTACH_ACCEPT_EQUIVALENT_PLMNS_IEI:
if ((decoded_result =
decode_plmn_list(&attach_accept->equivalentplmns,
ATTACH_ACCEPT_EQUIVALENT_PLMNS_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_EQUIVALENT_PLMNS_PRESENT;
break;
case ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_IEI:
if ((decoded_result =
decode_emergency_number_list(&attach_accept->emergencynumberlist,
ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_IEI, buffer + decoded,
len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT;
break;
case ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI:
if ((decoded_result =
decode_eps_network_feature_support(&attach_accept->epsnetworkfeaturesupport,
ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT;
break;
case ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI:
if ((decoded_result =
decode_additional_update_result(&attach_accept->additionalupdateresult,
ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_accept->presencemask |= ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_attach_accept(attach_accept_msg *attach_accept, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
LOG_FUNC_IN;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ATTACH_ACCEPT_MINIMUM_LENGTH, len);
*(buffer + encoded) = (encode_u8_eps_attach_result(&attach_accept->epsattachresult) & 0x0f);
encoded++;
#warning "LG TEST override t3412value"
attach_accept->t3412value.unit = GPRS_TIMER_UNIT_360S;
attach_accept->t3412value.timervalue = 10;
if ((encode_result = encode_gprs_timer(&attach_accept->t3412value, 0, buffer
+ encoded, len - encoded)) < 0) { //Return in case of error
LOG_TRACE(WARNING, "Failed encode_gprs_timer");
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
if ((encode_result =
encode_tracking_area_identity_list(&attach_accept->tailist, 0, buffer
+ encoded, len - encoded)) < 0) { //Return in case of error
LOG_TRACE(WARNING, "Failed encode_tracking_area_identity_list");
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
if ((encode_result =
encode_esm_message_container(&attach_accept->esmmessagecontainer, 0,
buffer + encoded, len - encoded)) < 0) { //Return in case of error
LOG_TRACE(WARNING, "Failed encode_esm_message_container");
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
if ((attach_accept->presencemask & ATTACH_ACCEPT_GUTI_PRESENT)
== ATTACH_ACCEPT_GUTI_PRESENT) {
if ((encode_result = encode_eps_mobile_identity(&attach_accept->guti,
ATTACH_ACCEPT_GUTI_IEI, buffer + encoded, len - encoded)) < 0) {
// Return in case of error
LOG_TRACE(WARNING, "Failed encode_eps_mobile_identity");
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT)
== ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT) {
if ((encode_result =
encode_location_area_identification(&attach_accept->locationareaidentification,
ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI, buffer + encoded,
len - encoded)) < 0) {
LOG_TRACE(WARNING, "Failed encode_location_area_identification");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_MS_IDENTITY_PRESENT)
== ATTACH_ACCEPT_MS_IDENTITY_PRESENT) {
if ((encode_result = encode_mobile_identity(&attach_accept->msidentity,
ATTACH_ACCEPT_MS_IDENTITY_IEI, buffer + encoded, len - encoded)) <
0) {
LOG_TRACE(WARNING, "Failed encode_mobile_identity");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_EMM_CAUSE_PRESENT)
== ATTACH_ACCEPT_EMM_CAUSE_PRESENT) {
if ((encode_result = encode_emm_cause(&attach_accept->emmcause,
ATTACH_ACCEPT_EMM_CAUSE_IEI, buffer + encoded, len - encoded)) <
0) {
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
#warning "LG TEST override t3402value"
attach_accept->presencemask |= ATTACH_ACCEPT_T3402_VALUE_PRESENT;
attach_accept->t3402value.unit = GPRS_TIMER_UNIT_60S;
attach_accept->t3402value.timervalue = 12;
if ((attach_accept->presencemask & ATTACH_ACCEPT_T3402_VALUE_PRESENT)
== ATTACH_ACCEPT_T3402_VALUE_PRESENT) {
if ((encode_result = encode_gprs_timer(&attach_accept->t3402value,
ATTACH_ACCEPT_T3402_VALUE_IEI, buffer + encoded, len - encoded)) <
0) {
LOG_TRACE(WARNING, "Failed encode_gprs_timer");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_T3423_VALUE_PRESENT)
== ATTACH_ACCEPT_T3423_VALUE_PRESENT) {
if ((encode_result = encode_gprs_timer(&attach_accept->t3423value,
ATTACH_ACCEPT_T3423_VALUE_IEI, buffer + encoded, len - encoded)) <
0) {
LOG_TRACE(WARNING, "Failed encode_gprs_timer");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_EQUIVALENT_PLMNS_PRESENT)
== ATTACH_ACCEPT_EQUIVALENT_PLMNS_PRESENT) {
if ((encode_result = encode_plmn_list(&attach_accept->equivalentplmns,
ATTACH_ACCEPT_EQUIVALENT_PLMNS_IEI, buffer + encoded, len -
encoded)) < 0) {
LOG_TRACE(WARNING, "Failed encode_plmn_list");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT)
== ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT) {
if ((encode_result =
encode_emergency_number_list(&attach_accept->emergencynumberlist,
ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_IEI, buffer + encoded, len -
encoded)) < 0) {
LOG_TRACE(WARNING, "Failed encode_emergency_number_list");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT)
== ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT) {
if ((encode_result =
encode_eps_network_feature_support(&attach_accept->epsnetworkfeaturesupport,
ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI, buffer + encoded,
len - encoded)) < 0) {
LOG_TRACE(WARNING, "Failed encode_eps_network_feature_support");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
if ((attach_accept->presencemask & ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT)
== ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT) {
if ((encode_result =
encode_additional_update_result(&attach_accept->additionalupdateresult,
ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI, buffer + encoded, len
- encoded)) < 0) {
LOG_TRACE(WARNING, "Failed encode_additional_update_result");
// Return in case of error
LOG_FUNC_RETURN(encode_result);
} else
encoded += encode_result;
}
LOG_FUNC_RETURN(encoded);
}
+138
View File
@@ -0,0 +1,138 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EpsAttachResult.h"
#include "GprsTimer.h"
#include "TrackingAreaIdentityList.h"
#include "EsmMessageContainer.h"
#include "EpsMobileIdentity.h"
#include "LocationAreaIdentification.h"
#include "MobileIdentity.h"
#include "EmmCause.h"
#include "PlmnList.h"
#include "EmergencyNumberList.h"
#include "EpsNetworkFeatureSupport.h"
#include "AdditionalUpdateResult.h"
#ifndef ATTACH_ACCEPT_H_
#define ATTACH_ACCEPT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ATTACH_ACCEPT_MINIMUM_LENGTH ( \
EPS_ATTACH_RESULT_MINIMUM_LENGTH + \
GPRS_TIMER_MINIMUM_LENGTH + \
TRACKING_AREA_IDENTITY_LIST_MINIMUM_LENGTH + \
ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ATTACH_ACCEPT_MAXIMUM_LENGTH ( \
EPS_ATTACH_RESULT_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH + \
TRACKING_AREA_IDENTITY_LIST_MAXIMUM_LENGTH + \
ESM_MESSAGE_CONTAINER_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
LOCATION_AREA_IDENTIFICATION_MAXIMUM_LENGTH + \
MOBILE_IDENTITY_MAXIMUM_LENGTH + \
EMM_CAUSE_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH + \
PLMN_LIST_MAXIMUM_LENGTH + \
EMERGENCY_NUMBER_LIST_MAXIMUM_LENGTH + \
EPS_NETWORK_FEATURE_SUPPORT_MAXIMUM_LENGTH + \
ADDITIONAL_UPDATE_RESULT_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ATTACH_ACCEPT_GUTI_PRESENT (1<<0)
# define ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT (1<<1)
# define ATTACH_ACCEPT_MS_IDENTITY_PRESENT (1<<2)
# define ATTACH_ACCEPT_EMM_CAUSE_PRESENT (1<<3)
# define ATTACH_ACCEPT_T3402_VALUE_PRESENT (1<<4)
# define ATTACH_ACCEPT_T3423_VALUE_PRESENT (1<<5)
# define ATTACH_ACCEPT_EQUIVALENT_PLMNS_PRESENT (1<<6)
# define ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT (1<<7)
# define ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT (1<<8)
# define ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT (1<<9)
typedef enum attach_accept_iei_tag {
ATTACH_ACCEPT_GUTI_IEI = 0x50, /* 0x50 = 80 */
ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI = 0x13, /* 0x13 = 19 */
ATTACH_ACCEPT_MS_IDENTITY_IEI = 0x23, /* 0x23 = 35 */
ATTACH_ACCEPT_EMM_CAUSE_IEI = 0x53, /* 0x53 = 83 */
ATTACH_ACCEPT_T3402_VALUE_IEI = 0x17, /* 0x17 = 23 */
ATTACH_ACCEPT_T3423_VALUE_IEI = 0x59, /* 0x59 = 89 */
ATTACH_ACCEPT_EQUIVALENT_PLMNS_IEI = 0x4A, /* 0x4A = 74 */
ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_IEI = 0x34, /* 0x34 = 52 */
ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI = 0x64, /* 0x64 = 100 */
ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI = 0xF0, /* 0xF0 = 240 */
} attach_accept_iei;
/*
* Message name: Attach accept
* Description: This message is sent by the network to the UE to indicate that the corresponding attach request has been accepted. See table 8.2.1.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct attach_accept_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EpsAttachResult epsattachresult;
GprsTimer t3412value;
TrackingAreaIdentityList tailist;
EsmMessageContainer esmmessagecontainer;
/* Optional fields */
uint32_t presencemask;
EpsMobileIdentity guti;
LocationAreaIdentification locationareaidentification;
MobileIdentity msidentity;
EmmCause emmcause;
GprsTimer t3402value;
GprsTimer t3423value;
PlmnList equivalentplmns;
EmergencyNumberList emergencynumberlist;
EpsNetworkFeatureSupport epsnetworkfeaturesupport;
AdditionalUpdateResult additionalupdateresult;
} attach_accept_msg;
int decode_attach_accept(attach_accept_msg *attachaccept, uint8_t *buffer, uint32_t len);
int encode_attach_accept(attach_accept_msg *attachaccept, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ATTACH_ACCEPT_H_) */
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AttachComplete.h"
int decode_attach_complete(attach_complete_msg *attach_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, ATTACH_COMPLETE_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_esm_message_container(&attach_complete->esmmessagecontainer, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_attach_complete(attach_complete_msg *attach_complete, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ATTACH_COMPLETE_MINIMUM_LENGTH, len);
if ((encode_result =
encode_esm_message_container(&attach_complete->esmmessagecontainer, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EsmMessageContainer.h"
#ifndef ATTACH_COMPLETE_H_
#define ATTACH_COMPLETE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ATTACH_COMPLETE_MINIMUM_LENGTH ( \
ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ATTACH_COMPLETE_MAXIMUM_LENGTH ( \
ESM_MESSAGE_CONTAINER_MAXIMUM_LENGTH )
/*
* Message name: Attach complete
* Description: This message is sent by the UE to the network in response to an ATTACH ACCEPT message. See table 8.2.2.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct attach_complete_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EsmMessageContainer esmmessagecontainer;
} attach_complete_msg;
int decode_attach_complete(attach_complete_msg *attachcomplete, uint8_t *buffer, uint32_t len);
int encode_attach_complete(attach_complete_msg *attachcomplete, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ATTACH_COMPLETE_H_) */
+111
View File
@@ -0,0 +1,111 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AttachReject.h"
int decode_attach_reject(attach_reject_msg *attach_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, ATTACH_REJECT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_emm_cause(&attach_reject->emmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ATTACH_REJECT_ESM_MESSAGE_CONTAINER_IEI:
if ((decoded_result =
decode_esm_message_container(&attach_reject->esmmessagecontainer,
ATTACH_REJECT_ESM_MESSAGE_CONTAINER_IEI, buffer + decoded,
len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_reject->presencemask |= ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_attach_reject(attach_reject_msg *attach_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ATTACH_REJECT_MINIMUM_LENGTH, len);
if ((encode_result = encode_emm_cause(&attach_reject->emmcause, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((attach_reject->presencemask & ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT)
== ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT) {
if ((encode_result =
encode_esm_message_container(&attach_reject->esmmessagecontainer,
ATTACH_REJECT_ESM_MESSAGE_CONTAINER_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EmmCause.h"
#include "EsmMessageContainer.h"
#ifndef ATTACH_REJECT_H_
#define ATTACH_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ATTACH_REJECT_MINIMUM_LENGTH ( \
EMM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ATTACH_REJECT_MAXIMUM_LENGTH ( \
EMM_CAUSE_MAXIMUM_LENGTH + \
ESM_MESSAGE_CONTAINER_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT (1<<0)
typedef enum attach_reject_iei_tag {
ATTACH_REJECT_ESM_MESSAGE_CONTAINER_IEI = 0x78, /* 0x78 = 120 */
} attach_reject_iei;
/*
* Message name: Attach reject
* Description: This message is sent by the network to the UE to indicate that the corresponding attach request has been rejected. See table 8.2.3.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct attach_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EmmCause emmcause;
/* Optional fields */
uint32_t presencemask;
EsmMessageContainer esmmessagecontainer;
} attach_reject_msg;
int decode_attach_reject(attach_reject_msg *attachreject, uint8_t *buffer, uint32_t len);
int encode_attach_reject(attach_reject_msg *attachreject, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ATTACH_REJECT_H_) */
+502
View File
@@ -0,0 +1,502 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "nas_log.h"
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AttachRequest.h"
int decode_attach_request(attach_request_msg *attach_request, uint8_t *buffer, uint32_t len)
{
uint32_t decoded = 0;
int decoded_result = 0;
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMM - attach_request len = %d",
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, ATTACH_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_eps_attach_type(&attach_request->epsattachtype, 0, *(buffer + decoded) & 0x0f, len - decoded)) < 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
if ((decoded_result = decode_u8_nas_key_set_identifier(&attach_request->naskeysetidentifier, 0, *(buffer + decoded) >> 4, len - decoded)) < 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded++;
if ((decoded_result = decode_eps_mobile_identity(&attach_request->oldgutiorimsi, 0, buffer + decoded, len - decoded)) < 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
} else
decoded += decoded_result;
if ((decoded_result = decode_ue_network_capability(&attach_request->uenetworkcapability, 0, buffer + decoded, len - decoded)) < 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
} else
decoded += decoded_result;
if ((decoded_result = decode_esm_message_container(&attach_request->esmmessagecontainer, 0, buffer + decoded, len - decoded)) < 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
} else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_IEI:
if ((decoded_result =
decode_p_tmsi_signature(&attach_request->oldptmsisignature,
ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_IEI, buffer + decoded,
len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT;
break;
case ATTACH_REQUEST_ADDITIONAL_GUTI_IEI:
if ((decoded_result =
decode_eps_mobile_identity(&attach_request->additionalguti,
ATTACH_REQUEST_ADDITIONAL_GUTI_IEI, buffer + decoded, len -
decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_ADDITIONAL_GUTI_PRESENT;
break;
case ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI:
if ((decoded_result =
decode_tracking_area_identity(&attach_request->lastvisitedregisteredtai,
ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI, buffer +
decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT;
break;
case ATTACH_REQUEST_DRX_PARAMETER_IEI:
if ((decoded_result =
decode_drx_parameter(&attach_request->drxparameter,
ATTACH_REQUEST_DRX_PARAMETER_IEI, buffer + decoded, len -
decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_DRX_PARAMETER_PRESENT;
break;
case ATTACH_REQUEST_MS_NETWORK_CAPABILITY_IEI:
if ((decoded_result =
decode_ms_network_capability(&attach_request->msnetworkcapability,
ATTACH_REQUEST_MS_NETWORK_CAPABILITY_IEI, buffer + decoded,
len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_MS_NETWORK_CAPABILITY_PRESENT;
break;
case ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI:
if ((decoded_result =
decode_location_area_identification(&attach_request->oldlocationareaidentification,
ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI, buffer
+ decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT;
break;
case ATTACH_REQUEST_TMSI_STATUS_IEI:
if ((decoded_result =
decode_tmsi_status(&attach_request->tmsistatus,
ATTACH_REQUEST_TMSI_STATUS_IEI, buffer + decoded, len -
decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_TMSI_STATUS_PRESENT;
break;
case ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI:
if ((decoded_result =
decode_mobile_station_classmark_2(&attach_request->mobilestationclassmark2,
ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI, buffer +
decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT;
break;
case ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI:
if ((decoded_result =
decode_mobile_station_classmark_3(&attach_request->mobilestationclassmark3,
ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI, buffer +
decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT;
break;
case ATTACH_REQUEST_SUPPORTED_CODECS_IEI:
if ((decoded_result =
decode_supported_codec_list(&attach_request->supportedcodecs,
ATTACH_REQUEST_SUPPORTED_CODECS_IEI,
buffer + decoded,
len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_SUPPORTED_CODECS_PRESENT;
break;
case ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI:
if ((decoded_result =
decode_additional_update_type(&attach_request->additionalupdatetype,
ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI, buffer +
decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT;
break;
case ATTACH_REQUEST_OLD_GUTI_TYPE_IEI:
if ((decoded_result =
decode_guti_type(&attach_request->oldgutitype,
ATTACH_REQUEST_OLD_GUTI_TYPE_IEI,
buffer + decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT;
break;
case ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_IEI:
if ((decoded_result =
decode_voice_domain_preference_and_ue_usage_setting(&attach_request->voicedomainpreferenceandueusagesetting,
ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_IEI,
buffer + decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_PRESENT;
break;
case ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_IEI:
if ((decoded_result =
decode_ms_network_feature_support(&attach_request->msnetworkfeaturesupport,
ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_IEI,
buffer + decoded, len - decoded)) <= 0) {
// return decoded_result;
LOG_FUNC_RETURN(decoded_result);
}
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
attach_request->presencemask |= ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
{
// return TLV_DECODE_UNEXPECTED_IEI;
LOG_TRACE(INFO,"EMM: Can't decode the message with iei %d\n",ieiDecoded);
LOG_FUNC_RETURN(TLV_DECODE_UNEXPECTED_IEI);
}
}
}
LOG_FUNC_RETURN(decoded);
}
int encode_attach_request(attach_request_msg *attach_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ATTACH_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&attach_request->naskeysetidentifier) & 0x0f) << 4) | (encode_u8_eps_attach_type(&attach_request->epsattachtype) & 0x0f);
encoded++;
if ((encode_result =
encode_eps_mobile_identity(&attach_request->oldgutiorimsi, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result =
encode_ue_network_capability(&attach_request->uenetworkcapability, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result =
encode_esm_message_container(&attach_request->esmmessagecontainer, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((attach_request->presencemask & ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT)
== ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT) {
if ((encode_result =
encode_p_tmsi_signature(&attach_request->oldptmsisignature,
ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_ADDITIONAL_GUTI_PRESENT)
== ATTACH_REQUEST_ADDITIONAL_GUTI_PRESENT) {
if ((encode_result =
encode_eps_mobile_identity(&attach_request->additionalguti,
ATTACH_REQUEST_ADDITIONAL_GUTI_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT)
== ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT) {
if ((encode_result =
encode_tracking_area_identity(&attach_request->lastvisitedregisteredtai,
ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI, buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_DRX_PARAMETER_PRESENT)
== ATTACH_REQUEST_DRX_PARAMETER_PRESENT) {
if ((encode_result = encode_drx_parameter(&attach_request->drxparameter,
ATTACH_REQUEST_DRX_PARAMETER_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_MS_NETWORK_CAPABILITY_PRESENT)
== ATTACH_REQUEST_MS_NETWORK_CAPABILITY_PRESENT) {
if ((encode_result =
encode_ms_network_capability(&attach_request->msnetworkcapability,
ATTACH_REQUEST_MS_NETWORK_CAPABILITY_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT)
== ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT) {
if ((encode_result =
encode_location_area_identification(&attach_request->oldlocationareaidentification,
ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_TMSI_STATUS_PRESENT)
== ATTACH_REQUEST_TMSI_STATUS_PRESENT) {
if ((encode_result = encode_tmsi_status(&attach_request->tmsistatus,
ATTACH_REQUEST_TMSI_STATUS_IEI, buffer + encoded, len - encoded))
< 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT)
== ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT) {
if ((encode_result =
encode_mobile_station_classmark_2(&attach_request->mobilestationclassmark2,
ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI, buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT)
== ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT) {
if ((encode_result =
encode_mobile_station_classmark_3(&attach_request->mobilestationclassmark3,
ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI, buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_SUPPORTED_CODECS_PRESENT)
== ATTACH_REQUEST_SUPPORTED_CODECS_PRESENT) {
if ((encode_result =
encode_supported_codec_list(&attach_request->supportedcodecs,
ATTACH_REQUEST_SUPPORTED_CODECS_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT)
== ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT) {
if ((encode_result =
encode_additional_update_type(&attach_request->additionalupdatetype,
ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT)
== ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT) {
if ((encode_result =
encode_guti_type(&attach_request->oldgutitype,
ATTACH_REQUEST_OLD_GUTI_TYPE_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_PRESENT)
== ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_PRESENT) {
if ((encode_result =
encode_voice_domain_preference_and_ue_usage_setting(&attach_request->voicedomainpreferenceandueusagesetting,
ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((attach_request->presencemask & ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_PRESENT)
== ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_PRESENT) {
if ((encode_result =
encode_ms_network_feature_support(&attach_request->msnetworkfeaturesupport,
ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_IEI,
buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
+162
View File
@@ -0,0 +1,162 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EpsAttachType.h"
#include "NasKeySetIdentifier.h"
#include "EpsMobileIdentity.h"
#include "UeNetworkCapability.h"
#include "EsmMessageContainer.h"
#include "PTmsiSignature.h"
#include "TrackingAreaIdentity.h"
#include "DrxParameter.h"
#include "MsNetworkCapability.h"
#include "MsNetworkFeatureSupport.h"
#include "LocationAreaIdentification.h"
#include "TmsiStatus.h"
#include "MobileStationClassmark2.h"
#include "MobileStationClassmark3.h"
#include "SupportedCodecList.h"
#include "AdditionalUpdateType.h"
#include "GutiType.h"
#include "VoiceDomainPreferenceAndUeUsageSetting.h"
#ifndef ATTACH_REQUEST_H_
#define ATTACH_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ATTACH_REQUEST_MINIMUM_LENGTH ( \
EPS_ATTACH_TYPE_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MINIMUM_LENGTH + \
UE_NETWORK_CAPABILITY_MINIMUM_LENGTH + \
ESM_MESSAGE_CONTAINER_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ATTACH_REQUEST_MAXIMUM_LENGTH ( \
EPS_ATTACH_TYPE_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
UE_NETWORK_CAPABILITY_MAXIMUM_LENGTH + \
ESM_MESSAGE_CONTAINER_MAXIMUM_LENGTH + \
P_TMSI_SIGNATURE_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
TRACKING_AREA_IDENTITY_MAXIMUM_LENGTH + \
DRX_PARAMETER_MAXIMUM_LENGTH + \
MS_NETWORK_CAPABILITY_MAXIMUM_LENGTH + \
MS_NETWORK_FEATURE_SUPPORT_MAXIMUM_LENGTH + \
LOCATION_AREA_IDENTIFICATION_MAXIMUM_LENGTH + \
TMSI_STATUS_MAXIMUM_LENGTH + \
MOBILE_STATION_CLASSMARK_2_MAXIMUM_LENGTH + \
MOBILE_STATION_CLASSMARK_3_MAXIMUM_LENGTH + \
SUPPORTED_CODEC_LIST_MAXIMUM_LENGTH + \
ADDITIONAL_UPDATE_TYPE_MAXIMUM_LENGTH + \
GUTI_TYPE_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT (1<<0)
# define ATTACH_REQUEST_ADDITIONAL_GUTI_PRESENT (1<<1)
# define ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT (1<<2)
# define ATTACH_REQUEST_DRX_PARAMETER_PRESENT (1<<3)
# define ATTACH_REQUEST_MS_NETWORK_CAPABILITY_PRESENT (1<<4)
# define ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT (1<<5)
# define ATTACH_REQUEST_TMSI_STATUS_PRESENT (1<<6)
# define ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT (1<<7)
# define ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT (1<<8)
# define ATTACH_REQUEST_SUPPORTED_CODECS_PRESENT (1<<9)
# define ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT (1<<10)
# define ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT (1<<11)
# define ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_PRESENT (1<<12)
# define ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_PRESENT (1<<13)
typedef enum attach_request_iei_tag {
ATTACH_REQUEST_OLD_PTMSI_SIGNATURE_IEI = 0x19, /* 0x19 = 25 */
ATTACH_REQUEST_ADDITIONAL_GUTI_IEI = 0x50, /* 0x50 = 80 */
ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI = 0x52, /* 0x52 = 82 */
ATTACH_REQUEST_DRX_PARAMETER_IEI = 0x5C, /* 0x5C = 92 */
ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_IEI = 0xC0, /* 0xC- = 192- */
ATTACH_REQUEST_MS_NETWORK_CAPABILITY_IEI = 0x31, /* 0x31 = 49 */
ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI = 0x13, /* 0x13 = 19 */
ATTACH_REQUEST_TMSI_STATUS_IEI = 0x90, /* 0x90 = 144 */
ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI = 0x11, /* 0x11 = 17 */
ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI = 0x20, /* 0x20 = 32 */
ATTACH_REQUEST_SUPPORTED_CODECS_IEI = 0x40, /* 0x40 = 64 */
ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI = 0xF0, /* 0xF0 = 240 */
ATTACH_REQUEST_OLD_GUTI_TYPE_IEI = 0xE0, /* 0xE0 = 224 */
ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_IEI = 0x5D, /* 0x5D = 93 */
} attach_request_iei;
/*
* Message name: Attach request
* Description: This message is sent by the UE to the network in order to perform an attach procedure. See table 8.2.4.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct attach_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EpsAttachType epsattachtype;
NasKeySetIdentifier naskeysetidentifier;
EpsMobileIdentity oldgutiorimsi;
UeNetworkCapability uenetworkcapability;
EsmMessageContainer esmmessagecontainer;
/* Optional fields */
uint32_t presencemask;
PTmsiSignature oldptmsisignature;
EpsMobileIdentity additionalguti;
TrackingAreaIdentity lastvisitedregisteredtai;
DrxParameter drxparameter;
MsNetworkCapability msnetworkcapability;
LocationAreaIdentification oldlocationareaidentification;
TmsiStatus tmsistatus;
MobileStationClassmark2 mobilestationclassmark2;
MobileStationClassmark3 mobilestationclassmark3;
SupportedCodecList supportedcodecs;
AdditionalUpdateType additionalupdatetype;
GutiType oldgutitype;
VoiceDomainPreferenceAndUeUsageSetting voicedomainpreferenceandueusagesetting;
MsNetworkFeatureSupport msnetworkfeaturesupport;
} attach_request_msg;
int decode_attach_request(attach_request_msg *attachrequest, uint8_t *buffer, uint32_t len);
int encode_attach_request(attach_request_msg *attachrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ATTACH_REQUEST_H_) */
@@ -0,0 +1,111 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AuthenticationFailure.h"
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);
/* Decoding mandatory fields */
if ((decoded_result = decode_emm_cause(&authentication_failure->emmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
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;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
authentication_failure->presencemask |= AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_authentication_failure(authentication_failure_msg *authentication_failure, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len);
if ((encode_result = encode_emm_cause(&authentication_failure->emmcause, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((authentication_failure->presencemask & AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT)
== AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) {
if ((encode_result =
encode_authentication_failure_parameter(&authentication_failure->authenticationfailureparameter,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EmmCause.h"
#include "AuthenticationFailureParameter.h"
#ifndef AUTHENTICATION_FAILURE_H_
#define AUTHENTICATION_FAILURE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_FAILURE_MINIMUM_LENGTH ( \
EMM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_FAILURE_MAXIMUM_LENGTH ( \
EMM_CAUSE_MAXIMUM_LENGTH + \
AUTHENTICATION_FAILURE_PARAMETER_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT (1<<0)
typedef enum authentication_failure_iei_tag {
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI = 0x30, /* 0x30 = 48 */
} authentication_failure_iei;
/*
* Message name: Authentication failure
* Description: This message is sent by the UE to the network to indicate that authentication of the network has failed. See table 8.2.5.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct authentication_failure_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EmmCause emmcause;
/* Optional fields */
uint32_t presencemask;
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 /* ! defined(AUTHENTICATION_FAILURE_H_) */
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#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;
// 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);
/* Decoding mandatory fields */
return decoded;
}
int encode_authentication_reject(authentication_reject_msg *authentication_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_REJECT_MINIMUM_LENGTH, len);
return encoded;
}
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#ifndef AUTHENTICATION_REJECT_H_
#define AUTHENTICATION_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_REJECT_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_REJECT_MAXIMUM_LENGTH (0)
/*
* Message name: Authentication reject
* Description: This message is sent by the network to the UE to indicate that the authentication procedure has failed and that the UE shall abort all activities. See table 8.2.6.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct authentication_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
} 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 /* ! defined(AUTHENTICATION_REJECT_H_) */
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AuthenticationRequest.h"
int decode_authentication_request(authentication_request_msg *authentication_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, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifierasme, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_authentication_parameter_rand(&authentication_request->authenticationparameterrand, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_authentication_parameter_autn(&authentication_request->authenticationparameterautn, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_authentication_request(authentication_request_msg *authentication_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifierasme) & 0x0f) << 4) | 0x00;
encoded++;
if ((encode_result =
encode_authentication_parameter_rand(&authentication_request->authenticationparameterrand,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result =
encode_authentication_parameter_autn(&authentication_request->authenticationparameterautn,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "NasKeySetIdentifier.h"
#include "AuthenticationParameterRand.h"
#include "AuthenticationParameterAutn.h"
#ifndef AUTHENTICATION_REQUEST_H_
#define AUTHENTICATION_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_REQUEST_MINIMUM_LENGTH ( \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_RAND_MINIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_AUTN_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_REQUEST_MAXIMUM_LENGTH ( \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_RAND_MAXIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_AUTN_MAXIMUM_LENGTH )
/*
* Message name: Authentication request
* Description: This message is sent by the network to the UE to initiate authentication of the UE identity. See table 8.2.7.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct authentication_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
NasKeySetIdentifier naskeysetidentifierasme;
AuthenticationParameterRand authenticationparameterrand;
AuthenticationParameterAutn authenticationparameterautn;
} 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 /* ! defined(AUTHENTICATION_REQUEST_H_) */
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "AuthenticationResponse.h"
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);
/* Decoding mandatory fields */
if ((decoded_result = decode_authentication_response_parameter(&authentication_response->authenticationresponseparameter, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_authentication_response(authentication_response_msg *authentication_response, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len);
if ((encode_result =
encode_authentication_response_parameter(&authentication_response->authenticationresponseparameter,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "AuthenticationResponseParameter.h"
#ifndef AUTHENTICATION_RESPONSE_H_
#define AUTHENTICATION_RESPONSE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_RESPONSE_MINIMUM_LENGTH ( \
AUTHENTICATION_RESPONSE_PARAMETER_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_RESPONSE_MAXIMUM_LENGTH ( \
AUTHENTICATION_RESPONSE_PARAMETER_MAXIMUM_LENGTH )
/*
* Message name: Authentication response
* Description: This message is sent by the UE to the network to deliver a calculated authentication response to the network. See table 8.2.8.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct authentication_response_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
AuthenticationResponseParameter authenticationresponseparameter;
} 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 /* ! defined(AUTHENTICATION_RESPONSE_H_) */
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
@@ -0,0 +1,181 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "CsServiceNotification.h"
int decode_cs_service_notification(cs_service_notification_msg *cs_service_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, CS_SERVICE_NOTIFICATION_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_paging_identity(&cs_service_notification->pagingidentity, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case CS_SERVICE_NOTIFICATION_CLI_IEI:
if ((decoded_result = decode_cli(&cs_service_notification->cli,
CS_SERVICE_NOTIFICATION_CLI_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
cs_service_notification->presencemask |= CS_SERVICE_NOTIFICATION_CLI_PRESENT;
break;
case CS_SERVICE_NOTIFICATION_SS_CODE_IEI:
if ((decoded_result =
decode_ss_code(&cs_service_notification->sscode,
CS_SERVICE_NOTIFICATION_SS_CODE_IEI, buffer + decoded, len
- decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
cs_service_notification->presencemask |= CS_SERVICE_NOTIFICATION_SS_CODE_PRESENT;
break;
case CS_SERVICE_NOTIFICATION_LCS_INDICATOR_IEI:
if ((decoded_result =
decode_lcs_indicator(&cs_service_notification->lcsindicator,
CS_SERVICE_NOTIFICATION_LCS_INDICATOR_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
cs_service_notification->presencemask |= CS_SERVICE_NOTIFICATION_LCS_INDICATOR_PRESENT;
break;
case CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_IEI:
if ((decoded_result =
decode_lcs_client_identity(&cs_service_notification->lcsclientidentity,
CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
cs_service_notification->presencemask |= CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_cs_service_notification(cs_service_notification_msg *cs_service_notification, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, CS_SERVICE_NOTIFICATION_MINIMUM_LENGTH, len);
if ((encode_result =
encode_paging_identity(&cs_service_notification->pagingidentity, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((cs_service_notification->presencemask & CS_SERVICE_NOTIFICATION_CLI_PRESENT)
== CS_SERVICE_NOTIFICATION_CLI_PRESENT) {
if ((encode_result = encode_cli(&cs_service_notification->cli,
CS_SERVICE_NOTIFICATION_CLI_IEI, buffer + encoded, len - encoded))
< 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((cs_service_notification->presencemask & CS_SERVICE_NOTIFICATION_SS_CODE_PRESENT)
== CS_SERVICE_NOTIFICATION_SS_CODE_PRESENT) {
if ((encode_result = encode_ss_code(&cs_service_notification->sscode,
CS_SERVICE_NOTIFICATION_SS_CODE_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((cs_service_notification->presencemask & CS_SERVICE_NOTIFICATION_LCS_INDICATOR_PRESENT)
== CS_SERVICE_NOTIFICATION_LCS_INDICATOR_PRESENT) {
if ((encode_result =
encode_lcs_indicator(&cs_service_notification->lcsindicator,
CS_SERVICE_NOTIFICATION_LCS_INDICATOR_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((cs_service_notification->presencemask & CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_PRESENT)
== CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_PRESENT) {
if ((encode_result =
encode_lcs_client_identity(&cs_service_notification->lcsclientidentity,
CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_IEI, buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "PagingIdentity.h"
#include "Cli.h"
#include "SsCode.h"
#include "LcsIndicator.h"
#include "LcsClientIdentity.h"
#ifndef CS_SERVICE_NOTIFICATION_H_
#define CS_SERVICE_NOTIFICATION_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define CS_SERVICE_NOTIFICATION_MINIMUM_LENGTH ( \
PAGING_IDENTITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define CS_SERVICE_NOTIFICATION_MAXIMUM_LENGTH ( \
PAGING_IDENTITY_MAXIMUM_LENGTH + \
CLI_MAXIMUM_LENGTH + \
SS_CODE_MAXIMUM_LENGTH + \
LCS_INDICATOR_MAXIMUM_LENGTH + \
LCS_CLIENT_IDENTITY_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define CS_SERVICE_NOTIFICATION_CLI_PRESENT (1<<0)
# define CS_SERVICE_NOTIFICATION_SS_CODE_PRESENT (1<<1)
# define CS_SERVICE_NOTIFICATION_LCS_INDICATOR_PRESENT (1<<2)
# define CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_PRESENT (1<<3)
typedef enum cs_service_notification_iei_tag {
CS_SERVICE_NOTIFICATION_CLI_IEI = 0x60, /* 0x60 = 96 */
CS_SERVICE_NOTIFICATION_SS_CODE_IEI = 0x61, /* 0x61 = 97 */
CS_SERVICE_NOTIFICATION_LCS_INDICATOR_IEI = 0x62, /* 0x62 = 98 */
CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_IEI = 0x63, /* 0x63 = 99 */
} cs_service_notification_iei;
/*
* Message name: CS service notification
* Description: This message is sent by the network when a paging request with CS call indicator was received via SGs for a UE, and a NAS signalling connection is already established for the UE. See table 8.2.9.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct cs_service_notification_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
PagingIdentity pagingidentity;
/* Optional fields */
uint32_t presencemask;
Cli cli;
SsCode sscode;
LcsIndicator lcsindicator;
LcsClientIdentity lcsclientidentity;
} cs_service_notification_msg;
int decode_cs_service_notification(cs_service_notification_msg *csservicenotification, uint8_t *buffer, uint32_t len);
int encode_cs_service_notification(cs_service_notification_msg *csservicenotification, uint8_t *buffer, uint32_t len);
#endif /* ! defined(CS_SERVICE_NOTIFICATION_H_) */
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "DetachAccept.h"
int decode_detach_accept(detach_accept_msg *detach_accept, uint8_t *buffer, uint32_t len)
{
uint32_t decoded = 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, DETACH_ACCEPT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
return decoded;
}
int encode_detach_accept(detach_accept_msg *detach_accept, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DETACH_ACCEPT_MINIMUM_LENGTH, len);
return encoded;
}
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#ifndef DETACH_ACCEPT_H_
#define DETACH_ACCEPT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DETACH_ACCEPT_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define DETACH_ACCEPT_MAXIMUM_LENGTH (0)
/*
* Message name: Detach accept
* Description: This message is sent by the network to indicate that the detach procedure has been completed. See table 8.2.10.1.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct detach_accept_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
} detach_accept_msg;
int decode_detach_accept(detach_accept_msg *detachaccept, uint8_t *buffer, uint32_t len);
int encode_detach_accept(detach_accept_msg *detachaccept, uint8_t *buffer, uint32_t len);
#endif /* ! defined(DETACH_ACCEPT_H_) */
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "DetachRequest.h"
int decode_detach_request(detach_request_msg *detach_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, DETACH_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_detach_type(&detach_request->detachtype, 0, *(buffer + decoded) & 0x0f, len - decoded)) < 0)
return decoded_result;
if ((decoded_result = decode_u8_nas_key_set_identifier(&detach_request->naskeysetidentifier, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_eps_mobile_identity(&detach_request->gutiorimsi, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_detach_request(detach_request_msg *detach_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DETACH_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&detach_request->naskeysetidentifier) << 4) | (encode_u8_detach_type(&detach_request->detachtype) & 0x0f));
encoded++;
if ((encode_result = encode_eps_mobile_identity(&detach_request->gutiorimsi,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "DetachType.h"
#include "NasKeySetIdentifier.h"
#include "EpsMobileIdentity.h"
#ifndef DETACH_REQUEST_H_
#define DETACH_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DETACH_REQUEST_MINIMUM_LENGTH ( \
DETACH_TYPE_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define DETACH_REQUEST_MAXIMUM_LENGTH ( \
DETACH_TYPE_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH )
/*
* Message name: Detach request
* Description: This message is sent by the UE to request the release of an EMM context. See table 8.2.11.1.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct detach_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
DetachType detachtype;
NasKeySetIdentifier naskeysetidentifier;
EpsMobileIdentity gutiorimsi;
} detach_request_msg;
int decode_detach_request(detach_request_msg *detachrequest, uint8_t *buffer, uint32_t len);
int encode_detach_request(detach_request_msg *detachrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(DETACH_REQUEST_H_) */
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "DownlinkNasTransport.h"
int decode_downlink_nas_transport(downlink_nas_transport_msg *downlink_nas_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, DOWNLINK_NAS_TRANSPORT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_nas_message_container(&downlink_nas_transport->nasmessagecontainer, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_downlink_nas_transport(downlink_nas_transport_msg *downlink_nas_transport, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DOWNLINK_NAS_TRANSPORT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_nas_message_container(&downlink_nas_transport->nasmessagecontainer,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "NasMessageContainer.h"
#ifndef DOWNLINK_NAS_TRANSPORT_H_
#define DOWNLINK_NAS_TRANSPORT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DOWNLINK_NAS_TRANSPORT_MINIMUM_LENGTH ( \
NAS_MESSAGE_CONTAINER_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define DOWNLINK_NAS_TRANSPORT_MAXIMUM_LENGTH ( \
NAS_MESSAGE_CONTAINER_MAXIMUM_LENGTH )
/*
* Message name: Downlink NAS Transport
* Description: This message is sent by the network to the UE in order to carry an SMS message in encapsulated format. See table 8.2.12.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct downlink_nas_transport_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
NasMessageContainer nasmessagecontainer;
} downlink_nas_transport_msg;
int decode_downlink_nas_transport(downlink_nas_transport_msg *downlinknastransport, uint8_t *buffer, uint32_t len);
int encode_downlink_nas_transport(downlink_nas_transport_msg *downlinknastransport, uint8_t *buffer, uint32_t len);
#endif /* ! defined(DOWNLINK_NAS_TRANSPORT_H_) */
@@ -0,0 +1,195 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "EmmInformation.h"
int decode_emm_information(emm_information_msg *emm_information, 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, EMM_INFORMATION_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case EMM_INFORMATION_FULL_NAME_FOR_NETWORK_IEI:
if ((decoded_result =
decode_network_name(&emm_information->fullnamefornetwork,
EMM_INFORMATION_FULL_NAME_FOR_NETWORK_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
emm_information->presencemask |= EMM_INFORMATION_FULL_NAME_FOR_NETWORK_PRESENT;
break;
case EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_IEI:
if ((decoded_result =
decode_network_name(&emm_information->shortnamefornetwork,
EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
emm_information->presencemask |= EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_PRESENT;
break;
case EMM_INFORMATION_LOCAL_TIME_ZONE_IEI:
if ((decoded_result =
decode_time_zone(&emm_information->localtimezone,
EMM_INFORMATION_LOCAL_TIME_ZONE_IEI, buffer + decoded, len
- decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
emm_information->presencemask |= EMM_INFORMATION_LOCAL_TIME_ZONE_PRESENT;
break;
case EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_IEI:
if ((decoded_result =
decode_time_zone_and_time(&emm_information->universaltimeandlocaltimezone,
EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
emm_information->presencemask |= EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_PRESENT;
break;
case EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_IEI:
if ((decoded_result =
decode_daylight_saving_time(&emm_information->networkdaylightsavingtime,
EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
emm_information->presencemask |= EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_emm_information(emm_information_msg *emm_information, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, EMM_INFORMATION_MINIMUM_LENGTH, len);
if ((emm_information->presencemask & EMM_INFORMATION_FULL_NAME_FOR_NETWORK_PRESENT)
== EMM_INFORMATION_FULL_NAME_FOR_NETWORK_PRESENT) {
if ((encode_result =
encode_network_name(&emm_information->fullnamefornetwork,
EMM_INFORMATION_FULL_NAME_FOR_NETWORK_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((emm_information->presencemask & EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_PRESENT)
== EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_PRESENT) {
if ((encode_result =
encode_network_name(&emm_information->shortnamefornetwork,
EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_IEI, buffer + encoded, len
- encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((emm_information->presencemask & EMM_INFORMATION_LOCAL_TIME_ZONE_PRESENT)
== EMM_INFORMATION_LOCAL_TIME_ZONE_PRESENT) {
if ((encode_result = encode_time_zone(&emm_information->localtimezone,
EMM_INFORMATION_LOCAL_TIME_ZONE_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((emm_information->presencemask & EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_PRESENT)
== EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_PRESENT) {
if ((encode_result =
encode_time_zone_and_time(&emm_information->universaltimeandlocaltimezone,
EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((emm_information->presencemask & EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_PRESENT)
== EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_PRESENT) {
if ((encode_result =
encode_daylight_saving_time(&emm_information->networkdaylightsavingtime,
EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "NetworkName.h"
#include "TimeZone.h"
#include "TimeZoneAndTime.h"
#include "DaylightSavingTime.h"
#ifndef EMM_INFORMATION_H_
#define EMM_INFORMATION_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define EMM_INFORMATION_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define EMM_INFORMATION_MAXIMUM_LENGTH ( \
NETWORK_NAME_MAXIMUM_LENGTH + \
NETWORK_NAME_MAXIMUM_LENGTH + \
TIME_ZONE_MAXIMUM_LENGTH + \
TIME_ZONE_AND_TIME_MAXIMUM_LENGTH + \
DAYLIGHT_SAVING_TIME_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define EMM_INFORMATION_FULL_NAME_FOR_NETWORK_PRESENT (1<<0)
# define EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_PRESENT (1<<1)
# define EMM_INFORMATION_LOCAL_TIME_ZONE_PRESENT (1<<2)
# define EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_PRESENT (1<<3)
# define EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_PRESENT (1<<4)
typedef enum emm_information_iei_tag {
EMM_INFORMATION_FULL_NAME_FOR_NETWORK_IEI = 0x43, /* 0x43 = 67 */
EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_IEI = 0x45, /* 0x45 = 69 */
EMM_INFORMATION_LOCAL_TIME_ZONE_IEI = 0x46, /* 0x46 = 70 */
EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_IEI = 0x47, /* 0x47 = 71 */
EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_IEI = 0x49, /* 0x49 = 73 */
} emm_information_iei;
/*
* Message name: EMM information
* Description: This message is sent by the network at any time during EMM context is established to send certain information to the UE. See table 8.2.13.1.
* Significance: local
* Direction: network to UE
*/
typedef struct emm_information_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
/* Optional fields */
uint32_t presencemask;
NetworkName fullnamefornetwork;
NetworkName shortnamefornetwork;
TimeZone localtimezone;
TimeZoneAndTime universaltimeandlocaltimezone;
DaylightSavingTime networkdaylightsavingtime;
} emm_information_msg;
int decode_emm_information(emm_information_msg *emminformation, uint8_t *buffer, uint32_t len);
int encode_emm_information(emm_information_msg *emminformation, uint8_t *buffer, uint32_t len);
#endif /* ! defined(EMM_INFORMATION_H_) */
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "EmmStatus.h"
int decode_emm_status(emm_status_msg *emm_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, EMM_STATUS_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_emm_cause(&emm_status->emmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_emm_status(emm_status_msg *emm_status, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, EMM_STATUS_MINIMUM_LENGTH, len);
if ((encode_result = encode_emm_cause(&emm_status->emmcause, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
+70
View File
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EmmCause.h"
#ifndef EMM_STATUS_H_
#define EMM_STATUS_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define EMM_STATUS_MINIMUM_LENGTH ( \
EMM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define EMM_STATUS_MAXIMUM_LENGTH ( \
EMM_CAUSE_MAXIMUM_LENGTH )
/*
* Message name: EMM status
* Description: This message is sent by the UE or by the network at any time to report certain error conditions listed in clause 7. See table 8.2.14.1.
* Significance: local
* Direction: both
*/
typedef struct emm_status_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EmmCause emmcause;
} emm_status_msg;
int decode_emm_status(emm_status_msg *emmstatus, uint8_t *buffer, uint32_t len);
int encode_emm_status(emm_status_msg *emmstatus, uint8_t *buffer, uint32_t len);
#endif /* ! defined(EMM_STATUS_H_) */
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ExtendedServiceRequest.h"
int decode_extended_service_request(extended_service_request_msg *extended_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, EXTENDED_SERVICE_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_service_type(&extended_service_request->servicetype, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
if ((decoded_result = decode_u8_nas_key_set_identifier(&extended_service_request->naskeysetidentifier, 0, *(buffer + decoded) & 0x0f, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_mobile_identity(&extended_service_request->mtmsi, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_extended_service_request(extended_service_request_msg *extended_service_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, EXTENDED_SERVICE_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_service_type(&extended_service_request->servicetype) & 0x0f) << 4) | (encode_u8_nas_key_set_identifier(&extended_service_request->naskeysetidentifier) & 0x0f);
encoded++;
if ((encode_result =
encode_mobile_identity(&extended_service_request->mtmsi, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result =
encode_csfb_response(&extended_service_request->csfbresponse, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "ServiceType.h"
#include "NasKeySetIdentifier.h"
#include "MobileIdentity.h"
#include "CsfbResponse.h"
#ifndef EXTENDED_SERVICE_REQUEST_H_
#define EXTENDED_SERVICE_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define EXTENDED_SERVICE_REQUEST_MINIMUM_LENGTH ( \
SERVICE_TYPE_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
MOBILE_IDENTITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define EXTENDED_SERVICE_REQUEST_MAXIMUM_LENGTH ( \
SERVICE_TYPE_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
MOBILE_IDENTITY_MAXIMUM_LENGTH + \
CSFB_RESPONSE_MAXIMUM_LENGTH )
/*
* Message name: Extended service request
* Description: This message is sent by the UE to the network to initiate a CS fallback call or respond to a mobile terminated CS fallback request from the network. See table 8.2.15.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct extended_service_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
ServiceType servicetype;
NasKeySetIdentifier naskeysetidentifier;
MobileIdentity mtmsi;
/* Optional fields */
uint32_t presencemask;
CsfbResponse csfbresponse;
} extended_service_request_msg;
int decode_extended_service_request(extended_service_request_msg *extendedservicerequest, uint8_t *buffer, uint32_t len);
int encode_extended_service_request(extended_service_request_msg *extendedservicerequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(EXTENDED_SERVICE_REQUEST_H_) */
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "GutiReallocationCommand.h"
int decode_guti_reallocation_command(guti_reallocation_command_msg *guti_reallocation_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, GUTI_REALLOCATION_COMMAND_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_eps_mobile_identity(&guti_reallocation_command->guti, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case GUTI_REALLOCATION_COMMAND_TAI_LIST_IEI:
if ((decoded_result =
decode_tracking_area_identity_list(&guti_reallocation_command->tailist,
GUTI_REALLOCATION_COMMAND_TAI_LIST_IEI, buffer + decoded,
len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
guti_reallocation_command->presencemask |= GUTI_REALLOCATION_COMMAND_TAI_LIST_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_guti_reallocation_command(guti_reallocation_command_msg *guti_reallocation_command, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, GUTI_REALLOCATION_COMMAND_MINIMUM_LENGTH, len);
if ((encode_result =
encode_eps_mobile_identity(&guti_reallocation_command->guti, 0, buffer
+ encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((guti_reallocation_command->presencemask & GUTI_REALLOCATION_COMMAND_TAI_LIST_PRESENT)
== GUTI_REALLOCATION_COMMAND_TAI_LIST_PRESENT) {
if ((encode_result =
encode_tracking_area_identity_list(&guti_reallocation_command->tailist,
GUTI_REALLOCATION_COMMAND_TAI_LIST_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EpsMobileIdentity.h"
#include "TrackingAreaIdentityList.h"
#ifndef GUTI_REALLOCATION_COMMAND_H_
#define GUTI_REALLOCATION_COMMAND_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define GUTI_REALLOCATION_COMMAND_MINIMUM_LENGTH ( \
EPS_MOBILE_IDENTITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define GUTI_REALLOCATION_COMMAND_MAXIMUM_LENGTH ( \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
TRACKING_AREA_IDENTITY_LIST_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define GUTI_REALLOCATION_COMMAND_TAI_LIST_PRESENT (1<<0)
typedef enum guti_reallocation_command_iei_tag {
GUTI_REALLOCATION_COMMAND_TAI_LIST_IEI = 0x54, /* 0x54 = 84 */
} guti_reallocation_command_iei;
/*
* Message name: GUTI reallocation command
* Description: This message is sent by the network to the UE to reallocate a GUTI and optionally to provide a new TAI list. See table 8.2.16.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct guti_reallocation_command_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EpsMobileIdentity guti;
/* Optional fields */
uint32_t presencemask;
TrackingAreaIdentityList tailist;
} guti_reallocation_command_msg;
int decode_guti_reallocation_command(guti_reallocation_command_msg *gutireallocationcommand, uint8_t *buffer, uint32_t len);
int encode_guti_reallocation_command(guti_reallocation_command_msg *gutireallocationcommand, uint8_t *buffer, uint32_t len);
#endif /* ! defined(GUTI_REALLOCATION_COMMAND_H_) */
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "GutiReallocationComplete.h"
int decode_guti_reallocation_complete(guti_reallocation_complete_msg *guti_reallocation_complete, uint8_t *buffer, uint32_t len)
{
uint32_t decoded = 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, GUTI_REALLOCATION_COMPLETE_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
return decoded;
}
int encode_guti_reallocation_complete(guti_reallocation_complete_msg *guti_reallocation_complete, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, GUTI_REALLOCATION_COMPLETE_MINIMUM_LENGTH, len);
return encoded;
}
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#ifndef GUTI_REALLOCATION_COMPLETE_H_
#define GUTI_REALLOCATION_COMPLETE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define GUTI_REALLOCATION_COMPLETE_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define GUTI_REALLOCATION_COMPLETE_MAXIMUM_LENGTH (0)
/*
* Message name: GUTI reallocation complete
* Description: This message is sent by the UE to the network to indicate that reallocation of a GUTI has taken place. See table 8.2.17.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct guti_reallocation_complete_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
} guti_reallocation_complete_msg;
int decode_guti_reallocation_complete(guti_reallocation_complete_msg *gutireallocationcomplete, uint8_t *buffer, uint32_t len);
int encode_guti_reallocation_complete(guti_reallocation_complete_msg *gutireallocationcomplete, uint8_t *buffer, uint32_t len);
#endif /* ! defined(GUTI_REALLOCATION_COMPLETE_H_) */
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#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);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_identity_type_2(&identity_request->identitytype, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
decoded++;
return decoded;
}
int encode_identity_request(identity_request_msg *identity_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, IDENTITY_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = encode_u8_identity_type_2(&identity_request->identitytype) & 0x0f;
encoded++;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "IdentityType2.h"
#ifndef IDENTITY_REQUEST_H_
#define IDENTITY_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define IDENTITY_REQUEST_MINIMUM_LENGTH ( \
IDENTITY_TYPE_2_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define IDENTITY_REQUEST_MAXIMUM_LENGTH ( \
IDENTITY_TYPE_2_MAXIMUM_LENGTH )
/*
* Message name: Identity request
* Description: This message is sent by the network to the UE to request the UE to provide the specified identity. See table 8.2.18.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct identity_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
IdentityType2 identitytype;
} 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 /* ! defined(IDENTITY_REQUEST_H_) */
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#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;
// 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);
/* Decoding mandatory fields */
if ((decoded_result = decode_mobile_identity(&identity_response->mobileidentity, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_identity_response(identity_response_msg *identity_response, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, IDENTITY_RESPONSE_MINIMUM_LENGTH, len);
if ((encode_result =
encode_mobile_identity(&identity_response->mobileidentity, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "MobileIdentity.h"
#ifndef IDENTITY_RESPONSE_H_
#define IDENTITY_RESPONSE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define IDENTITY_RESPONSE_MINIMUM_LENGTH ( \
MOBILE_IDENTITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define IDENTITY_RESPONSE_MAXIMUM_LENGTH ( \
MOBILE_IDENTITY_MAXIMUM_LENGTH )
/*
* Message name: Identity response
* Description: This message is sent by the UE to the network in response to an IDENTITY REQUEST message and provides the requested identity. See table 8.2.19.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct identity_response_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
MobileIdentity mobileidentity;
} 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 /* ! defined(IDENTITY_RESPONSE_H_) */
+41
View File
@@ -0,0 +1,41 @@
ifndef PROJDIR
PROJDIR = $(PWD)/../../..
endif
include $(PROJDIR)/Makerules
include $(PROJDIR)/Makefile.inc
INCLUDES = -I. -I$(INCDIR) -I$(UTILDIR) -I$(IESDIR)
TARGET = $(LIBEMMMSG)
TARGETS = $(TARGET).a $(TARGET).so
all: $(TARGETS)
%.o: %.c %.h Makefile $(LIBDIR)/$(LIBIES).a $(UTILDIR)/TLVEncoder.h $(UTILDIR)/TLVDecoder.h
@echo Compiling $<
@$(CC) $(CFLAGS) -c $< -o $@
$(TARGET).a: $(OBJS)
@$(RM) $@
@$(AR) $(ARFLAGS) $@ $(OBJS)
@echo Replacing $@ to $(LIBDIR)
@$(RM) $(LIBDIR)/$@
@$(CP) $@ $(LIBDIR)
$(TARGET).so: $(OBJS)
@$(LD) -G -o $@ $(OBJS)
@echo Replacing $@ to $(LIBDIR)
@$(RM) $(LIBDIR)/$@
@$(CP) $@ $(LIBDIR)
clean:
$(RM) $(OBJS) .bak *~
veryclean: clean
$(RM) $(TARGETS)
depend:
makedepend -- ${CFLAGS} -- ${SRCS}
# DO NOT DELETE THIS LINE -- make depend depends on it.
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "NasSecurityAlgorithms.h"
#include "NasKeySetIdentifier.h"
#include "UeSecurityCapability.h"
#include "ImeisvRequest.h"
#include "Nonce.h"
#ifndef NAS_SECURITY_MODE_COMMAND_H_
#define NAS_SECURITY_MODE_COMMAND_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_COMMAND_MINIMUM_LENGTH ( \
NAS_SECURITY_ALGORITHMS_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
UE_SECURITY_CAPABILITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define SECURITY_MODE_COMMAND_MAXIMUM_LENGTH ( \
NAS_SECURITY_ALGORITHMS_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
UE_SECURITY_CAPABILITY_MAXIMUM_LENGTH + \
IMEISV_REQUEST_MAXIMUM_LENGTH + \
NONCE_MAXIMUM_LENGTH + \
NONCE_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT (1<<0)
# define SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT (1<<1)
# define SECURITY_MODE_COMMAND_NONCEMME_PRESENT (1<<2)
typedef enum security_mode_command_iei_tag {
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI = 0xC0, /* 0xC0 = 192 */
SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_IEI = 0x55, /* 0x55 = 85 */
SECURITY_MODE_COMMAND_NONCEMME_IEI = 0x56, /* 0x56 = 86 */
} security_mode_command_iei;
/*
* Message name: Security mode command
* Description: This message is sent by the network to the UE to establish NAS signalling security. See table 8.2.20.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct security_mode_command_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
NasSecurityAlgorithms selectednassecurityalgorithms;
NasKeySetIdentifier naskeysetidentifier;
UeSecurityCapability replayeduesecuritycapabilities;
/* Optional fields */
uint32_t presencemask;
ImeisvRequest imeisvrequest;
Nonce replayednonceue;
Nonce noncemme;
} 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 /* ! defined(NAS_SECURITY_MODE_COMMAND_H_) */
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "MobileIdentity.h"
#ifndef SECURITY_MODE_COMPLETE_H_
#define SECURITY_MODE_COMPLETE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_COMPLETE_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define SECURITY_MODE_COMPLETE_MAXIMUM_LENGTH ( \
MOBILE_IDENTITY_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define SECURITY_MODE_COMPLETE_IMEISV_PRESENT (1<<0)
typedef enum security_mode_complete_iei_tag {
SECURITY_MODE_COMPLETE_IMEISV_IEI = 0x23, /* 0x23 = 35 */
} security_mode_complete_iei;
/*
* Message name: Security mode complete
* Description: This message is sent by the UE to the network in response to a SECURITY MODE COMMAND message. See table 8.2.21.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct security_mode_complete_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
/* Optional fields */
uint32_t presencemask;
MobileIdentity imeisv;
} 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 /* ! defined(SECURITY_MODE_COMPLETE_H_) */
@@ -0,0 +1,179 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "NASSecurityModeCommand.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;
// 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);
/* Decoding mandatory fields */
if ((decoded_result = decode_nas_security_algorithms(&security_mode_command->selectednassecurityalgorithms, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_u8_nas_key_set_identifier(&security_mode_command->naskeysetidentifier, 0, *(buffer + decoded) & 0x0f, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_ue_security_capability(&security_mode_command->replayeduesecuritycapabilities, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
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;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
security_mode_command->presencemask |= SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT;
break;
case SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_IEI:
if ((decoded_result =
decode_nonce(&security_mode_command->replayednonceue,
SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
security_mode_command->presencemask |= SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT;
break;
case SECURITY_MODE_COMMAND_NONCEMME_IEI:
if ((decoded_result =
decode_nonce(&security_mode_command->noncemme,
SECURITY_MODE_COMMAND_NONCEMME_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
security_mode_command->presencemask |= SECURITY_MODE_COMMAND_NONCEMME_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_security_mode_command(security_mode_command_msg *security_mode_command, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SECURITY_MODE_COMMAND_MINIMUM_LENGTH, len);
if ((encode_result =
encode_nas_security_algorithms(&security_mode_command->selectednassecurityalgorithms,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
*(buffer + encoded) = (encode_u8_nas_key_set_identifier(&security_mode_command->naskeysetidentifier) & 0x0f);
encoded++;
if ((encode_result =
encode_ue_security_capability(&security_mode_command->replayeduesecuritycapabilities,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((security_mode_command->presencemask & SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT)
== SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT) {
if ((encode_result =
encode_imeisv_request(&security_mode_command->imeisvrequest,
SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((security_mode_command->presencemask & SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT)
== SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT) {
if ((encode_result =
encode_nonce(&security_mode_command->replayednonceue,
SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_IEI, buffer + encoded, len
- encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((security_mode_command->presencemask & SECURITY_MODE_COMMAND_NONCEMME_PRESENT)
== SECURITY_MODE_COMMAND_NONCEMME_PRESENT) {
if ((encode_result = encode_nonce(&security_mode_command->noncemme,
SECURITY_MODE_COMMAND_NONCEMME_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "NASSecurityModeComplete.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;
// 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);
/* Decoding mandatory fields */
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case SECURITY_MODE_COMPLETE_IMEISV_IEI:
if ((decoded_result =
decode_mobile_identity(&security_mode_complete->imeisv,
SECURITY_MODE_COMPLETE_IMEISV_IEI, buffer + decoded, len -
decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
security_mode_complete->presencemask |= SECURITY_MODE_COMPLETE_IMEISV_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_security_mode_complete(security_mode_complete_msg *security_mode_complete, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SECURITY_MODE_COMPLETE_MINIMUM_LENGTH, len);
if ((security_mode_complete->presencemask & SECURITY_MODE_COMPLETE_IMEISV_PRESENT)
== SECURITY_MODE_COMPLETE_IMEISV_PRESENT) {
if ((encode_result =
encode_mobile_identity(&security_mode_complete->imeisv,
SECURITY_MODE_COMPLETE_IMEISV_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#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);
/* Decoding mandatory fields */
if ((decoded_result = decode_emm_cause(&security_mode_reject->emmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_security_mode_reject(security_mode_reject_msg *security_mode_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SECURITY_MODE_REJECT_MINIMUM_LENGTH, len);
if ((encode_result = encode_emm_cause(&security_mode_reject->emmcause, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EmmCause.h"
#ifndef SECURITY_MODE_REJECT_H_
#define SECURITY_MODE_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_REJECT_MINIMUM_LENGTH ( \
EMM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define SECURITY_MODE_REJECT_MAXIMUM_LENGTH ( \
EMM_CAUSE_MAXIMUM_LENGTH )
/*
* Message name: Security mode reject
* Description: This message is sent by the UE to the network to indicate that the corresponding security mode command has been rejected. See table 8.2.22.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct security_mode_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EmmCause emmcause;
} 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 /* ! defined(SECURITY_MODE_REJECT_H_) */
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#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);
/* Decoding mandatory fields */
if ((decoded_result = decode_emm_cause(&service_reject->emmcause, 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)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SERVICE_REJECT_MINIMUM_LENGTH, len);
if ((encode_result = encode_emm_cause(&service_reject->emmcause, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result = encode_gprs_timer(&service_reject->t3442value, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EmmCause.h"
#include "GprsTimer.h"
#ifndef SERVICE_REJECT_H_
#define SERVICE_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SERVICE_REJECT_MINIMUM_LENGTH ( \
EMM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define SERVICE_REJECT_MAXIMUM_LENGTH ( \
EMM_CAUSE_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH )
/*
* Message name: Service reject
* Description: This message is sent by the network to the UE in order to reject the service request procedure. See table 8.2.24.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct service_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EmmCause emmcause;
/* Optional fields */
uint32_t presencemask;
GprsTimer t3442value;
} 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 /* ! defined(SERVICE_REJECT_H_) */
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#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;
int decoded_result = 0;
LOG_FUNC_IN;
// 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);
/* Decoding mandatory fields */
if ((decoded_result = decode_ksi_and_sequence_number(&service_request->ksiandsequencenumber, 0, buffer + decoded, len - decoded)) < 0)
LOG_FUNC_RETURN(decoded_result);
else
decoded += decoded_result;
if ((decoded_result = decode_short_mac(&service_request->messageauthenticationcode, 0, buffer + decoded, len - decoded)) < 0)
LOG_FUNC_RETURN(decoded_result);
else
decoded += decoded_result;
LOG_FUNC_RETURN(decoded);
}
int encode_service_request(service_request_msg *service_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
LOG_FUNC_IN;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SERVICE_REQUEST_MINIMUM_LENGTH, len);
if ((encode_result =
encode_ksi_and_sequence_number(&service_request->ksiandsequencenumber,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
LOG_FUNC_RETURN(encode_result);
else
encoded += encode_result;
if ((encode_result =
encode_short_mac(&service_request->messageauthenticationcode, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
LOG_FUNC_RETURN(encode_result);
else
encoded += encode_result;
LOG_FUNC_RETURN(encoded);
}
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "KsiAndSequenceNumber.h"
#include "ShortMac.h"
#ifndef SERVICE_REQUEST_H_
#define SERVICE_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define SERVICE_REQUEST_MINIMUM_LENGTH ( \
KSI_AND_SEQUENCE_NUMBER_MINIMUM_LENGTH + \
SHORT_MAC_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define SERVICE_REQUEST_MAXIMUM_LENGTH ( \
KSI_AND_SEQUENCE_NUMBER_MAXIMUM_LENGTH + \
SHORT_MAC_MAXIMUM_LENGTH )
/*
* Message name: Service request
* Description: This message is sent by the UE to the network to request the establishment of a NAS signalling connection and of the radio and S1 bearers. Its structure does not follow the structure of a standard layer 3 message. See table 8.2.25.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct service_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
KsiAndSequenceNumber ksiandsequencenumber;
ShortMac messageauthenticationcode;
} 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 /* ! defined(SERVICE_REQUEST_H_) */
@@ -0,0 +1,396 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "TrackingAreaUpdateAccept.h"
int decode_tracking_area_update_accept(tracking_area_update_accept_msg *tracking_area_update_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, TRACKING_AREA_UPDATE_ACCEPT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_eps_update_result(&tracking_area_update_accept->epsupdateresult, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
decoded++;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_IEI:
if ((decoded_result =
decode_gprs_timer(&tracking_area_update_accept->t3412value,
TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_GUTI_IEI:
if ((decoded_result =
decode_eps_mobile_identity(&tracking_area_update_accept->guti,
TRACKING_AREA_UPDATE_ACCEPT_GUTI_IEI, buffer + decoded, len
- decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_GUTI_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_IEI:
if ((decoded_result =
decode_tracking_area_identity_list(&tracking_area_update_accept->tailist,
TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_IEI, buffer + decoded,
len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_IEI:
if ((decoded_result =
decode_eps_bearer_context_status(&tracking_area_update_accept->epsbearercontextstatus,
TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI:
if ((decoded_result =
decode_location_area_identification(&tracking_area_update_accept->locationareaidentification,
TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_IEI:
if ((decoded_result =
decode_mobile_identity(&tracking_area_update_accept->msidentity,
TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_IEI:
if ((decoded_result =
decode_emm_cause(&tracking_area_update_accept->emmcause,
TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_IEI:
if ((decoded_result =
decode_gprs_timer(&tracking_area_update_accept->t3402value,
TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_IEI:
if ((decoded_result =
decode_gprs_timer(&tracking_area_update_accept->t3423value,
TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_IEI:
if ((decoded_result =
decode_plmn_list(&tracking_area_update_accept->equivalentplmns,
TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_IEI:
if ((decoded_result =
decode_emergency_number_list(&tracking_area_update_accept->emergencynumberlist,
TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI:
if ((decoded_result =
decode_eps_network_feature_support(&tracking_area_update_accept->epsnetworkfeaturesupport,
TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT;
break;
case TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI:
if ((decoded_result =
decode_additional_update_result(&tracking_area_update_accept->additionalupdateresult,
TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_accept->presencemask |= TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_tracking_area_update_accept(tracking_area_update_accept_msg *tracking_area_update_accept, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, TRACKING_AREA_UPDATE_ACCEPT_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_eps_update_result(&tracking_area_update_accept->epsupdateresult) & 0x0f) << 4) | 0x00;
encoded++;
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_PRESENT) {
if ((encode_result =
encode_gprs_timer(&tracking_area_update_accept->t3412value,
TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_IEI, buffer + encoded, len
- encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_GUTI_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_GUTI_PRESENT) {
if ((encode_result =
encode_eps_mobile_identity(&tracking_area_update_accept->guti,
TRACKING_AREA_UPDATE_ACCEPT_GUTI_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_PRESENT) {
if ((encode_result =
encode_tracking_area_identity_list(&tracking_area_update_accept->tailist,
TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_PRESENT) {
if ((encode_result =
encode_eps_bearer_context_status(&tracking_area_update_accept->epsbearercontextstatus,
TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_IEI, buffer
+ encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT) {
if ((encode_result =
encode_location_area_identification(&tracking_area_update_accept->locationareaidentification,
TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_PRESENT) {
if ((encode_result =
encode_mobile_identity(&tracking_area_update_accept->msidentity,
TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_IEI, buffer + encoded, len
- encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_PRESENT) {
if ((encode_result =
encode_emm_cause(&tracking_area_update_accept->emmcause,
TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_PRESENT) {
if ((encode_result =
encode_gprs_timer(&tracking_area_update_accept->t3402value,
TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_IEI, buffer + encoded, len
- encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_PRESENT) {
if ((encode_result =
encode_gprs_timer(&tracking_area_update_accept->t3423value,
TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_IEI, buffer + encoded, len
- encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_PRESENT) {
if ((encode_result =
encode_plmn_list(&tracking_area_update_accept->equivalentplmns,
TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT) {
if ((encode_result =
encode_emergency_number_list(&tracking_area_update_accept->emergencynumberlist,
TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT) {
if ((encode_result =
encode_eps_network_feature_support(&tracking_area_update_accept->epsnetworkfeaturesupport,
TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_accept->presencemask & TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT)
== TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT) {
if ((encode_result =
encode_additional_update_result(&tracking_area_update_accept->additionalupdateresult,
TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EpsUpdateResult.h"
#include "GprsTimer.h"
#include "EpsMobileIdentity.h"
#include "TrackingAreaIdentityList.h"
#include "EpsBearerContextStatus.h"
#include "LocationAreaIdentification.h"
#include "MobileIdentity.h"
#include "EmmCause.h"
#include "PlmnList.h"
#include "EmergencyNumberList.h"
#include "EpsNetworkFeatureSupport.h"
#include "AdditionalUpdateResult.h"
#ifndef TRACKING_AREA_UPDATE_ACCEPT_H_
#define TRACKING_AREA_UPDATE_ACCEPT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define TRACKING_AREA_UPDATE_ACCEPT_MINIMUM_LENGTH ( \
EPS_UPDATE_RESULT_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define TRACKING_AREA_UPDATE_ACCEPT_MAXIMUM_LENGTH ( \
EPS_UPDATE_RESULT_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
TRACKING_AREA_IDENTITY_LIST_MAXIMUM_LENGTH + \
EPS_BEARER_CONTEXT_STATUS_MAXIMUM_LENGTH + \
LOCATION_AREA_IDENTIFICATION_MAXIMUM_LENGTH + \
MOBILE_IDENTITY_MAXIMUM_LENGTH + \
EMM_CAUSE_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH + \
GPRS_TIMER_MAXIMUM_LENGTH + \
PLMN_LIST_MAXIMUM_LENGTH + \
EMERGENCY_NUMBER_LIST_MAXIMUM_LENGTH + \
EPS_NETWORK_FEATURE_SUPPORT_MAXIMUM_LENGTH + \
ADDITIONAL_UPDATE_RESULT_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_PRESENT (1<<0)
# define TRACKING_AREA_UPDATE_ACCEPT_GUTI_PRESENT (1<<1)
# define TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_PRESENT (1<<2)
# define TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_PRESENT (1<<3)
# define TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT (1<<4)
# define TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_PRESENT (1<<5)
# define TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_PRESENT (1<<6)
# define TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_PRESENT (1<<7)
# define TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_PRESENT (1<<8)
# define TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_PRESENT (1<<9)
# define TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT (1<<10)
# define TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT (1<<11)
# define TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT (1<<12)
typedef enum tracking_area_update_accept_iei_tag {
TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_IEI = 0x5A, /* 0x5A = 90 */
TRACKING_AREA_UPDATE_ACCEPT_GUTI_IEI = 0x50, /* 0x50 = 80 */
TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_IEI = 0x54, /* 0x54 = 84 */
TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_IEI = 0x57, /* 0x57 = 87 */
TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_IEI = 0x13, /* 0x13 = 19 */
TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_IEI = 0x23, /* 0x23 = 35 */
TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_IEI = 0x53, /* 0x53 = 83 */
TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_IEI = 0x17, /* 0x17 = 23 */
TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_IEI = 0x59, /* 0x59 = 89 */
TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_IEI = 0x4A, /* 0x4A = 74 */
TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_IEI = 0x34, /* 0x34 = 52 */
TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_IEI = 0x64, /* 0x64 = 100 */
TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_IEI = 0xF0, /* 0xF0 = 240 */
} tracking_area_update_accept_iei;
/*
* Message name: Tracking area update accept
* Description: This message is sent by the network to the UE to provide the UE with EPS mobility management related data in response to a tracking area update request message. See table 8.2.26.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct tracking_area_update_accept_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EpsUpdateResult epsupdateresult;
/* Optional fields */
uint32_t presencemask;
GprsTimer t3412value;
EpsMobileIdentity guti;
TrackingAreaIdentityList tailist;
EpsBearerContextStatus epsbearercontextstatus;
LocationAreaIdentification locationareaidentification;
MobileIdentity msidentity;
EmmCause emmcause;
GprsTimer t3402value;
GprsTimer t3423value;
PlmnList equivalentplmns;
EmergencyNumberList emergencynumberlist;
EpsNetworkFeatureSupport epsnetworkfeaturesupport;
AdditionalUpdateResult additionalupdateresult;
} tracking_area_update_accept_msg;
int decode_tracking_area_update_accept(tracking_area_update_accept_msg *trackingareaupdateaccept, uint8_t *buffer, uint32_t len);
int encode_tracking_area_update_accept(tracking_area_update_accept_msg *trackingareaupdateaccept, uint8_t *buffer, uint32_t len);
#endif /* ! defined(TRACKING_AREA_UPDATE_ACCEPT_H_) */
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "TrackingAreaUpdateComplete.h"
int decode_tracking_area_update_complete(tracking_area_update_complete_msg *tracking_area_update_complete, uint8_t *buffer, uint32_t len)
{
uint32_t decoded = 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, TRACKING_AREA_UPDATE_COMPLETE_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
return decoded;
}
int encode_tracking_area_update_complete(tracking_area_update_complete_msg *tracking_area_update_complete, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, TRACKING_AREA_UPDATE_COMPLETE_MINIMUM_LENGTH, len);
return encoded;
}
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#ifndef TRACKING_AREA_UPDATE_COMPLETE_H_
#define TRACKING_AREA_UPDATE_COMPLETE_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define TRACKING_AREA_UPDATE_COMPLETE_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define TRACKING_AREA_UPDATE_COMPLETE_MAXIMUM_LENGTH (0)
/*
* Message name: Tracking area update complete
* Description: This message shall be sent by the UE to the network in response to a tracking area update accept message if a GUTI has been changed or a new TMSI has been assigned. See table 8.2.27.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct tracking_area_update_complete_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
} tracking_area_update_complete_msg;
int decode_tracking_area_update_complete(tracking_area_update_complete_msg *trackingareaupdatecomplete, uint8_t *buffer, uint32_t len);
int encode_tracking_area_update_complete(tracking_area_update_complete_msg *trackingareaupdatecomplete, uint8_t *buffer, uint32_t len);
#endif /* ! defined(TRACKING_AREA_UPDATE_COMPLETE_H_) */
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "TrackingAreaUpdateReject.h"
int decode_tracking_area_update_reject(tracking_area_update_reject_msg *tracking_area_update_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, TRACKING_AREA_UPDATE_REJECT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_emm_cause(&tracking_area_update_reject->emmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_tracking_area_update_reject(tracking_area_update_reject_msg *tracking_area_update_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, TRACKING_AREA_UPDATE_REJECT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_emm_cause(&tracking_area_update_reject->emmcause, 0, buffer +
encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EmmCause.h"
#ifndef TRACKING_AREA_UPDATE_REJECT_H_
#define TRACKING_AREA_UPDATE_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define TRACKING_AREA_UPDATE_REJECT_MINIMUM_LENGTH ( \
EMM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define TRACKING_AREA_UPDATE_REJECT_MAXIMUM_LENGTH ( \
EMM_CAUSE_MAXIMUM_LENGTH )
/*
* Message name: Tracking area update reject
* Description: This message is sent by the network to the UE in order to reject the tracking area updating procedure. See table 8.2.28.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct tracking_area_update_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EmmCause emmcause;
} tracking_area_update_reject_msg;
int decode_tracking_area_update_reject(tracking_area_update_reject_msg *trackingareaupdatereject, uint8_t *buffer, uint32_t len);
int encode_tracking_area_update_reject(tracking_area_update_reject_msg *trackingareaupdatereject, uint8_t *buffer, uint32_t len);
#endif /* ! defined(TRACKING_AREA_UPDATE_REJECT_H_) */
@@ -0,0 +1,532 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "TrackingAreaUpdateRequest.h"
int decode_tracking_area_update_request(tracking_area_update_request_msg *tracking_area_update_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, TRACKING_AREA_UPDATE_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_eps_update_type(&tracking_area_update_request->epsupdatetype, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
if ((decoded_result = decode_u8_nas_key_set_identifier(&tracking_area_update_request->naskeysetidentifier, 0, *(buffer + decoded) & 0x0f, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_eps_mobile_identity(&tracking_area_update_request->oldguti, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_IEI:
if ((decoded_result =
decode_nas_key_set_identifier(&tracking_area_update_request->noncurrentnativenaskeysetidentifier,
TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_IEI:
if ((decoded_result =
decode_ciphering_key_sequence_number(&tracking_area_update_request->gprscipheringkeysequencenumber,
TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_IEI:
if ((decoded_result =
decode_p_tmsi_signature(&tracking_area_update_request->oldptmsisignature,
TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_IEI:
if ((decoded_result =
decode_eps_mobile_identity(&tracking_area_update_request->additionalguti,
TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_NONCEUE_IEI:
if ((decoded_result =
decode_nonce(&tracking_area_update_request->nonceue,
TRACKING_AREA_UPDATE_REQUEST_NONCEUE_IEI, buffer + decoded,
len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_NONCEUE_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_IEI:
if ((decoded_result =
decode_ue_network_capability(&tracking_area_update_request->uenetworkcapability,
TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI:
if ((decoded_result =
decode_tracking_area_identity(&tracking_area_update_request->lastvisitedregisteredtai,
TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_IEI:
if ((decoded_result =
decode_drx_parameter(&tracking_area_update_request->drxparameter,
TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_IEI:
if ((decoded_result =
decode_ue_radio_capability_information_update_needed(&tracking_area_update_request->ueradiocapabilityinformationupdateneeded,
TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_IEI:
if ((decoded_result =
decode_eps_bearer_context_status(&tracking_area_update_request->epsbearercontextstatus,
TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_IEI:
if ((decoded_result =
decode_ms_network_capability(&tracking_area_update_request->msnetworkcapability,
TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI:
if ((decoded_result =
decode_location_area_identification(&tracking_area_update_request->oldlocationareaidentification,
TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_IEI:
if ((decoded_result =
decode_tmsi_status(&tracking_area_update_request->tmsistatus,
TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI:
if ((decoded_result =
decode_mobile_station_classmark_2(&tracking_area_update_request->mobilestationclassmark2,
TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI:
if ((decoded_result =
decode_mobile_station_classmark_3(&tracking_area_update_request->mobilestationclassmark3,
TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_IEI:
if ((decoded_result =
decode_supported_codec_list(&tracking_area_update_request->supportedcodecs,
TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_IEI, buffer +
decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI:
if ((decoded_result =
decode_additional_update_type(&tracking_area_update_request->additionalupdatetype,
TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT;
break;
case TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_IEI:
if ((decoded_result =
decode_guti_type(&tracking_area_update_request->oldgutitype,
TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
tracking_area_update_request->presencemask |= TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_tracking_area_update_request(tracking_area_update_request_msg *tracking_area_update_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, TRACKING_AREA_UPDATE_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_eps_update_type(&tracking_area_update_request->epsupdatetype) & 0x0f) << 4) | (encode_u8_nas_key_set_identifier(
&tracking_area_update_request->naskeysetidentifier) & 0x0f);
encoded++;
if ((encode_result =
encode_eps_mobile_identity(&tracking_area_update_request->oldguti, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_PRESENT) {
if ((encode_result =
encode_nas_key_set_identifier(&tracking_area_update_request->noncurrentnativenaskeysetidentifier,
TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_PRESENT) {
if ((encode_result =
encode_ciphering_key_sequence_number(&tracking_area_update_request->gprscipheringkeysequencenumber,
TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT) {
if ((encode_result =
encode_p_tmsi_signature(&tracking_area_update_request->oldptmsisignature,
TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_PRESENT) {
if ((encode_result =
encode_eps_mobile_identity(&tracking_area_update_request->additionalguti,
TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_NONCEUE_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_NONCEUE_PRESENT) {
if ((encode_result =
encode_nonce(&tracking_area_update_request->nonceue,
TRACKING_AREA_UPDATE_REQUEST_NONCEUE_IEI, buffer + encoded, len -
encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_PRESENT) {
if ((encode_result =
encode_ue_network_capability(&tracking_area_update_request->uenetworkcapability,
TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT) {
if ((encode_result =
encode_tracking_area_identity(&tracking_area_update_request->lastvisitedregisteredtai,
TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_PRESENT) {
if ((encode_result =
encode_drx_parameter(&tracking_area_update_request->drxparameter,
TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_IEI, buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_PRESENT) {
if ((encode_result =
encode_ue_radio_capability_information_update_needed(&tracking_area_update_request->ueradiocapabilityinformationupdateneeded,
TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT) {
if ((encode_result =
encode_eps_bearer_context_status(&tracking_area_update_request->epsbearercontextstatus,
TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_IEI, buffer
+ encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_PRESENT) {
if ((encode_result =
encode_ms_network_capability(&tracking_area_update_request->msnetworkcapability,
TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT) {
if ((encode_result =
encode_location_area_identification(&tracking_area_update_request->oldlocationareaidentification,
TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_PRESENT) {
if ((encode_result =
encode_tmsi_status(&tracking_area_update_request->tmsistatus,
TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_IEI, buffer + encoded,
len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT) {
if ((encode_result =
encode_mobile_station_classmark_2(&tracking_area_update_request->mobilestationclassmark2,
TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT) {
if ((encode_result =
encode_mobile_station_classmark_3(&tracking_area_update_request->mobilestationclassmark3,
TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_PRESENT) {
if ((encode_result =
encode_supported_codec_list(&tracking_area_update_request->supportedcodecs,
TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT) {
if ((encode_result =
encode_additional_update_type(&tracking_area_update_request->additionalupdatetype,
TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((tracking_area_update_request->presencemask & TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_PRESENT)
== TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_PRESENT) {
if ((encode_result =
encode_guti_type(&tracking_area_update_request->oldgutitype,
TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,173 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "EpsUpdateType.h"
#include "NasKeySetIdentifier.h"
#include "EpsMobileIdentity.h"
#include "CipheringKeySequenceNumber.h"
#include "PTmsiSignature.h"
#include "Nonce.h"
#include "UeNetworkCapability.h"
#include "TrackingAreaIdentity.h"
#include "DrxParameter.h"
#include "UeRadioCapabilityInformationUpdateNeeded.h"
#include "EpsBearerContextStatus.h"
#include "MsNetworkCapability.h"
#include "LocationAreaIdentification.h"
#include "TmsiStatus.h"
#include "MobileStationClassmark2.h"
#include "MobileStationClassmark3.h"
#include "SupportedCodecList.h"
#include "AdditionalUpdateType.h"
#include "GutiType.h"
#ifndef TRACKING_AREA_UPDATE_REQUEST_H_
#define TRACKING_AREA_UPDATE_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define TRACKING_AREA_UPDATE_REQUEST_MINIMUM_LENGTH ( \
EPS_UPDATE_TYPE_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define TRACKING_AREA_UPDATE_REQUEST_MAXIMUM_LENGTH ( \
EPS_UPDATE_TYPE_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
CIPHERING_KEY_SEQUENCE_NUMBER_MAXIMUM_LENGTH + \
P_TMSI_SIGNATURE_MAXIMUM_LENGTH + \
EPS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
NONCE_MAXIMUM_LENGTH + \
UE_NETWORK_CAPABILITY_MAXIMUM_LENGTH + \
TRACKING_AREA_IDENTITY_MAXIMUM_LENGTH + \
DRX_PARAMETER_MAXIMUM_LENGTH + \
UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_MAXIMUM_LENGTH + \
EPS_BEARER_CONTEXT_STATUS_MAXIMUM_LENGTH + \
MS_NETWORK_CAPABILITY_MAXIMUM_LENGTH + \
LOCATION_AREA_IDENTIFICATION_MAXIMUM_LENGTH + \
TMSI_STATUS_MAXIMUM_LENGTH + \
MOBILE_STATION_CLASSMARK_2_MAXIMUM_LENGTH + \
MOBILE_STATION_CLASSMARK_3_MAXIMUM_LENGTH + \
SUPPORTED_CODEC_LIST_MAXIMUM_LENGTH + \
ADDITIONAL_UPDATE_TYPE_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_PRESENT (1<<0)
# define TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_PRESENT (1<<1)
# define TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_PRESENT (1<<2)
# define TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_PRESENT (1<<3)
# define TRACKING_AREA_UPDATE_REQUEST_NONCEUE_PRESENT (1<<4)
# define TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_PRESENT (1<<5)
# define TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT (1<<6)
# define TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_PRESENT (1<<7)
# define TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_PRESENT (1<<8)
# define TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT (1<<9)
# define TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_PRESENT (1<<10)
# define TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT (1<<11)
# define TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_PRESENT (1<<12)
# define TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT (1<<13)
# define TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT (1<<14)
# define TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_PRESENT (1<<15)
# define TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT (1<<16)
# define TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_PRESENT (1<<17)
typedef enum tracking_area_update_request_iei_tag {
TRACKING_AREA_UPDATE_REQUEST_NONCURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_IEI = 0xB0, /* 0xB0 = 176 */
TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_IEI = 0x80, /* 0x80 = 128 */
TRACKING_AREA_UPDATE_REQUEST_OLD_PTMSI_SIGNATURE_IEI = 0x19, /* 0x19 = 25 */
TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_IEI = 0x50, /* 0x50 = 80 */
TRACKING_AREA_UPDATE_REQUEST_NONCEUE_IEI = 0x55, /* 0x55 = 85 */
TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_IEI = 0x58, /* 0x58 = 88 */
TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI = 0x52, /* 0x52 = 82 */
TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_IEI = 0x5C, /* 0x5C = 92 */
TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_IEI = 0xA0, /* 0xA0 = 160 */
TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_IEI = 0x57, /* 0x57 = 87 */
TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_IEI = 0x31, /* 0x31 = 49 */
TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_IEI = 0x13, /* 0x13 = 19 */
TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_IEI = 0x90, /* 0x90 = 144 */
TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_IEI = 0x11, /* 0x11 = 17 */
TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_IEI = 0x20, /* 0x20 = 32 */
TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_IEI = 0x40, /* 0x40 = 64 */
TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_IEI = 0xF0, /* 0xF0 = 240 */
TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_IEI = 0xE0, /* 0xE0 = 224 */
} tracking_area_update_request_iei;
/*
* Message name: Tracking area update request
* Description: The purposes of sending the tracking area update request by the UE to the network are described in subclause 5.5.3.1. See table 8.2.29.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct tracking_area_update_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
EpsUpdateType epsupdatetype;
NasKeySetIdentifier naskeysetidentifier;
EpsMobileIdentity oldguti;
/* Optional fields */
uint32_t presencemask;
NasKeySetIdentifier noncurrentnativenaskeysetidentifier;
CipheringKeySequenceNumber gprscipheringkeysequencenumber;
PTmsiSignature oldptmsisignature;
EpsMobileIdentity additionalguti;
Nonce nonceue;
UeNetworkCapability uenetworkcapability;
TrackingAreaIdentity lastvisitedregisteredtai;
DrxParameter drxparameter;
UeRadioCapabilityInformationUpdateNeeded ueradiocapabilityinformationupdateneeded;
EpsBearerContextStatus epsbearercontextstatus;
MsNetworkCapability msnetworkcapability;
LocationAreaIdentification oldlocationareaidentification;
TmsiStatus tmsistatus;
MobileStationClassmark2 mobilestationclassmark2;
MobileStationClassmark3 mobilestationclassmark3;
SupportedCodecList supportedcodecs;
AdditionalUpdateType additionalupdatetype;
GutiType oldgutitype;
} tracking_area_update_request_msg;
int decode_tracking_area_update_request(tracking_area_update_request_msg *trackingareaupdaterequest, uint8_t *buffer, uint32_t len);
int encode_tracking_area_update_request(tracking_area_update_request_msg *trackingareaupdaterequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(TRACKING_AREA_UPDATE_REQUEST_H_) */
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "UplinkNasTransport.h"
int decode_uplink_nas_transport(uplink_nas_transport_msg *uplink_nas_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, UPLINK_NAS_TRANSPORT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_nas_message_container(&uplink_nas_transport->nasmessagecontainer, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
return decoded;
}
int encode_uplink_nas_transport(uplink_nas_transport_msg *uplink_nas_transport, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, UPLINK_NAS_TRANSPORT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_nas_message_container(&uplink_nas_transport->nasmessagecontainer,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
return encoded;
}
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "SecurityHeaderType.h"
#include "MessageType.h"
#include "NasMessageContainer.h"
#ifndef UPLINK_NAS_TRANSPORT_H_
#define UPLINK_NAS_TRANSPORT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define UPLINK_NAS_TRANSPORT_MINIMUM_LENGTH ( \
NAS_MESSAGE_CONTAINER_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define UPLINK_NAS_TRANSPORT_MAXIMUM_LENGTH ( \
NAS_MESSAGE_CONTAINER_MAXIMUM_LENGTH )
/*
* Message name: Uplink NAS Transport
* Description: This message is sent by the UE to the network in order to carry an SMS message in encapsulated format. See table 8.2.30.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct uplink_nas_transport_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
SecurityHeaderType securityheadertype:4;
MessageType messagetype;
NasMessageContainer nasmessagecontainer;
} uplink_nas_transport_msg;
int decode_uplink_nas_transport(uplink_nas_transport_msg *uplinknastransport, uint8_t *buffer, uint32_t len);
int encode_uplink_nas_transport(uplink_nas_transport_msg *uplinknastransport, uint8_t *buffer, uint32_t len);
#endif /* ! defined(UPLINK_NAS_TRANSPORT_H_) */
+132
View File
@@ -0,0 +1,132 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source emm_cause.h
Version 0.1
Date 2013/01/30
Product NAS stack
Subsystem EPS Mobility Management
Author Frederic Maurel
Description Defines error cause code returned upon receiving unknown,
unforeseen, and erroneous EPS mobility management protocol
data.
*****************************************************************************/
#ifndef __EMM_CAUSE_H__
#define __EMM_CAUSE_H__
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* Cause code used to notify that the EPS mobility management procedure
* has been successfully processed
*/
#define EMM_CAUSE_SUCCESS (-1)
/*
* Causes related to UE identification (TS 24.301 - Annex A1)
*/
#define EMM_CAUSE_IMSI_UNKNOWN_IN_HSS 2
#define EMM_CAUSE_ILLEGAL_UE 3
#define EMM_CAUSE_ILLEGAL_ME 6
#define EMM_CAUSE_INVALID_UE 9
#define EMM_CAUSE_IMPLICITLY_DETACHED 10
/*
* Causes related to subscription options (TS 24.301 - Annex A2)
*/
#define EMM_CAUSE_IMEI_NOT_ACCEPTED 5
#define EMM_CAUSE_EPS_NOT_ALLOWED 7
#define EMM_CAUSE_BOTH_NOT_ALLOWED 8
#define EMM_CAUSE_PLMN_NOT_ALLOWED 11
#define EMM_CAUSE_TA_NOT_ALLOWED 12
#define EMM_CAUSE_ROAMING_NOT_ALLOWED 13
#define EMM_CAUSE_EPS_NOT_ALLOWED_IN_PLMN 14
#define EMM_CAUSE_NO_SUITABLE_CELLS 15
#define EMM_CAUSE_CSG_NOT_AUTHORIZED 25
#define EMM_CAUSE_NOT_AUTHORIZED_IN_PLMN 35
#define EMM_CAUSE_NO_EPS_BEARER_CTX_ACTIVE 40
/*
* Causes related to PLMN specific network failures and congestion/
* authentication failures (TS 24.301 - Annex A3)
*/
#define EMM_CAUSE_MSC_NOT_REACHABLE 16
#define EMM_CAUSE_NETWORK_FAILURE 17
#define EMM_CAUSE_CS_DOMAIN_NOT_AVAILABLE 18
#define EMM_CAUSE_ESM_FAILURE 19
#define EMM_CAUSE_MAC_FAILURE 20
#define EMM_CAUSE_SYNCH_FAILURE 21
#define EMM_CAUSE_CONGESTION 22
#define EMM_CAUSE_UE_SECURITY_MISMATCH 23
#define EMM_CAUSE_SECURITY_MODE_REJECTED 24
#define EMM_CAUSE_NON_EPS_AUTH_UNACCEPTABLE 26
#define EMM_CAUSE_CS_SERVICE_NOT_AVAILABLE 39
/*
* Causes related to invalid messages (TS 24.301 - Annex A5)
*/
#define EMM_CAUSE_SEMANTICALLY_INCORRECT 95
#define EMM_CAUSE_INVALID_MANDATORY_INFO 96
#define EMM_CAUSE_MESSAGE_TYPE_NOT_IMPLEMENTED 97
#define EMM_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE 98
#define EMM_CAUSE_IE_NOT_IMPLEMENTED 99
#define EMM_CAUSE_CONDITIONAL_IE_ERROR 100
#define EMM_CAUSE_MESSAGE_NOT_COMPATIBLE 101
#define EMM_CAUSE_PROTOCOL_ERROR 111
/*
* TS 24.301 - Table 9.9.3.9.1
* Any other value received by the mobile station shall be treated as cause
* code #111 "protocol error, unspecified".
* Any other value received by the network shall be treated as cause code #111
* "protocol error, unspecified".
*/
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
#endif /* __EMM_CAUSE_H__*/
+568
View File
@@ -0,0 +1,568 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source emm_msg.c
Version 0.1
Date 2012/09/27
Product NAS stack
Subsystem EPS Mobility Management
Author Frederic Maurel, Sebastien Roux
Description Defines EPS Mobility Management messages
*****************************************************************************/
#include "emm_msg.h"
#include "commonDef.h"
#include "nas_log.h"
#include "TLVDecoder.h"
#include "TLVEncoder.h"
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
# include "nas_itti_messaging.h"
#endif
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
/****************************************************************************/
static int _emm_msg_decode_header(emm_msg_header_t *header,
const uint8_t *buffer, uint32_t len);
static int _emm_msg_encode_header(const emm_msg_header_t *header,
uint8_t *buffer, uint32_t len);
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
/****************************************************************************
** **
** Name: emm_msg_decode() **
** **
** Description: Decode EPS Mobility Management messages **
** **
** Inputs: buffer: Pointer to the buffer containing the EMM **
** message data **
** len: Number of bytes that should be decoded **
** Others: None **
** **
** Outputs: msg: The EMM message structure to be filled **
** Return: The number of bytes in the buffer if data **
** have been successfully decoded; **
** A negative error code otherwise. **
** Others: None **
** **
***************************************************************************/
int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len)
{
LOG_FUNC_IN;
int header_result;
int decode_result;
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
uint8_t *buffer_log = buffer;
uint32_t len_log = len;
int down_link;
# if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)))
down_link = 0;
# else
down_link = 1;
# endif
#endif
/* First decode the EMM message header */
header_result = _emm_msg_decode_header(&msg->header, buffer, len);
if (header_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to decode EMM message header "
"(%d)", header_result);
LOG_FUNC_RETURN(header_result);
}
buffer += header_result;
len -= header_result;
LOG_TRACE(INFO, "EMM-MSG - Message Type 0x%02x", msg->header.message_type);
switch(msg->header.message_type) {
case EMM_INFORMATION:
decode_result = decode_emm_information(&msg->emm_information, buffer, len);
break;
case UPLINK_NAS_TRANSPORT:
decode_result = decode_uplink_nas_transport(&msg->uplink_nas_transport, 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 DETACH_ACCEPT:
decode_result = decode_detach_accept(&msg->detach_accept, buffer, len);
break;
case SERVICE_REJECT:
decode_result = decode_service_reject(&msg->service_reject, buffer, len);
break;
case AUTHENTICATION_REQUEST:
decode_result = decode_authentication_request(&msg->authentication_request,
buffer, len);
break;
case TRACKING_AREA_UPDATE_REQUEST:
decode_result = decode_tracking_area_update_request(
&msg->tracking_area_update_request, buffer, len);
break;
case ATTACH_REQUEST:
decode_result = decode_attach_request(&msg->attach_request, buffer, len);
break;
case EMM_STATUS:
decode_result = decode_emm_status(&msg->emm_status, buffer, len);
break;
case IDENTITY_RESPONSE:
decode_result = decode_identity_response(&msg->identity_response, buffer, len);
break;
case IDENTITY_REQUEST:
decode_result = decode_identity_request(&msg->identity_request, buffer, len);
break;
case GUTI_REALLOCATION_COMMAND:
decode_result = decode_guti_reallocation_command(&msg->guti_reallocation_command,
buffer, len);
break;
case TRACKING_AREA_UPDATE_REJECT:
decode_result = decode_tracking_area_update_reject(
&msg->tracking_area_update_reject, buffer, len);
break;
case ATTACH_ACCEPT:
decode_result = decode_attach_accept(&msg->attach_accept, buffer, len);
break;
case SECURITY_MODE_COMPLETE:
decode_result = decode_security_mode_complete(&msg->security_mode_complete,
buffer, len);
break;
case TRACKING_AREA_UPDATE_ACCEPT:
decode_result = decode_tracking_area_update_accept(
&msg->tracking_area_update_accept, buffer, len);
break;
case ATTACH_REJECT:
decode_result = decode_attach_reject(&msg->attach_reject, buffer, len);
break;
case ATTACH_COMPLETE:
decode_result = decode_attach_complete(&msg->attach_complete, buffer, len);
break;
case TRACKING_AREA_UPDATE_COMPLETE:
decode_result = decode_tracking_area_update_complete(
&msg->tracking_area_update_complete, buffer, len);
break;
case CS_SERVICE_NOTIFICATION:
decode_result = decode_cs_service_notification(&msg->cs_service_notification,
buffer, len);
break;
case SECURITY_MODE_REJECT:
decode_result = decode_security_mode_reject(&msg->security_mode_reject, buffer,
len);
break;
case DETACH_REQUEST:
decode_result = decode_detach_request(&msg->detach_request, buffer, len);
break;
case GUTI_REALLOCATION_COMPLETE:
decode_result = decode_guti_reallocation_complete(
&msg->guti_reallocation_complete, buffer, len);
break;
case SECURITY_MODE_COMMAND:
decode_result = decode_security_mode_command(&msg->security_mode_command,
buffer, len);
break;
case DOWNLINK_NAS_TRANSPORT:
decode_result = decode_downlink_nas_transport(&msg->downlink_nas_transport,
buffer, len);
break;
case EXTENDED_SERVICE_REQUEST:
decode_result = decode_extended_service_request(&msg->extended_service_request,
buffer, len);
break;
case AUTHENTICATION_RESPONSE:
decode_result = decode_authentication_response(&msg->authentication_response,
buffer, len);
break;
default:
LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x",
msg->header.message_type);
decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE;
/* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */
}
if (decode_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to decode L3 EMM message 0x%x "
"(%d)", msg->header.message_type, decode_result);
LOG_FUNC_RETURN (decode_result);
} else {
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
/* Message has been decoded and security header removed, handle it has a plain message */
nas_itti_plain_msg((char *) buffer_log, (nas_message_t *) msg, len_log, down_link);
#endif
}
LOG_FUNC_RETURN (header_result + decode_result);
}
/****************************************************************************
** **
** 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 emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len)
{
LOG_FUNC_IN;
int header_result;
int encode_result;
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
uint8_t *buffer_log = buffer;
int down_link;
# if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)))
down_link = 1;
# else
down_link = 0;
# endif
#endif
/* First encode the EMM message header */
header_result = _emm_msg_encode_header(&msg->header, buffer, len);
if (header_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to encode EMM message header "
"(%d)", header_result);
LOG_FUNC_RETURN(header_result);
}
buffer += header_result;
len -= header_result;
switch(msg->header.message_type) {
case EMM_INFORMATION:
encode_result = encode_emm_information(&msg->emm_information, buffer, len);
break;
case UPLINK_NAS_TRANSPORT:
encode_result = encode_uplink_nas_transport(&msg->uplink_nas_transport, 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 DETACH_ACCEPT:
encode_result = encode_detach_accept(&msg->detach_accept, buffer, len);
break;
case SERVICE_REJECT:
encode_result = encode_service_reject(&msg->service_reject, buffer, len);
break;
case AUTHENTICATION_REQUEST:
encode_result = encode_authentication_request(&msg->authentication_request,
buffer, len);
break;
case TRACKING_AREA_UPDATE_REQUEST:
encode_result = encode_tracking_area_update_request(
&msg->tracking_area_update_request, buffer, len);
break;
case ATTACH_REQUEST:
encode_result = encode_attach_request(&msg->attach_request, buffer, len);
break;
case EMM_STATUS:
encode_result = encode_emm_status(&msg->emm_status, buffer, len);
break;
case IDENTITY_RESPONSE:
encode_result = encode_identity_response(&msg->identity_response, buffer, len);
break;
case IDENTITY_REQUEST:
encode_result = encode_identity_request(&msg->identity_request, buffer, len);
break;
case GUTI_REALLOCATION_COMMAND:
encode_result = encode_guti_reallocation_command(&msg->guti_reallocation_command,
buffer, len);
break;
case TRACKING_AREA_UPDATE_REJECT:
encode_result = encode_tracking_area_update_reject(
&msg->tracking_area_update_reject, buffer, len);
break;
case ATTACH_ACCEPT:
encode_result = encode_attach_accept(&msg->attach_accept, buffer, len);
break;
case SECURITY_MODE_COMPLETE:
encode_result = encode_security_mode_complete(&msg->security_mode_complete,
buffer, len);
break;
case TRACKING_AREA_UPDATE_ACCEPT:
encode_result = encode_tracking_area_update_accept(
&msg->tracking_area_update_accept, buffer, len);
break;
case ATTACH_REJECT:
encode_result = encode_attach_reject(&msg->attach_reject, buffer, len);
break;
case ATTACH_COMPLETE:
encode_result = encode_attach_complete(&msg->attach_complete, buffer, len);
break;
case TRACKING_AREA_UPDATE_COMPLETE:
encode_result = encode_tracking_area_update_complete(
&msg->tracking_area_update_complete, buffer, len);
break;
case CS_SERVICE_NOTIFICATION:
encode_result = encode_cs_service_notification(&msg->cs_service_notification,
buffer, len);
break;
case SECURITY_MODE_REJECT:
encode_result = encode_security_mode_reject(&msg->security_mode_reject, buffer,
len);
break;
case DETACH_REQUEST:
encode_result = encode_detach_request(&msg->detach_request, buffer, len);
break;
case GUTI_REALLOCATION_COMPLETE:
encode_result = encode_guti_reallocation_complete(
&msg->guti_reallocation_complete, buffer, len);
break;
case SECURITY_MODE_COMMAND:
encode_result = encode_security_mode_command(&msg->security_mode_command,
buffer, len);
break;
case DOWNLINK_NAS_TRANSPORT:
encode_result = encode_downlink_nas_transport(&msg->downlink_nas_transport,
buffer, len);
break;
case EXTENDED_SERVICE_REQUEST:
encode_result = encode_extended_service_request(&msg->extended_service_request,
buffer, len);
break;
case AUTHENTICATION_RESPONSE:
encode_result = encode_authentication_response(&msg->authentication_response,
buffer, len);
break;
case SERVICE_REQUEST:
encode_result = encode_service_request(&msg->service_request, buffer, len);
break;
default:
LOG_TRACE(ERROR, "EMM-MSG - Unexpected message type: 0x%x",
msg->header.message_type);
encode_result = TLV_ENCODE_WRONG_MESSAGE_TYPE;
/* TODO: Handle not standard layer 3 messages: SERVICE_REQUEST */
}
if (encode_result < 0) {
LOG_TRACE(ERROR, "EMM-MSG - Failed to encode L3 EMM message 0x%x "
"(%d)", msg->header.message_type, encode_result);
} else {
#if ((defined(NAS_BUILT_IN_EPC) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(NAS_BUILT_IN_UE) && defined(NAS_UE)))
nas_itti_plain_msg((char *) buffer_log, (nas_message_t *) msg, header_result + encode_result, down_link);
#endif
}
LOG_FUNC_RETURN (header_result + encode_result);
}
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
/****************************************************************************/
/****************************************************************************
** **
** Name: _emm_msg_decode_header() **
** **
** Description: Decode header of EPS Mobility Management message. **
** The protocol discriminator and the security header type **
** have already been decoded. **
** **
** Inputs: buffer: Pointer to the buffer containing the EMM **
** message **
** len: Number of bytes that should be decoded **
** Others: None **
** **
** Outputs: header: The EMM message header to be filled **
** Return: The size of the header if data have been **
** successfully decoded; **
** A negative error code otherwise. **
** Others: None **
** **
***************************************************************************/
static int _emm_msg_decode_header(emm_msg_header_t *header,
const uint8_t *buffer, uint32_t len)
{
int size = 0;
/* Check the buffer length */
if (len < sizeof(emm_msg_header_t)) {
return (TLV_DECODE_BUFFER_TOO_SHORT);
}
/* Decode the security header type and the protocol discriminator */
DECODE_U8(buffer + size, *(uint8_t *)(header), size);
/* Decode the message type */
DECODE_U8(buffer + size, header->message_type, size);
/* Check the protocol discriminator */
if (header->protocol_discriminator != EPS_MOBILITY_MANAGEMENT_MESSAGE) {
LOG_TRACE(ERROR, "ESM-MSG - Unexpected protocol discriminator: 0x%x",
header->protocol_discriminator);
return (TLV_DECODE_PROTOCOL_NOT_SUPPORTED);
}
return (size);
}
/****************************************************************************
** **
** 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 _emm_msg_encode_header(const emm_msg_header_t *header,
uint8_t *buffer, uint32_t len)
{
int size = 0;
/* Check the buffer length */
if (len < sizeof(emm_msg_header_t)) {
return (TLV_ENCODE_BUFFER_TOO_SHORT);
}
/* Check the protocol discriminator */
if (header->protocol_discriminator != EPS_MOBILITY_MANAGEMENT_MESSAGE) {
LOG_TRACE(ERROR, "ESM-MSG - Unexpected protocol discriminator: 0x%x",
header->protocol_discriminator);
return (TLV_ENCODE_PROTOCOL_NOT_SUPPORTED);
}
/* Encode the security header type and the protocol discriminator */
ENCODE_U8(buffer + size, *(uint8_t *)(header), size);
/* Encode the message type */
ENCODE_U8(buffer + size, header->message_type, size);
return (size);
}
+141
View File
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Source emm_msg.h
Version 0.1
Date 2012/09/27
Product NAS stack
Subsystem EPS Mobility Management
Author Frederic Maurel
Description Defines EPS Mobility Management messages and functions used
to encode and decode
*****************************************************************************/
#ifndef __EMM_MSG_H__
#define __EMM_MSG_H__
#include "emm_msgDef.h"
#include "AttachRequest.h"
#include "AttachAccept.h"
#include "AttachComplete.h"
#include "AttachReject.h"
#include "DetachRequest.h"
#include "DetachAccept.h"
#include "TrackingAreaUpdateRequest.h"
#include "TrackingAreaUpdateAccept.h"
#include "TrackingAreaUpdateComplete.h"
#include "TrackingAreaUpdateReject.h"
#include "ExtendedServiceRequest.h"
#include "ServiceRequest.h"
#include "ServiceReject.h"
#include "GutiReallocationCommand.h"
#include "GutiReallocationComplete.h"
#include "AuthenticationRequest.h"
#include "AuthenticationResponse.h"
#include "AuthenticationReject.h"
#include "AuthenticationFailure.h"
#include "IdentityRequest.h"
#include "IdentityResponse.h"
#include "NASSecurityModeCommand.h"
#include "NASSecurityModeComplete.h"
#include "SecurityModeReject.h"
#include "EmmStatus.h"
#include "EmmInformation.h"
#include "DownlinkNasTransport.h"
#include "UplinkNasTransport.h"
#include "CsServiceNotification.h"
#include <stdint.h>
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* Structure of EMM plain NAS message
* ----------------------------------
*/
typedef union {
emm_msg_header_t header;
attach_request_msg attach_request;
attach_accept_msg attach_accept;
attach_complete_msg attach_complete;
attach_reject_msg attach_reject;
detach_request_msg detach_request;
detach_accept_msg detach_accept;
tracking_area_update_request_msg tracking_area_update_request;
tracking_area_update_accept_msg tracking_area_update_accept;
tracking_area_update_complete_msg tracking_area_update_complete;
tracking_area_update_reject_msg tracking_area_update_reject;
extended_service_request_msg extended_service_request;
service_request_msg service_request;
service_reject_msg service_reject;
guti_reallocation_command_msg guti_reallocation_command;
guti_reallocation_complete_msg guti_reallocation_complete;
authentication_request_msg authentication_request;
authentication_response_msg authentication_response;
authentication_reject_msg authentication_reject;
authentication_failure_msg authentication_failure;
identity_request_msg identity_request;
identity_response_msg identity_response;
security_mode_command_msg security_mode_command;
security_mode_complete_msg security_mode_complete;
security_mode_reject_msg security_mode_reject;
emm_status_msg emm_status;
emm_information_msg emm_information;
downlink_nas_transport_msg downlink_nas_transport;
uplink_nas_transport_msg uplink_nas_transport;
cs_service_notification_msg cs_service_notification;
} EMM_msg;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int emm_msg_decode(EMM_msg *msg, uint8_t *buffer, uint32_t len);
int emm_msg_encode(EMM_msg *msg, uint8_t *buffer, uint32_t len);
#endif /* __EMM_MSG_H__ */
+137
View File
@@ -0,0 +1,137 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
/*****************************************************************************
Version 0.1
Date 2012/09/27
Product NAS stack
Subsystem EPS Mobility Management
Author Frederic Maurel, Sebastien Roux
Description Defines identifiers of the EPS Mobility Management messages.
*****************************************************************************/
#ifndef __EMM_MSGDEF_H__
#define __EMM_MSGDEF_H__
#include <stdint.h>
#include <asm/byteorder.h>
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/* Header length boundaries of EPS Mobility Management messages */
#define EMM_HEADER_LENGTH sizeof(emm_msg_header_t)
#define EMM_HEADER_MINIMUM_LENGTH EMM_HEADER_LENGTH
#define EMM_HEADER_MAXIMUM_LENGTH EMM_HEADER_LENGTH
/* EPS Mobility Management Security header type */
#define SECURITY_HEADER_TYPE_NOT_PROTECTED 0b0000
#define SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED 0b0001
#define SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED 0b0010
#define SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_NEW 0b0011
#define SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED_CYPHERED_NEW 0b0100
#define SECURITY_HEADER_TYPE_SERVICE_REQUEST 0b1100
/* Message identifiers for EPS Mobility Management */
# define ATTACH_REQUEST 0b01000001 /* 65 = 0x41 */
# define ATTACH_ACCEPT 0b01000010 /* 66 = 0x42 */
# define ATTACH_COMPLETE 0b01000011 /* 67 = 0x43 */
# define ATTACH_REJECT 0b01000100 /* 68 = 0x44 */
# define DETACH_REQUEST 0b01000101 /* 69 = 0x45 */
# define DETACH_ACCEPT 0b01000110 /* 70 = 0x46 */
# define TRACKING_AREA_UPDATE_REQUEST 0b01001000 /* 72 = 0x48 */
# define TRACKING_AREA_UPDATE_ACCEPT 0b01001001 /* 73 = 0x49 */
# define TRACKING_AREA_UPDATE_COMPLETE 0b01001010 /* 74 = 0x4a */
# define TRACKING_AREA_UPDATE_REJECT 0b01001011 /* 75 = 0x4b */
# define EXTENDED_SERVICE_REQUEST 0b01001100 /* 76 = 0x4c */
# define SERVICE_REJECT 0b01001110 /* 78 = 0x4e */
# define GUTI_REALLOCATION_COMMAND 0b01010000 /* 80 = 0x50 */
# define GUTI_REALLOCATION_COMPLETE 0b01010001 /* 81 = 0x51 */
# define AUTHENTICATION_REQUEST 0b01010010 /* 82 = 0x52 */
# define AUTHENTICATION_RESPONSE 0b01010011 /* 83 = 0x53 */
# define AUTHENTICATION_REJECT 0b01010100 /* 84 = 0x54 */
# define AUTHENTICATION_FAILURE 0b01011100 /* 92 = 0x5c */
# define IDENTITY_REQUEST 0b01010101 /* 85 = 0x55 */
# define IDENTITY_RESPONSE 0b01010110 /* 86 = 0x56 */
# define SECURITY_MODE_COMMAND 0b01011101 /* 93 = 0x5d */
# define SECURITY_MODE_COMPLETE 0b01011110 /* 94 = 0x5e */
# define SECURITY_MODE_REJECT 0b01011111 /* 95 = 0x5f */
# define EMM_STATUS 0b01100000 /* 96 = 0x60 */
# define EMM_INFORMATION 0b01100001 /* 97 = 0x61 */
# define DOWNLINK_NAS_TRANSPORT 0b01100010 /* 98 = 0x62 */
# define UPLINK_NAS_TRANSPORT 0b01100011 /* 99 = 0x63 */
# define CS_SERVICE_NOTIFICATION 0b01100100 /* 100 = 0x64 */
/*
* Message identifiers for EMM messages that does not follow the structure
* of a standard layer 3 message
*/
# define SERVICE_REQUEST 0b01001101 /* TODO: TBD - 77 = 0x4d */
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* Header of EPS Mobility Management plain NAS message
* ---------------------------------------------------
* 8 7 6 5 4 3 2 1
* +-----------------------+------------------------+
* | Security header type | Protocol discriminator |
* +-----------------------+------------------------+
* | Message type |
* +-----------------------+------------------------+
*/
typedef struct {
#ifdef __LITTLE_ENDIAN_BITFIELD
uint8_t protocol_discriminator:4;
uint8_t security_header_type:4;
#endif
#ifdef __BIG_ENDIAN_BITFIELD
uint8_t security_header_type:4;
uint8_t protocol_discriminator:4;
#endif
uint8_t message_type;
} __attribute__((__packed__)) emm_msg_header_t;
/****************************************************************************/
/******************** G L O B A L V A R I A B L E S ********************/
/****************************************************************************/
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
#endif /* __EMM_MSGDEF_H__ */
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ActivateDedicatedEpsBearerContextAccept.h"
int decode_activate_dedicated_eps_bearer_context_accept(activate_dedicated_eps_bearer_context_accept_msg *activate_dedicated_eps_bearer_context_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, ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_accept->protocolconfigurationoptions,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_accept->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_activate_dedicated_eps_bearer_context_accept(activate_dedicated_eps_bearer_context_accept_msg *activate_dedicated_eps_bearer_context_accept, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH, len);
if ((activate_dedicated_eps_bearer_context_accept->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_accept->protocolconfigurationoptions,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "ProtocolConfigurationOptions.h"
#ifndef ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_H_
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MAXIMUM_LENGTH ( \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum activate_dedicated_eps_bearer_context_accept_iei_tag {
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} activate_dedicated_eps_bearer_context_accept_iei;
/*
* Message name: Activate dedicated EPS bearer context accept
* Description: This message is sent by the UE to the network to acknowledge activation of a dedicated EPS bearer context associated with the same PDN address(es) and APN as an already active EPS bearer context. See table 8.3.1.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct activate_dedicated_eps_bearer_context_accept_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} activate_dedicated_eps_bearer_context_accept_msg;
int decode_activate_dedicated_eps_bearer_context_accept(activate_dedicated_eps_bearer_context_accept_msg *activatededicatedepsbearercontextaccept, uint8_t *buffer, uint32_t len);
int encode_activate_dedicated_eps_bearer_context_accept(activate_dedicated_eps_bearer_context_accept_msg *activatededicatedepsbearercontextaccept, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_H_) */
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ActivateDedicatedEpsBearerContextReject.h"
int decode_activate_dedicated_eps_bearer_context_reject(activate_dedicated_eps_bearer_context_reject_msg *activate_dedicated_eps_bearer_context_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, ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_esm_cause(&activate_dedicated_eps_bearer_context_reject->esmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_reject->protocolconfigurationoptions,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_reject->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_activate_dedicated_eps_bearer_context_reject(activate_dedicated_eps_bearer_context_reject_msg *activate_dedicated_eps_bearer_context_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_esm_cause(&activate_dedicated_eps_bearer_context_reject->esmcause,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((activate_dedicated_eps_bearer_context_reject->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_reject->protocolconfigurationoptions,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_H_
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH ( \
ESM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_MAXIMUM_LENGTH ( \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum activate_dedicated_eps_bearer_context_reject_iei_tag {
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} activate_dedicated_eps_bearer_context_reject_iei;
/*
* Message name: Activate dedicated EPS bearer context reject
* Description: This message is sent by UE to the network to reject activation of a dedicated EPS bearer context. See table 8.3.2.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct activate_dedicated_eps_bearer_context_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EsmCause esmcause;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} activate_dedicated_eps_bearer_context_reject_msg;
int decode_activate_dedicated_eps_bearer_context_reject(activate_dedicated_eps_bearer_context_reject_msg *activatededicatedepsbearercontextreject, uint8_t *buffer, uint32_t len);
int encode_activate_dedicated_eps_bearer_context_reject(activate_dedicated_eps_bearer_context_reject_msg *activatededicatedepsbearercontextreject, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_H_) */
@@ -0,0 +1,252 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ActivateDedicatedEpsBearerContextRequest.h"
int decode_activate_dedicated_eps_bearer_context_request(activate_dedicated_eps_bearer_context_request_msg *activate_dedicated_eps_bearer_context_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, ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_linked_eps_bearer_identity(&activate_dedicated_eps_bearer_context_request->linkedepsbeareridentity, 0, *(buffer + decoded), len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_eps_quality_of_service(&activate_dedicated_eps_bearer_context_request->epsqos, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_traffic_flow_template(&activate_dedicated_eps_bearer_context_request->tft, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI:
if ((decoded_result =
decode_transaction_identifier(&activate_dedicated_eps_bearer_context_request->transactionidentifier,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_request->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT;
break;
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI:
if ((decoded_result =
decode_quality_of_service(&activate_dedicated_eps_bearer_context_request->negotiatedqos,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_request->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT;
break;
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI:
if ((decoded_result =
decode_llc_service_access_point_identifier(&activate_dedicated_eps_bearer_context_request->negotiatedllcsapi,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_request->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT;
break;
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI:
if ((decoded_result =
decode_radio_priority(&activate_dedicated_eps_bearer_context_request->radiopriority,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_request->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT;
break;
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI:
if ((decoded_result =
decode_packet_flow_identifier(&activate_dedicated_eps_bearer_context_request->packetflowidentifier,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_request->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT;
break;
case ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_request->protocolconfigurationoptions,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_dedicated_eps_bearer_context_request->presencemask |= ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_activate_dedicated_eps_bearer_context_request(activate_dedicated_eps_bearer_context_request_msg *activate_dedicated_eps_bearer_context_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = encode_u8_linked_eps_bearer_identity(&activate_dedicated_eps_bearer_context_request->linkedepsbeareridentity) & 0x0f;
encoded++;
if ((encode_result =
encode_eps_quality_of_service(&activate_dedicated_eps_bearer_context_request->epsqos,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result =
encode_traffic_flow_template(&activate_dedicated_eps_bearer_context_request->tft,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((activate_dedicated_eps_bearer_context_request->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT) {
if ((encode_result =
encode_transaction_identifier(&activate_dedicated_eps_bearer_context_request->transactionidentifier,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((activate_dedicated_eps_bearer_context_request->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT) {
if ((encode_result =
encode_quality_of_service(&activate_dedicated_eps_bearer_context_request->negotiatedqos,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((activate_dedicated_eps_bearer_context_request->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT) {
if ((encode_result =
encode_llc_service_access_point_identifier(&activate_dedicated_eps_bearer_context_request->negotiatedllcsapi,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((activate_dedicated_eps_bearer_context_request->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT) {
if ((encode_result =
encode_radio_priority(&activate_dedicated_eps_bearer_context_request->radiopriority,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((activate_dedicated_eps_bearer_context_request->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT) {
if ((encode_result =
encode_packet_flow_identifier(&activate_dedicated_eps_bearer_context_request->packetflowidentifier,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((activate_dedicated_eps_bearer_context_request->presencemask & ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_request->protocolconfigurationoptions,
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,116 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "LinkedEpsBearerIdentity.h"
#include "EpsQualityOfService.h"
#include "TrafficFlowTemplate.h"
#include "TransactionIdentifier.h"
#include "QualityOfService.h"
#include "LlcServiceAccessPointIdentifier.h"
#include "RadioPriority.h"
#include "PacketFlowIdentifier.h"
#include "ProtocolConfigurationOptions.h"
#ifndef ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_H_
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH ( \
EPS_QUALITY_OF_SERVICE_MINIMUM_LENGTH + \
TRAFFIC_FLOW_TEMPLATE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MAXIMUM_LENGTH ( \
EPS_QUALITY_OF_SERVICE_MAXIMUM_LENGTH + \
TRAFFIC_FLOW_TEMPLATE_MAXIMUM_LENGTH + \
TRANSACTION_IDENTIFIER_MAXIMUM_LENGTH + \
QUALITY_OF_SERVICE_MAXIMUM_LENGTH + \
LLC_SERVICE_ACCESS_POINT_IDENTIFIER_MAXIMUM_LENGTH + \
RADIO_PRIORITY_MAXIMUM_LENGTH + \
PACKET_FLOW_IDENTIFIER_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH)
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT (1<<0)
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT (1<<1)
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT (1<<2)
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT (1<<3)
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT (1<<4)
# define ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<5)
typedef enum activate_dedicated_eps_bearer_context_request_iei_tag {
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI = 0x5D, /* 0x5D = 93 */
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI = 0x30, /* 0x30 = 48 */
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI = 0x32, /* 0x32 = 50 */
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI = 0x80, /* 0x80 = 128 */
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI = 0x34, /* 0x34 = 52 */
ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} activate_dedicated_eps_bearer_context_request_iei;
/*
* Message name: Activate dedicated EPS bearer context request
* Description: This message is sent by the network to the UE to request activation of a dedicated EPS bearer context associated with the same PDN address(es) and APN as an already active default EPS bearer context. See table 8.3.3.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct activate_dedicated_eps_bearer_context_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
LinkedEpsBearerIdentity linkedepsbeareridentity;
EpsQualityOfService epsqos;
TrafficFlowTemplate tft;
/* Optional fields */
uint32_t presencemask;
TransactionIdentifier transactionidentifier;
QualityOfService negotiatedqos;
LlcServiceAccessPointIdentifier negotiatedllcsapi;
RadioPriority radiopriority;
PacketFlowIdentifier packetflowidentifier;
ProtocolConfigurationOptions protocolconfigurationoptions;
} activate_dedicated_eps_bearer_context_request_msg;
int decode_activate_dedicated_eps_bearer_context_request(activate_dedicated_eps_bearer_context_request_msg *activatededicatedepsbearercontextrequest, uint8_t *buffer, uint32_t len);
int encode_activate_dedicated_eps_bearer_context_request(activate_dedicated_eps_bearer_context_request_msg *activatededicatedepsbearercontextrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_H_) */
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ActivateDefaultEpsBearerContextAccept.h"
int decode_activate_default_eps_bearer_context_accept(activate_default_eps_bearer_context_accept_msg *activate_default_eps_bearer_context_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, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&activate_default_eps_bearer_context_accept->protocolconfigurationoptions,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_accept->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_activate_default_eps_bearer_context_accept(activate_default_eps_bearer_context_accept_msg *activate_default_eps_bearer_context_accept, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH, len);
if ((activate_default_eps_bearer_context_accept->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&activate_default_eps_bearer_context_accept->protocolconfigurationoptions,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "ProtocolConfigurationOptions.h"
#ifndef ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_H_
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MAXIMUM_LENGTH ( \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum activate_default_eps_bearer_context_accept_iei_tag {
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} activate_default_eps_bearer_context_accept_iei;
/*
* Message name: Activate default EPS bearer context accept
* Description: This message is sent by the UE to the network to acknowledge activation of a default EPS bearer context. See table 8.3.4.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct activate_default_eps_bearer_context_accept_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} activate_default_eps_bearer_context_accept_msg;
int decode_activate_default_eps_bearer_context_accept(activate_default_eps_bearer_context_accept_msg *activatedefaultepsbearercontextaccept, uint8_t *buffer, uint32_t len);
int encode_activate_default_eps_bearer_context_accept(activate_default_eps_bearer_context_accept_msg *activatedefaultepsbearercontextaccept, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_H_) */
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ActivateDefaultEpsBearerContextReject.h"
int decode_activate_default_eps_bearer_context_reject(activate_default_eps_bearer_context_reject_msg *activate_default_eps_bearer_context_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, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_esm_cause(&activate_default_eps_bearer_context_reject->esmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&activate_default_eps_bearer_context_reject->protocolconfigurationoptions,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_reject->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_activate_default_eps_bearer_context_reject(activate_default_eps_bearer_context_reject_msg *activate_default_eps_bearer_context_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_esm_cause(&activate_default_eps_bearer_context_reject->esmcause,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((activate_default_eps_bearer_context_reject->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&activate_default_eps_bearer_context_reject->protocolconfigurationoptions,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_H_
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_MINIMUM_LENGTH ( \
ESM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_MAXIMUM_LENGTH ( \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum activate_default_eps_bearer_context_reject_iei_tag {
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} activate_default_eps_bearer_context_reject_iei;
/*
* Message name: Activate default EPS bearer context reject
* Description: This message is sent by UE to the network to reject activation of a default EPS bearer context. See table 8.3.5.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct activate_default_eps_bearer_context_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EsmCause esmcause;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} activate_default_eps_bearer_context_reject_msg;
int decode_activate_default_eps_bearer_context_reject(activate_default_eps_bearer_context_reject_msg *activatedefaultepsbearercontextreject, uint8_t *buffer, uint32_t len);
int encode_activate_default_eps_bearer_context_reject(activate_default_eps_bearer_context_reject_msg *activatedefaultepsbearercontextreject, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_H_) */
@@ -0,0 +1,341 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ActivateDefaultEpsBearerContextRequest.h"
int decode_activate_default_eps_bearer_context_request(activate_default_eps_bearer_context_request_msg *activate_default_eps_bearer_context_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, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_eps_quality_of_service(&activate_default_eps_bearer_context_request->epsqos, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_access_point_name(&activate_default_eps_bearer_context_request->accesspointname, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_pdn_address(&activate_default_eps_bearer_context_request->pdnaddress, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI:
if ((decoded_result =
decode_transaction_identifier(&activate_default_eps_bearer_context_request->transactionidentifier,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI:
if ((decoded_result =
decode_quality_of_service(&activate_default_eps_bearer_context_request->negotiatedqos,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI:
if ((decoded_result =
decode_llc_service_access_point_identifier(&activate_default_eps_bearer_context_request->negotiatedllcsapi,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI:
if ((decoded_result =
decode_radio_priority(&activate_default_eps_bearer_context_request->radiopriority,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI:
if ((decoded_result =
decode_packet_flow_identifier(&activate_default_eps_bearer_context_request->packetflowidentifier,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_IEI:
if ((decoded_result =
decode_apn_aggregate_maximum_bit_rate(&activate_default_eps_bearer_context_request->apnambr,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_IEI:
if ((decoded_result =
decode_esm_cause(&activate_default_eps_bearer_context_request->esmcause,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT;
break;
case ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&activate_default_eps_bearer_context_request->protocolconfigurationoptions,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_activate_default_eps_bearer_context_request(activate_default_eps_bearer_context_request_msg *activate_default_eps_bearer_context_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH, len);
if ((encode_result =
encode_eps_quality_of_service(&activate_default_eps_bearer_context_request->epsqos,
0, buffer + encoded, len - encoded)) < 0) { //Return in case of error
LOG_TRACE(ERROR, "ESM ENCODE epsqos");
return encode_result;
} else
encoded += encode_result;
if ((encode_result =
encode_access_point_name(&activate_default_eps_bearer_context_request->accesspointname,
0, buffer + encoded, len - encoded)) < 0) { //Return in case of error
LOG_TRACE(ERROR, "ESM ENCODE accesspointname");
return encode_result;
} else
encoded += encode_result;
if ((encode_result =
encode_pdn_address(&activate_default_eps_bearer_context_request->pdnaddress,
0, buffer + encoded, len - encoded)) < 0) { //Return in case of error
LOG_TRACE(ERROR, "ESM ENCODE pdnaddress");
return encode_result;
} else
encoded += encode_result;
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT) {
if ((encode_result =
encode_transaction_identifier(&activate_default_eps_bearer_context_request->transactionidentifier,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI,
buffer + encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE transactionidentifier");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT) {
if ((encode_result =
encode_quality_of_service(&activate_default_eps_bearer_context_request->negotiatedqos,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI,
buffer + encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE negotiatedqos");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT) {
if ((encode_result =
encode_llc_service_access_point_identifier(&activate_default_eps_bearer_context_request->negotiatedllcsapi,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI,
buffer + encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE negotiatedllcsapi");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT) {
if ((encode_result =
encode_radio_priority(&activate_default_eps_bearer_context_request->radiopriority,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI,
buffer + encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE radiopriority");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT) {
if ((encode_result =
encode_packet_flow_identifier(&activate_default_eps_bearer_context_request->packetflowidentifier,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI,
buffer + encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE packetflowidentifier");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_PRESENT) {
if ((encode_result =
encode_apn_aggregate_maximum_bit_rate(&activate_default_eps_bearer_context_request->apnambr,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_IEI, buffer +
encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE apnambr");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT) {
if ((encode_result =
encode_esm_cause(&activate_default_eps_bearer_context_request->esmcause,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_IEI, buffer
+ encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE esmcause");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
#if 0 /* LW: force Protocol Configuration Options to be included in the ESM message */
{
#define CONFIGURATION_PROTOCOL_PPP 0
#define PROTOCOL_ID_IPCP 0x8021
#define PROTOCOL_ID_DNS_SERVER_IPV4_ADDRESS 0x000D
/* Force this item to be present */
activate_default_eps_bearer_context_request->presencemask |= ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
/* Fill this item with data from PFT trace */
activate_default_eps_bearer_context_request->protocolconfigurationoptions.configurationprotol = CONFIGURATION_PROTOCOL_PPP;
activate_default_eps_bearer_context_request->protocolconfigurationoptions.protocolid = PROTOCOL_ID_IPCP;
activate_default_eps_bearer_context_request->protocolconfigurationoptions.lengthofprotocolid = 16; /* Size of PROTOCOL_ID_IPCP */
activate_default_eps_bearer_context_request->protocolconfigurationoptions.protocolidcontents.value = (uint8_t *)
/* PROTOCOL_ID_IPCP data */
"\x03\x00\x00\x10\x81\x06\xC0\xA8\x0C\x64\x83\x06\xC0\xA8\x6A\x0C";
/* Additional parameters PROTOCOL_ID_DNS_SERVER_IPV4_ADDRESS data */
//"\x00\x0d\x04\x52\x61\x00\x78"
/* Additional parameters PROTOCOL_ID_DNS_SERVER_IPV4_ADDRESS data */
//"\x00\x0d\x04\x52\x61\x01\x78";
//activate_default_eps_bearer_context_request->protocolconfigurationoptions.protocolidcontents.length = 16 + 7 + 7;
activate_default_eps_bearer_context_request->protocolconfigurationoptions.protocolidcontents.length = 16;
}
#endif
if ((activate_default_eps_bearer_context_request->presencemask & ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&activate_default_eps_bearer_context_request->protocolconfigurationoptions,
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0) {
LOG_TRACE(ERROR, "ESM ENCODE protocolconfigurationoptions");
// Return in case of error
return encode_result;
} else
encoded += encode_result;
}
LOG_TRACE(INFO, "ESM ENCODED activate_default_eps_bearer_context_request");
return encoded;
}
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "EpsQualityOfService.h"
#include "AccessPointName.h"
#include "PdnAddress.h"
#include "TransactionIdentifier.h"
#include "QualityOfService.h"
#include "LlcServiceAccessPointIdentifier.h"
#include "RadioPriority.h"
#include "PacketFlowIdentifier.h"
#include "ApnAggregateMaximumBitRate.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_H_
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH ( \
EPS_QUALITY_OF_SERVICE_MINIMUM_LENGTH + \
ACCESS_POINT_NAME_MINIMUM_LENGTH + \
PDN_ADDRESS_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MAXIMUM_LENGTH ( \
EPS_QUALITY_OF_SERVICE_MAXIMUM_LENGTH + \
ACCESS_POINT_NAME_MAXIMUM_LENGTH + \
PDN_ADDRESS_MAXIMUM_LENGTH + \
TRANSACTION_IDENTIFIER_MAXIMUM_LENGTH + \
QUALITY_OF_SERVICE_MAXIMUM_LENGTH + \
LLC_SERVICE_ACCESS_POINT_IDENTIFIER_MAXIMUM_LENGTH + \
RADIO_PRIORITY_MAXIMUM_LENGTH + \
PACKET_FLOW_IDENTIFIER_MAXIMUM_LENGTH + \
APN_AGGREGATE_MAXIMUM_BIT_RATE_MAXIMUM_LENGTH + \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT (1<<0)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT (1<<1)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT (1<<2)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT (1<<3)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT (1<<4)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_PRESENT (1<<5)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT (1<<6)
# define ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<7)
typedef enum activate_default_eps_bearer_context_request_iei_tag {
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_IEI = 0x5D, /* 0x5D = 93 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_IEI = 0x30, /* 0x30 = 48 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_IEI = 0x32, /* 0x32 = 50 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_IEI = 0x80, /* 0x80 = 128 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_IEI = 0x34, /* 0x34 = 52 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APNAMBR_IEI = 0x5E, /* 0x5E = 94 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_IEI = 0x58, /* 0x58 = 88 */
ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} activate_default_eps_bearer_context_request_iei;
/*
* Message name: Activate default EPS bearer context request
* Description: This message is sent by the network to the UE to request activation of a default EPS bearer context. See table 8.3.6.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct activate_default_eps_bearer_context_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EpsQualityOfService epsqos;
AccessPointName accesspointname;
PdnAddress pdnaddress;
/* Optional fields */
uint32_t presencemask;
TransactionIdentifier transactionidentifier;
QualityOfService negotiatedqos;
LlcServiceAccessPointIdentifier negotiatedllcsapi;
RadioPriority radiopriority;
PacketFlowIdentifier packetflowidentifier;
ApnAggregateMaximumBitRate apnambr;
EsmCause esmcause;
ProtocolConfigurationOptions protocolconfigurationoptions;
} activate_default_eps_bearer_context_request_msg;
int decode_activate_default_eps_bearer_context_request(activate_default_eps_bearer_context_request_msg *activatedefaultepsbearercontextrequest, uint8_t *buffer, uint32_t len);
int encode_activate_default_eps_bearer_context_request(activate_default_eps_bearer_context_request_msg *activatedefaultepsbearercontextrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_H_) */
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "BearerResourceAllocationReject.h"
int decode_bearer_resource_allocation_reject(bearer_resource_allocation_reject_msg *bearer_resource_allocation_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, BEARER_RESOURCE_ALLOCATION_REJECT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_esm_cause(&bearer_resource_allocation_reject->esmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&bearer_resource_allocation_reject->protocolconfigurationoptions,
BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
bearer_resource_allocation_reject->presencemask |= BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_bearer_resource_allocation_reject(bearer_resource_allocation_reject_msg *bearer_resource_allocation_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, BEARER_RESOURCE_ALLOCATION_REJECT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_esm_cause(&bearer_resource_allocation_reject->esmcause, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((bearer_resource_allocation_reject->presencemask & BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&bearer_resource_allocation_reject->protocolconfigurationoptions,
BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef BEARER_RESOURCE_ALLOCATION_REJECT_H_
#define BEARER_RESOURCE_ALLOCATION_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define BEARER_RESOURCE_ALLOCATION_REJECT_MINIMUM_LENGTH ( \
ESM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define BEARER_RESOURCE_ALLOCATION_REJECT_MAXIMUM_LENGTH ( \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum bearer_resource_allocation_reject_iei_tag {
BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} bearer_resource_allocation_reject_iei;
/*
* Message name: Bearer resource allocation reject
* Description: This message is sent by the network to the UE to reject the allocation of a dedicated bearer resource. See table 8.3.7.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct bearer_resource_allocation_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EsmCause esmcause;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} bearer_resource_allocation_reject_msg;
int decode_bearer_resource_allocation_reject(bearer_resource_allocation_reject_msg *bearerresourceallocationreject, uint8_t *buffer, uint32_t len);
int encode_bearer_resource_allocation_reject(bearer_resource_allocation_reject_msg *bearerresourceallocationreject, uint8_t *buffer, uint32_t len);
#endif /* ! defined(BEARER_RESOURCE_ALLOCATION_REJECT_H_) */
@@ -0,0 +1,132 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "BearerResourceAllocationRequest.h"
int decode_bearer_resource_allocation_request(bearer_resource_allocation_request_msg *bearer_resource_allocation_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, BEARER_RESOURCE_ALLOCATION_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_linked_eps_bearer_identity(&bearer_resource_allocation_request->linkedepsbeareridentity, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_traffic_flow_aggregate_description(&bearer_resource_allocation_request->trafficflowaggregate, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
if ((decoded_result = decode_eps_quality_of_service(&bearer_resource_allocation_request->requiredtrafficflowqos, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&bearer_resource_allocation_request->protocolconfigurationoptions,
BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
bearer_resource_allocation_request->presencemask |= BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_bearer_resource_allocation_request(bearer_resource_allocation_request_msg *bearer_resource_allocation_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, BEARER_RESOURCE_ALLOCATION_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_linked_eps_bearer_identity(&bearer_resource_allocation_request->linkedepsbeareridentity) & 0x0f) << 4) | 0x00;
encoded++;
if ((encode_result =
encode_traffic_flow_aggregate_description(&bearer_resource_allocation_request->trafficflowaggregate,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((encode_result =
encode_eps_quality_of_service(&bearer_resource_allocation_request->requiredtrafficflowqos,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((bearer_resource_allocation_request->presencemask & BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&bearer_resource_allocation_request->protocolconfigurationoptions,
BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "LinkedEpsBearerIdentity.h"
#include "TrafficFlowAggregateDescription.h"
#include "EpsQualityOfService.h"
#include "ProtocolConfigurationOptions.h"
#ifndef BEARER_RESOURCE_ALLOCATION_REQUEST_H_
#define BEARER_RESOURCE_ALLOCATION_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define BEARER_RESOURCE_ALLOCATION_REQUEST_MINIMUM_LENGTH ( \
TRAFFIC_FLOW_AGGREGATE_DESCRIPTION_MINIMUM_LENGTH + \
EPS_QUALITY_OF_SERVICE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define BEARER_RESOURCE_ALLOCATION_REQUEST_MAXIMUM_LENGTH ( \
TRAFFIC_FLOW_AGGREGATE_DESCRIPTION_MAXIMUM_LENGTH + \
EPS_QUALITY_OF_SERVICE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum bearer_resource_allocation_request_iei_tag {
BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} bearer_resource_allocation_request_iei;
/*
* Message name: Bearer resource allocation request
* Description: This message is sent by the UE to the network to request the allocation of a dedicated bearer resource. See table 8.3.8.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct bearer_resource_allocation_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
LinkedEpsBearerIdentity linkedepsbeareridentity;
TrafficFlowAggregateDescription trafficflowaggregate;
EpsQualityOfService requiredtrafficflowqos;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} bearer_resource_allocation_request_msg;
int decode_bearer_resource_allocation_request(bearer_resource_allocation_request_msg *bearerresourceallocationrequest, uint8_t *buffer, uint32_t len);
int encode_bearer_resource_allocation_request(bearer_resource_allocation_request_msg *bearerresourceallocationrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(BEARER_RESOURCE_ALLOCATION_REQUEST_H_) */
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "BearerResourceModificationReject.h"
int decode_bearer_resource_modification_reject(bearer_resource_modification_reject_msg *bearer_resource_modification_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, BEARER_RESOURCE_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_esm_cause(&bearer_resource_modification_reject->esmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&bearer_resource_modification_reject->protocolconfigurationoptions,
BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
bearer_resource_modification_reject->presencemask |= BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_bearer_resource_modification_reject(bearer_resource_modification_reject_msg *bearer_resource_modification_reject, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, BEARER_RESOURCE_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
if ((encode_result =
encode_esm_cause(&bearer_resource_modification_reject->esmcause, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((bearer_resource_modification_reject->presencemask & BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&bearer_resource_modification_reject->protocolconfigurationoptions,
BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef BEARER_RESOURCE_MODIFICATION_REJECT_H_
#define BEARER_RESOURCE_MODIFICATION_REJECT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define BEARER_RESOURCE_MODIFICATION_REJECT_MINIMUM_LENGTH ( \
ESM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define BEARER_RESOURCE_MODIFICATION_REJECT_MAXIMUM_LENGTH ( \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum bearer_resource_modification_reject_iei_tag {
BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} bearer_resource_modification_reject_iei;
/*
* Message name: Bearer resource modification reject
* Description: This message is sent by the network to the UE to reject the modification of a dedicated bearer resource. See table 8.3.9.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct bearer_resource_modification_reject_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EsmCause esmcause;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} bearer_resource_modification_reject_msg;
int decode_bearer_resource_modification_reject(bearer_resource_modification_reject_msg *bearerresourcemodificationreject, uint8_t *buffer, uint32_t len);
int encode_bearer_resource_modification_reject(bearer_resource_modification_reject_msg *bearerresourcemodificationreject, uint8_t *buffer, uint32_t len);
#endif /* ! defined(BEARER_RESOURCE_MODIFICATION_REJECT_H_) */
@@ -0,0 +1,168 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "BearerResourceModificationRequest.h"
int decode_bearer_resource_modification_request(bearer_resource_modification_request_msg *bearer_resource_modification_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, BEARER_RESOURCE_MODIFICATION_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_u8_linked_eps_bearer_identity(&bearer_resource_modification_request->epsbeareridentityforpacketfilter, 0, *(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result;
decoded++;
if ((decoded_result = decode_traffic_flow_aggregate_description(&bearer_resource_modification_request->trafficflowaggregate, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_IEI:
if ((decoded_result =
decode_eps_quality_of_service(&bearer_resource_modification_request->requiredtrafficflowqos,
BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
bearer_resource_modification_request->presencemask |= BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_PRESENT;
break;
case BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_IEI:
if ((decoded_result =
decode_esm_cause(&bearer_resource_modification_request->esmcause,
BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_IEI, buffer
+ decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
bearer_resource_modification_request->presencemask |= BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_PRESENT;
break;
case BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&bearer_resource_modification_request->protocolconfigurationoptions,
BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
bearer_resource_modification_request->presencemask |= BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_bearer_resource_modification_request(bearer_resource_modification_request_msg *bearer_resource_modification_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, BEARER_RESOURCE_MODIFICATION_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_linked_eps_bearer_identity(&bearer_resource_modification_request->epsbeareridentityforpacketfilter) & 0x0f) << 4) | 0x00;
encoded++;
if ((encode_result =
encode_traffic_flow_aggregate_description(&bearer_resource_modification_request->trafficflowaggregate,
0, buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((bearer_resource_modification_request->presencemask & BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_PRESENT)
== BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_PRESENT) {
if ((encode_result =
encode_eps_quality_of_service(&bearer_resource_modification_request->requiredtrafficflowqos,
BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((bearer_resource_modification_request->presencemask & BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_PRESENT)
== BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_PRESENT) {
if ((encode_result =
encode_esm_cause(&bearer_resource_modification_request->esmcause,
BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_IEI, buffer +
encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
if ((bearer_resource_modification_request->presencemask & BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&bearer_resource_modification_request->protocolconfigurationoptions,
BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "LinkedEpsBearerIdentity.h"
#include "TrafficFlowAggregateDescription.h"
#include "EpsQualityOfService.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef BEARER_RESOURCE_MODIFICATION_REQUEST_H_
#define BEARER_RESOURCE_MODIFICATION_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define BEARER_RESOURCE_MODIFICATION_REQUEST_MINIMUM_LENGTH ( \
TRAFFIC_FLOW_AGGREGATE_DESCRIPTION_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define BEARER_RESOURCE_MODIFICATION_REQUEST_MAXIMUM_LENGTH ( \
TRAFFIC_FLOW_AGGREGATE_DESCRIPTION_MAXIMUM_LENGTH + \
EPS_QUALITY_OF_SERVICE_MAXIMUM_LENGTH + \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_PRESENT (1<<0)
# define BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_PRESENT (1<<1)
# define BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<2)
typedef enum bearer_resource_modification_request_iei_tag {
BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_IEI = 0x5B, /* 0x5B = 91 */
BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_IEI = 0x58, /* 0x58 = 88 */
BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} bearer_resource_modification_request_iei;
/*
* Message name: Bearer resource modification request
* Description: This message is sent by the UE to the network to request the modification of a dedicated bearer resource. See table 8.3.10.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct bearer_resource_modification_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
LinkedEpsBearerIdentity epsbeareridentityforpacketfilter;
TrafficFlowAggregateDescription trafficflowaggregate;
/* Optional fields */
uint32_t presencemask;
EpsQualityOfService requiredtrafficflowqos;
EsmCause esmcause;
ProtocolConfigurationOptions protocolconfigurationoptions;
} bearer_resource_modification_request_msg;
int decode_bearer_resource_modification_request(bearer_resource_modification_request_msg *bearerresourcemodificationrequest, uint8_t *buffer, uint32_t len);
int encode_bearer_resource_modification_request(bearer_resource_modification_request_msg *bearerresourcemodificationrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(BEARER_RESOURCE_MODIFICATION_REQUEST_H_) */
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "DeactivateEpsBearerContextAccept.h"
int decode_deactivate_eps_bearer_context_accept(deactivate_eps_bearer_context_accept_msg *deactivate_eps_bearer_context_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, DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&deactivate_eps_bearer_context_accept->protocolconfigurationoptions,
DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
deactivate_eps_bearer_context_accept->presencemask |= DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_deactivate_eps_bearer_context_accept(deactivate_eps_bearer_context_accept_msg *deactivate_eps_bearer_context_accept, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH, len);
if ((deactivate_eps_bearer_context_accept->presencemask & DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&deactivate_eps_bearer_context_accept->protocolconfigurationoptions,
DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "ProtocolConfigurationOptions.h"
#ifndef DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_H_
#define DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_MINIMUM_LENGTH (0)
/* Maximum length macro. Formed by maximum length of each field */
#define DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_MAXIMUM_LENGTH ( \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum deactivate_eps_bearer_context_accept_iei_tag {
DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} deactivate_eps_bearer_context_accept_iei;
/*
* Message name: Deactivate EPS bearer context accept
* Description: This message is sent by the UE to acknowledge deactivation of the EPS bearer context requested in the corresponding Deactivate EPS bearer context request message. See table 8.3.11.1.
* Significance: dual
* Direction: UE to network
*/
typedef struct deactivate_eps_bearer_context_accept_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} deactivate_eps_bearer_context_accept_msg;
int decode_deactivate_eps_bearer_context_accept(deactivate_eps_bearer_context_accept_msg *deactivateepsbearercontextaccept, uint8_t *buffer, uint32_t len);
int encode_deactivate_eps_bearer_context_accept(deactivate_eps_bearer_context_accept_msg *deactivateepsbearercontextaccept, uint8_t *buffer, uint32_t len);
#endif /* ! defined(DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_H_) */
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "DeactivateEpsBearerContextRequest.h"
int decode_deactivate_eps_bearer_context_request(deactivate_eps_bearer_context_request_msg *deactivate_eps_bearer_context_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, DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
if ((decoded_result = decode_esm_cause(&deactivate_eps_bearer_context_request->esmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
/* Decoding optional fields */
while(len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
/* Type | value iei are below 0x80 so just return the first 4 bits */
if (ieiDecoded >= 0x80)
ieiDecoded = ieiDecoded & 0xf0;
switch(ieiDecoded) {
case DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI:
if ((decoded_result =
decode_protocol_configuration_options(&deactivate_eps_bearer_context_request->protocolconfigurationoptions,
DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result;
decoded += decoded_result;
/* Set corresponding mask to 1 in presencemask */
deactivate_eps_bearer_context_request->presencemask |= DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
break;
default:
errorCodeDecoder = TLV_DECODE_UNEXPECTED_IEI;
return TLV_DECODE_UNEXPECTED_IEI;
}
}
return decoded;
}
int encode_deactivate_eps_bearer_context_request(deactivate_eps_bearer_context_request_msg *deactivate_eps_bearer_context_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
int encode_result = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH, len);
if ((encode_result =
encode_esm_cause(&deactivate_eps_bearer_context_request->esmcause, 0,
buffer + encoded, len - encoded)) < 0) //Return in case of error
return encode_result;
else
encoded += encode_result;
if ((deactivate_eps_bearer_context_request->presencemask & DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT)
== DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
if ((encode_result =
encode_protocol_configuration_options(&deactivate_eps_bearer_context_request->protocolconfigurationoptions,
DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI,
buffer + encoded, len - encoded)) < 0)
// Return in case of error
return encode_result;
else
encoded += encode_result;
}
return encoded;
}
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "ProtocolDiscriminator.h"
#include "EpsBearerIdentity.h"
#include "ProcedureTransactionIdentity.h"
#include "MessageType.h"
#include "EsmCause.h"
#include "ProtocolConfigurationOptions.h"
#ifndef DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_H_
#define DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_H_
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_MINIMUM_LENGTH ( \
ESM_CAUSE_MINIMUM_LENGTH )
/* Maximum length macro. Formed by maximum length of each field */
#define DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_MAXIMUM_LENGTH ( \
ESM_CAUSE_MAXIMUM_LENGTH + \
PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH )
/* If an optional value is present and should be encoded, the corresponding
* Bit mask should be set to 1.
*/
# define DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT (1<<0)
typedef enum deactivate_eps_bearer_context_request_iei_tag {
DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_IEI = 0x27, /* 0x27 = 39 */
} deactivate_eps_bearer_context_request_iei;
/*
* Message name: Deactivate EPS bearer context request
* Description: This message is sent by the network to request deactivation of an active EPS bearer context. See table 8.3.12.1.
* Significance: dual
* Direction: network to UE
*/
typedef struct deactivate_eps_bearer_context_request_msg_tag {
/* Mandatory fields */
ProtocolDiscriminator protocoldiscriminator:4;
EpsBearerIdentity epsbeareridentity:4;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EsmCause esmcause;
/* Optional fields */
uint32_t presencemask;
ProtocolConfigurationOptions protocolconfigurationoptions;
} deactivate_eps_bearer_context_request_msg;
int decode_deactivate_eps_bearer_context_request(deactivate_eps_bearer_context_request_msg *deactivateepsbearercontextrequest, uint8_t *buffer, uint32_t len);
int encode_deactivate_eps_bearer_context_request(deactivate_eps_bearer_context_request_msg *deactivateepsbearercontextrequest, uint8_t *buffer, uint32_t len);
#endif /* ! defined(DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_H_) */
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "EsmInformationRequest.h"
int decode_esm_information_request(esm_information_request_msg *esm_information_request, uint8_t *buffer, uint32_t len)
{
uint32_t decoded = 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, ESM_INFORMATION_REQUEST_MINIMUM_LENGTH, len);
/* Decoding mandatory fields */
return decoded;
}
int encode_esm_information_request(esm_information_request_msg *esm_information_request, uint8_t *buffer, uint32_t len)
{
int encoded = 0;
/* Checking IEI and pointer */
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, ESM_INFORMATION_REQUEST_MINIMUM_LENGTH, len);
return encoded;
}

Some files were not shown because too many files have changed in this diff Show More