play_scenario_decode.c 2.32 KB
Newer Older
1 2 3 4 5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*
                                play_scenario_decode.c
                                -------------------
  AUTHOR  : Lionel GAUTHIER
  COMPANY : EURECOM
  EMAIL   : Lionel.Gauthier@eurecom.fr
 */

#include "intertask_interface.h"
#include "platform_types.h"
#include "s1ap_eNB_decoder.h"
#include "assertions.h"
#include "play_scenario.h"

//------------------------------------------------------------------------------
37
int et_s1ap_decode_pdu(S1AP_PDU_t *const pdu, const uint8_t *const buffer, const uint32_t length)
38 39 40
{
  asn_dec_rval_t dec_ret;
  DevAssert(buffer != NULL);
41
  memset((void *)pdu, 0, sizeof(S1AP_S1AP_PDU_t));
42
  dec_ret = aper_decode(NULL,
43
                        &asn_DEF_S1AP_S1AP_PDU,
44 45 46 47 48 49 50 51 52 53 54
                        (void **)&pdu,
                        buffer,
                        length,
                        0,
                        0);

  if (dec_ret.code != RC_OK) {
    S1AP_ERROR("Failed to decode pdu\n");
    return -1;
  }

55
  return dec_ret.code;
56
}
57

58
//------------------------------------------------------------------------------
59
void et_decode_s1ap(et_s1ap_t *const s1ap)
60 61
{
  if (NULL != s1ap) {
62
    if (et_s1ap_decode_pdu(&s1ap->pdu, s1ap->binary_stream, s1ap->binary_stream_allocated_size) < 0) {
63 64 65 66
      AssertFatal (0, "ERROR %s() Cannot decode S1AP message!\n", __FUNCTION__);
    }
  }
}