Skip to content
Snippets Groups Projects
s1ap_common.h 16.3 KiB
Newer Older
Cédric Roux's avatar
Cédric Roux committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
/*******************************************************************************

  Eurecom OpenAirInterface
  Copyright(c) 1999 - 2012 Eurecom

  This program is free software; you can redistribute it and/or modify it
  under the terms and conditions of the GNU General Public License,
  version 2, as published by the Free Software Foundation.

  This program is distributed in the hope it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  more details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

  The full GNU General Public License is included in this distribution in
  the file called "COPYING".

  Contact Information
  Openair Admin: openair_admin@eurecom.fr
  Openair Tech : openair_tech@eurecom.fr
  Forums       : http://forums.eurecom.fr/openairinterface
  Address      : EURECOM, Campus SophiaTech, 450 Route des Chappes
                 06410 Biot FRANCE

*******************************************************************************/

/** @defgroup _s1ap_impl_ S1AP Layer Reference Implementation
 * @ingroup _ref_implementation_
 * @{
 */

#if HAVE_CONFIG_H_
# include "config.h"
#endif

#ifndef S1AP_COMMON_H_
#define S1AP_COMMON_H_

/* Defined in asn_internal.h */
// extern int asn_debug_indent;
extern int asn_debug;

inline void ASN_DEBUG(const char *fmt, ...);

#include "Criticality.h"
#include "Presence.h"
#include "PrivateIE-ID.h"
#include "ProcedureCode.h"
#include "ProtocolExtensionID.h"
#include "ProtocolIE-ID.h"
#include "TriggeringMessage.h"
#include "AllocationAndRetentionPriority.h"
#include "Bearers-SubjectToStatusTransfer-List.h"
#include "Bearers-SubjectToStatusTransfer-Item.h"
#include "BitRate.h"
#include "BPLMNs.h"
#include "BroadcastCompletedAreaList.h"
#include "Cause.h"
#include "CauseMisc.h"
#include "CauseProtocol.h"
#include "CauseRadioNetwork.h"
#include "CauseTransport.h"
#include "CauseNas.h"
#include "CellIdentity.h"
#include "CellID-Broadcast.h"
#include "CellID-Broadcast-Item.h"
#include "Cdma2000PDU.h"
#include "Cdma2000RATType.h"
#include "Cdma2000SectorID.h"
#include "Cdma2000HOStatus.h"
#include "Cdma2000HORequiredIndication.h"
#include "Cdma2000OneXSRVCCInfo.h"
#include "Cdma2000OneXMEID.h"
#include "Cdma2000OneXMSI.h"
#include "Cdma2000OneXPilot.h"
#include "Cdma2000OneXRAND.h"
#include "Cell-Size.h"
#include "CellType.h"
#include "CGI.h"
#include "CI.h"
#include "CNDomain.h"
#include "CSFallbackIndicator.h"
#include "CSG-Id.h"
#include "CSG-IdList.h"
#include "CSG-IdList-Item.h"
#include "COUNTvalue.h"
#include "CriticalityDiagnostics.h"
#include "CriticalityDiagnostics-IE-List.h"
#include "CriticalityDiagnostics-IE-Item.h"
#include "DataCodingScheme.h"
#include "DL-Forwarding.h"
#include "Direct-Forwarding-Path-Availability.h"
#include "ECGIList.h"
#include "EmergencyAreaIDList.h"
#include "EmergencyAreaID.h"
#include "EmergencyAreaID-Broadcast.h"
#include "EmergencyAreaID-Broadcast-Item.h"
#include "CompletedCellinEAI.h"
#include "CompletedCellinEAI-Item.h"
#include "ENB-ID.h"
#include "GERAN-Cell-ID.h"
#include "Global-ENB-ID.h"
#include "ENB-StatusTransfer-TransparentContainer.h"
#include "ENB-UE-S1AP-ID.h"
#include "ENBname.h"
#include "ENBX2TLAs.h"
#include "EncryptionAlgorithms.h"
#include "EPLMNs.h"
#include "EventType.h"
#include "E-RAB-ID.h"
#include "E-RABInformationList.h"
#include "E-RABInformationListItem.h"
#include "E-RABList.h"
#include "E-RABItem.h"
#include "E-RABLevelQoSParameters.h"
#include "EUTRAN-CGI.h"
#include "ExtendedRNC-ID.h"
#include "ForbiddenInterRATs.h"
#include "ForbiddenTAs.h"
#include "ForbiddenTAs-Item.h"
#include "ForbiddenTACs.h"
#include "ForbiddenLAs.h"
#include "ForbiddenLAs-Item.h"
#include "ForbiddenLACs.h"
#include "GBR-QosInformation.h"
#include "GTP-TEID.h"
#include "GUMMEI.h"
#include "HandoverRestrictionList.h"
#include "HandoverType.h"
#include "HFN.h"
#include "IMSI.h"
#include "IntegrityProtectionAlgorithms.h"
#include "InterfacesToTrace.h"
#include "LAC.h"
#include "LAI.h"
#include "LastVisitedCell-Item.h"
#include "LastVisitedEUTRANCellInformation.h"
#include "LastVisitedUTRANCellInformation.h"
#include "LastVisitedGERANCellInformation.h"
#include "L3-Information.h"
#include "MessageIdentifier.h"
#include "MMEname.h"
#include "MME-Group-ID.h"
#include "MME-Code.h"
#include "MME-UE-S1AP-ID.h"
#include "M-TMSI.h"
#include "MSClassmark2.h"
#include "MSClassmark3.h"
#include "NAS-PDU.h"
#include "NASSecurityParametersfromE-UTRAN.h"
#include "NASSecurityParameterstoE-UTRAN.h"
#include "NumberofBroadcastRequest.h"
#include "NumberOfBroadcasts.h"
#include "OldBSS-ToNewBSS-Information.h"
#include "OverloadAction.h"
#include "OverloadResponse.h"
#include "PagingDRX.h"
#include "PDCP-SN.h"
#include "PLMNidentity.h"
#include "Pre-emptionCapability.h"
#include "Pre-emptionVulnerability.h"
#include "PriorityLevel.h"
#include "QCI.h"
#include "ReceiveStatusofULPDCPSDUs.h"
#include "RelativeMMECapacity.h"
#include "RAC.h"
#include "RequestType.h"
#include "RIMTransfer.h"
#include "RIMInformation.h"
#include "RIMRoutingAddress.h"
#include "ReportArea.h"
#include "RepetitionPeriod.h"
#include "RNC-ID.h"
#include "RRC-Container.h"
#include "RRC-Establishment-Cause.h"
#include "SecurityKey.h"
#include "SecurityContext.h"
#include "SerialNumber.h"
#include "SONInformation.h"
#include "SONInformationRequest.h"
#include "SONInformationReply.h"
#include "SONConfigurationTransfer.h"
#include "Source-ToTarget-TransparentContainer.h"
#include "SourceBSS-ToTargetBSS-TransparentContainer.h"
#include "SourceeNB-ID.h"
#include "SRVCCOperationPossible.h"
#include "SRVCCHOIndication.h"
#include "SourceeNB-ToTargeteNB-TransparentContainer.h"
#include "SourceRNC-ToTargetRNC-TransparentContainer.h"
#include "ServedGUMMEIs.h"
#include "ServedGUMMEIsItem.h"
#include "ServedGroupIDs.h"
#include "ServedMMECs.h"
#include "ServedPLMNs.h"
#include "SubscriberProfileIDforRFP.h"
#include "SupportedTAs.h"
#include "SupportedTAs-Item.h"
#include "S-TMSI.h"
#include "TAC.h"
#include "TAIItem.h"
#include "TAIList.h"
#include "TAIListforWarning.h"
#include "TAI.h"
#include "TAI-Broadcast.h"
#include "TAI-Broadcast-Item.h"
#include "CompletedCellinTAI.h"
#include "CompletedCellinTAI-Item.h"
#include "TBCD-STRING.h"
#include "TargetID.h"
#include "TargeteNB-ID.h"
#include "TargetRNC-ID.h"
#include "TargeteNB-ToSourceeNB-TransparentContainer.h"
#include "Target-ToSource-TransparentContainer.h"
#include "TargetRNC-ToSourceRNC-TransparentContainer.h"
#include "TargetBSS-ToSourceBSS-TransparentContainer.h"
#include "TimeToWait.h"
#include "Time-UE-StayedInCell.h"
#include "TransportLayerAddress.h"
#include "TraceActivation.h"
#include "TraceDepth.h"
#include "E-UTRAN-Trace-ID.h"
#include "TypeOfError.h"
#include "UEAggregateMaximumBitrate.h"
#include "UE-S1AP-IDs.h"
#include "UE-S1AP-ID-pair.h"
#include "UE-associatedLogicalS1-ConnectionItem.h"
#include "UEIdentityIndexValue.h"
#include "UE-HistoryInformation.h"
#include "UEPagingID.h"
#include "UERadioCapability.h"
#include "UESecurityCapabilities.h"
#include "WarningAreaList.h"
#include "WarningType.h"
#include "WarningSecurityInfo.h"
#include "WarningMessageContents.h"
#include "X2TNLConfigurationInfo.h"
#include "S1AP-PDU.h"
#include "InitiatingMessage.h"
#include "SuccessfulOutcome.h"
#include "UnsuccessfulOutcome.h"
#include "HandoverRequired.h"
#include "HandoverCommand.h"
#include "HandoverNotify.h"
#include "HandoverPreparationFailure.h"
#include "HandoverRequest.h"
#include "HandoverRequestAcknowledge.h"
#include "HandoverFailure.h"
#include "PathSwitchRequest.h"
#include "PathSwitchRequestAcknowledge.h"
#include "PathSwitchRequestFailure.h"
#include "E-RABSetupRequest.h"
#include "E-RABSetupResponse.h"
#include "E-RABModifyRequest.h"
#include "E-RABModifyResponse.h"
#include "E-RABReleaseIndication.h"
#include "E-RABReleaseCommand.h"
#include "E-RABReleaseResponse.h"
#include "InitialContextSetupRequest.h"
#include "InitialContextSetupResponse.h"
#include "InitialContextSetupFailure.h"
#include "UEContextReleaseRequest.h"
#include "Paging.h"
#include "DownlinkNASTransport.h"
#include "InitialUEMessage.h"
#include "UplinkNASTransport.h"
#include "NASNonDeliveryIndication.h"
#include "HandoverCancel.h"
#include "HandoverCancelAcknowledge.h"
#include "Reset.h"
#include "ResetType.h"
#include "ResetAcknowledge.h"
#include "S1SetupResponse.h"
#include "S1SetupRequest.h"
#include "S1SetupFailure.h"
#include "ErrorIndication.h"
#include "ENBConfigurationUpdate.h"
#include "ENBConfigurationUpdateAcknowledge.h"
#include "ENBConfigurationUpdateFailure.h"
#include "MMEConfigurationUpdate.h"
#include "MMEConfigurationUpdateAcknowledge.h"
#include "MMEConfigurationUpdateFailure.h"
#include "DownlinkS1cdma2000tunneling.h"
#include "UplinkS1cdma2000tunneling.h"
#include "UEContextModificationRequest.h"
#include "UEContextModificationResponse.h"
#include "UEContextModificationFailure.h"
#include "UECapabilityInfoIndication.h"
#include "UEContextReleaseCommand.h"
#include "UEContextReleaseComplete.h"
#include "ENBStatusTransfer.h"
#include "MMEStatusTransfer.h"
#include "DeactivateTrace.h"
#include "TraceStart.h"
#include "TraceFailureIndication.h"
#include "CellTrafficTrace.h"
#include "LocationReportingControl.h"
#include "LocationReportingFailureIndication.h"
#include "LocationReport.h"
#include "OverloadStart.h"
#include "OverloadStop.h"
#include "WriteReplaceWarningRequest.h"
#include "WriteReplaceWarningResponse.h"
#include "ENBDirectInformationTransfer.h"
#include "MMEDirectInformationTransfer.h"
#include "ENBConfigurationTransfer.h"
#include "MMEConfigurationTransfer.h"
#include "PrivateMessage.h"
#include "Inter-SystemInformationTransferType.h"
#include "E-RABReleaseItemBearerRelComp.h"
#include "E-RABToBeSwitchedDLList.h"
#include "E-RABToBeSwitchedDLItem.h"
#include "E-RABToBeSwitchedULList.h"
#include "E-RABToBeSwitchedULItem.h"
#include "E-RABToBeSetupListBearerSUReq.h"
#include "E-RABToBeSetupItemBearerSUReq.h"
#include "E-RABDataForwardingList.h"
#include "E-RABDataForwardingItem.h"
#include "E-RABToBeSetupListHOReq.h"
#include "E-RABToBeSetupItemHOReq.h"
#include "E-RABAdmittedList.h"
#include "E-RABAdmittedItem.h"
#include "E-RABFailedToSetupListHOReqAck.h"
#include "E-RABToBeSetupItemCtxtSUReq.h"
#include "E-RABToBeSetupListCtxtSUReq.h"
#include "E-RABSetupItemBearerSURes.h"
#include "E-RABSetupListBearerSURes.h"
#include "E-RABSetupItemCtxtSURes.h"
#include "E-RABSetupListCtxtSURes.h"
#include "E-RABReleaseListBearerRelComp.h"
#include "E-RABModifyItemBearerModRes.h"
#include "E-RABModifyListBearerModRes.h"
#include "E-RABFailedToSetupItemHOReqAck.h"
#include "E-RABFailedToSetupListHOReqAck.h"
#include "E-RABToBeModifiedItemBearerModReq.h"
#include "E-RABToBeModifiedListBearerModReq.h"
#include "UE-associatedLogicalS1-ConnectionListResAck.h"
#include "IE.h"

#if defined (UPDATE_RELEASE_9)
# include "BroadcastCancelledAreaList.h"
# include "CancelledCellinEAI.h"
# include "CancelledCellinEAI-Item.h"
# include "CancelledCellinTAI.h"
# include "CancelledCellinTAI-Item.h"
# include "CellAccessMode.h"
# include "CellID-Cancelled.h"
# include "CellID-Cancelled-Item.h"
# include "ConcurrentWarningMessageIndicator.h"
# include "CSGMembershipStatus.h"
# include "Data-Forwarding-Not-Possible.h"
# include "EmergencyAreaID-Cancelled.h"
# include "EmergencyAreaID-Cancelled-Item.h"
# include "E-RABList.h"
# include "EUTRANRoundTripDelayEstimationInfo.h"
# include "ExtendedRepetitionPeriod.h"
# include "LPPa-PDU.h"
# include "PS-ServiceNotAvailable.h"
# include "Routing-ID.h"
# include "StratumLevel.h"
# include "SynchronizationStatus.h"
# include "TimeSynchronizationInfo.h"
# include "TAI-Cancelled.h"
# include "TAI-Cancelled-Item.h"
# include "KillRequest.h"
# include "KillResponse.h"
# include "DownlinkUEAssociatedLPPaTransport.h"
# include "UplinkUEAssociatedLPPaTransport.h"
# include "DownlinkNonUEAssociatedLPPaTransport.h"
# include "UplinkNonUEAssociatedLPPaTransport.h"
#endif /* (UPDATE_RELEASE_9) */

#if defined(UPDATE_RELEASE_10)
# include "PagingPriority.h"
# include "RelayNode-Indicator.h"
# include "GWContextReleaseIndication.h"
# include "MMERelaySupportIndicator.h"
# include "ManagementBasedMDTAllowed.h"
# include "PrivacyIndicator.h"
# include "TrafficLoadReductionIndication.h"
# include "GUMMEIList.h"
#endif /* (UPDATE_RELEASE_10) */

/* Checking version of ASN1C compiler */
#if (ASN1C_ENVIRONMENT_VERSION < ASN1C_MINIMUM_VERSION)
# error "You are compiling s1ap with the wrong version of ASN1C"
#endif

#ifndef FALSE
# define FALSE (0)
#endif
#ifndef TRUE
# define TRUE  (!FALSE)
#endif

extern int asn_debug;
extern int asn1_xer_print;

#if defined(ENB_MODE)
# include "mme_sim.h"
# include "UTIL/LOG/log.h"
# include "eNB_default_values.h"
# define S1AP_ERROR(x, args...) LOG_E(S1AP, x, ##args)
# define S1AP_WARN(x, args...)  LOG_W(S1AP, x, ##args)
# define S1AP_TRAF(x, args...)  LOG_T(S1AP, x, ##args)
# define S1AP_DEBUG(x, args...) LOG_D(S1AP, x, ##args)
#else
# include "mme_default_values.h"
# define S1AP_ERROR(x, args...) do { fprintf(stdout, "[S1AP][E]"x, ##args); } while(0)
# define S1AP_WARN(x, args...)  do { fprintf(stdout, "[S1AP][W]"x, ##args); } while(0)
# define S1AP_TRAF(x, args...)  do { fprintf(stdout, "[S1AP][T]"x, ##args); } while(0)
# define S1AP_DEBUG(x, args...) do { fprintf(stdout, "[S1AP][D]"x, ##args); } while(0)
#endif

//Forward declaration
struct s1ap_message_s;

/** \brief Function callback prototype.
 **/
#if defined(ENB_MODE)
typedef int (*s1ap_message_decoded_callback)(
    eNB_mme_desc_t *eNB_desc_p,
    sctp_queue_item_t *packet_p,
    struct s1ap_message_s *message_p
);
#else
typedef int (*s1ap_message_decoded_callback)(
    uint32_t assocId,
    uint32_t stream,
    struct s1ap_message_s *message_p
);
#endif
/** \brief Encode a successfull outcome message
 \param buffer pointer to buffer in which data will be encoded
 \param length pointer to the length of buffer
 \param procedureCode Procedure code for the message
 \param criticality Criticality of the message
 \param td ASN1C type descriptor of the sptr
 \param sptr Deferenced pointer to the structure to encode
 @returns size in bytes encded on success or 0 on failure
 **/
ssize_t s1ap_generate_successfull_outcome(
    uint8_t               **buffer,
    uint32_t               *length,
    e_ProcedureCode         procedureCode,
    Criticality_t           criticality,
    asn_TYPE_descriptor_t  *td,
    void                   *sptr);

/** \brief Encode an initiating message
 \param buffer pointer to buffer in which data will be encoded
 \param length pointer to the length of buffer
 \param procedureCode Procedure code for the message
 \param criticality Criticality of the message
 \param td ASN1C type descriptor of the sptr
 \param sptr Deferenced pointer to the structure to encode
 @returns size in bytes encded on success or 0 on failure
 **/
ssize_t s1ap_generate_initiating_message(
    uint8_t               **buffer,
    uint32_t               *length,
    e_ProcedureCode         procedureCode,
    Criticality_t           criticality,
    asn_TYPE_descriptor_t  *td,
    void                   *sptr);

/** \brief Encode an unsuccessfull outcome message
 \param buffer pointer to buffer in which data will be encoded
 \param length pointer to the length of buffer
 \param procedureCode Procedure code for the message
 \param criticality Criticality of the message
 \param td ASN1C type descriptor of the sptr
 \param sptr Deferenced pointer to the structure to encode
 @returns size in bytes encded on success or 0 on failure
 **/
ssize_t s1ap_generate_unsuccessfull_outcome(
    uint8_t               **buffer,
    uint32_t               *length,
    e_ProcedureCode         procedureCode,
    Criticality_t           criticality,
    asn_TYPE_descriptor_t  *td,
    void                   *sptr);

/** \brief Generate a new IE
 \param id Protocol ie id of the IE
 \param criticality Criticality of the IE
 \param type ASN1 type descriptor of the IE value
 \param sptr Structure to be encoded in the value field
 @returns a pointer to the newly created IE structure or NULL in case of failure
 **/
IE_t *s1ap_new_ie(ProtocolIE_ID_t        id,
                  Criticality_t          criticality,
                  asn_TYPE_descriptor_t *type,
                  void                  *sptr);

/** \brief Handle criticality
 \param criticality Criticality of the IE
 @returns void
 **/
void s1ap_handle_criticality(e_Criticality criticality);

#endif /* S1AP_COMMON_H_ */