From a9256dedb360737ec70d7d2c9106dc201515d27f Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sun, 21 Feb 2016 22:01:49 +0100 Subject: [PATCH 01/21] Fix asn1c warnings. The strategy is rather basic. Files with warnings are replaced by an edited copy that triggers no warning. We take care to check that the replaced file is the same as the one that was analyzed at the time of warning removal (through checking its SHA1). There is a new bash script "fix_asn1" in cmake_targets/tools and the files replacing the existing ones are in cmake_targets/tools/fix_asn1.data. --- cmake_targets/CMakeLists.txt | 25 + cmake_targets/tools/fix_asn1 | 169 +++ .../RRC.rel10/SystemInformation-r8-IEs.h | 109 ++ .../S1AP.rel10.5/NativeInteger.c | 412 +++++++ .../S1AP.rel10.5/constr_SET_OF.c | 1041 +++++++++++++++++ .../X2AP.rel11.2/NativeInteger.c | 412 +++++++ .../X2ap-CriticalityDiagnostics-IE-List.h | 63 + .../X2AP.rel11.2/constr_SET_OF.c | 1041 +++++++++++++++++ 8 files changed, 3272 insertions(+) create mode 100755 cmake_targets/tools/fix_asn1 create mode 100644 cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h create mode 100644 cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c create mode 100644 cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c create mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c create mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h create mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index a125219982..6bebc2d655 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -247,6 +247,7 @@ endif (${RTAI}) # New C code source file, cmake must be re-run (instead of re-running make only) ############# set(asn1c_call "${OPENAIR_CMAKE}/tools/generate_asn1") +set(fix_asn1c_call "${OPENAIR_CMAKE}/tools/fix_asn1") set(asn1_generated_dir ${OPENAIR_BIN_DIR}) set(protoc_call "${OPENAIR_CMAKE}/tools/generate_protobuf") @@ -269,6 +270,15 @@ if(NOT EXISTS ${asn1c_call}) message( FATAL_ERROR "The script ${asn1c_call} must be present" ) endif(NOT EXISTS ${asn1c_call}) execute_process(COMMAND ${asn1c_call} ${RRC_FULL_DIR} ${RRC_GRAMMAR}) +if(NOT EXISTS ${fix_asn1c_call}) + message( FATAL_ERROR "The script ${fix_asn1c_call} must be present" ) +endif(NOT EXISTS ${fix_asn1c_call}) +execute_process( + COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION} + RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${fix_asn1c_call}: error") +endif (NOT ${ret} STREQUAL 0) file(GLOB rrc_source ${RRC_FULL_DIR}/*.c) set(rrc_source ${rrc_source} ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1_msg.c) file(GLOB rrc_h ${RRC_FULL_DIR}/*.h) @@ -282,6 +292,7 @@ include_directories ("${RRC_FULL_DIR}") add_custom_command ( OUTPUT ${RRC_FULL_DIR}/asn1_constants.h COMMAND ${asn1c_call} ${RRC_FULL_DIR} ${RRC_GRAMMAR} + COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION} DEPENDS ${RRC_GRAMMAR} ) @@ -311,6 +322,12 @@ set(S1AP_ASN_FILES set(S1AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) #message("calling ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}") execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}) +execute_process( + COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} + RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${fix_asn1c_call}: error") +endif (NOT ${ret} STREQUAL 0) file(GLOB S1AP_source ${S1AP_C_DIR}/*.c) set(S1AP_OAI_generated @@ -326,6 +343,7 @@ add_custom_command ( OUTPUT ${S1AP_OAI_generated} COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES} COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR} + COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} DEPENDS ${S1AP_ASN_FILES} ) add_library(S1AP_LIB @@ -378,6 +396,12 @@ set(X2AP_ASN_FILES set(X2AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) #message("calling ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}") execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}) +execute_process( + COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} + RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${fix_asn1c_call}: error") +endif (NOT ${ret} STREQUAL 0) file(GLOB X2AP_source ${X2AP_C_DIR}/*.c) set(X2AP_OAI_generated @@ -394,6 +418,7 @@ add_custom_command ( OUTPUT ${X2AP_OAI_generated} COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES} COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR} + COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} DEPENDS ${X2AP_ASN_FILES} ) diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 new file mode 100755 index 0000000000..f222374fae --- /dev/null +++ b/cmake_targets/tools/fix_asn1 @@ -0,0 +1,169 @@ +#!/bin/bash + +# in those arrays, each line is: +# + +RRC_Rel10=( + "SystemInformation-r8-IEs.h" 819eda3db27516f7c6780d832fb3c462e2264ea7 "fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h" +) + +X2AP_Rel11_2=( + "X2ap-CriticalityDiagnostics-IE-List.h" f0e2414992bfacfbc4b9fd15c977241d6d7fabeb "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h" + "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/X2AP.rel11.2/NativeInteger.c" + "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c" +) + +S1AP_Rel10_5=( + "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/S1AP.rel10.5/NativeInteger.c" + "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c" +) + +red_color="\x1b[31m" +green_color="\x1b[32m" +reset_color="\x1b[0m" + +function error() +{ + echo -e "$red_color"ERROR: "$@""$reset_color" + exit 1 +} + +function check_sha1() +{ + local file="$1" + local target_sha1="$2" + + if [ ! -f "$file" ] + then + error "$file: no such file" + fi + + local computed_sha1=$(sha1sum "$file" | cut -f 1 -d ' ') + + if [ "$target_sha1" != "$computed_sha1" ] + then + error "$file: wrong SHA1" + fi +} + +function copy_file() +{ + local file="$1" + local destination="$2" + + echo -e "$green_color""copy file $OPENAIR_DIR/cmake_targets/tools/$file to $destination""$reset_color" + + cp -f "$OPENAIR_DIR/cmake_targets/tools/$file" "$destination" + if [ $? -ne 0 ] + then + error "copy of $file to $destination failed" + fi +} + +function patch() +{ + local directory="$1" + local array=$2 + local len=$3 # the length could be computed locally but the way to do it is not clear to me [CROUX] + + local i + local file + local sha1 + local replace + local item + + for (( i = 0; i < $len; i += 3 )) + do + # special bash syntax to access the array + item=$array[$i]; file=${!item} + item=$array[$((i+1))]; sha1=${!item} + item=$array[$((i+2))]; replace=${!item} + check_sha1 "$directory/$file" "$sha1" + copy_file "$replace" "$directory" + done +} + +function patch_rrc() +{ + local directory="$1" + local version="$2" + + case "$version" in + Rel10 ) + echo "patching RRC files release 10" + patch "$directory" RRC_Rel10 ${#RRC_Rel10[*]} + ;; + * ) + error unknwon/unhandled RRC version \'"$version"\' + ;; + esac +} + +function patch_x2ap() +{ + local directory="$1" + local version="$2" + + case "$version" in + R11 ) + echo "patching X2AP files release 11.2" + patch "$directory" X2AP_Rel11_2 ${#X2AP_Rel11_2[*]} + ;; + * ) + error unknwon/unhandled X2AP version \'"$version"\' + ;; + esac +} + +function patch_s1ap() +{ + local directory="$1" + local version="$2" + + case "$version" in + R10 ) + echo "patching S1AP files release 10.5" + patch "$directory" S1AP_Rel10_5 ${#S1AP_Rel10_5[*]} + ;; + * ) + error unknwon/unhandled S1AP version \'"$version"\' + ;; + esac +} + +function main() +{ + if [ $# -ne 3 ] + then + echo "ERROR: pass " + exit 1 + fi + + if [ x"$OPENAIR_DIR" = x ] + then + error "the variable OPENAIR_DIR is not set" + fi + + local directory="$1" + local module="$2" + local version="$3" + + case "$module" in + RRC ) + patch_rrc "$directory" "$version" + ;; + X2AP ) + patch_x2ap "$directory" "$version" + ;; + S1AP ) + patch_s1ap "$directory" "$version" + ;; + * ) + error unknown module "$module" + ;; + esac + + exit 0 +} + +main "$@" diff --git a/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h b/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h new file mode 100644 index 0000000000..baa09c12ef --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h @@ -0,0 +1,109 @@ +/* + * Generated by asn1c-0.9.24 (http://lionet.info/asn1c) + * From ASN.1 module "EUTRA-RRC-Definitions" + * found in "fixed_grammar.asn" + * `asn1c -gen-PER` + */ + +#ifndef _SystemInformation_r8_IEs_H_ +#define _SystemInformation_r8_IEs_H_ + + +#include + +/* Including external dependencies */ +#include +#include "SystemInformationBlockType2.h" +#include "SystemInformationBlockType3.h" +#include "SystemInformationBlockType4.h" +#include "SystemInformationBlockType5.h" +#include "SystemInformationBlockType6.h" +#include "SystemInformationBlockType7.h" +#include "SystemInformationBlockType8.h" +#include "SystemInformationBlockType9.h" +#include "SystemInformationBlockType10.h" +#include "SystemInformationBlockType11.h" +#include "SystemInformationBlockType12-r9.h" +#include "SystemInformationBlockType13-r9.h" +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Dependencies */ +typedef enum SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR { + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_NOTHING, /* No components present */ + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11, + /* Extensions may appear below */ + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920, + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920 +} SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR; + +/* Forward declarations */ +struct SystemInformation_v8a0_IEs; + + union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u { + SystemInformationBlockType2_t sib2; + SystemInformationBlockType3_t sib3; + SystemInformationBlockType4_t sib4; + SystemInformationBlockType5_t sib5; + SystemInformationBlockType6_t sib6; + SystemInformationBlockType7_t sib7; + SystemInformationBlockType8_t sib8; + SystemInformationBlockType9_t sib9; + SystemInformationBlockType10_t sib10; + SystemInformationBlockType11_t sib11; + /* + * This type is extensible, + * possible extensions are below. + */ + SystemInformationBlockType12_r9_t sib12_v920; + SystemInformationBlockType13_r9_t sib13_v920; + }; + + struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member { + SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present; + union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + }; + +/* SystemInformation-r8-IEs */ +typedef struct SystemInformation_r8_IEs { + struct SystemInformation_r8_IEs__sib_TypeAndInfo { + A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member) list; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } sib_TypeAndInfo; + struct SystemInformation_v8a0_IEs *nonCriticalExtension /* OPTIONAL */; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} SystemInformation_r8_IEs_t; + +/* Implementation */ +extern asn_TYPE_descriptor_t asn_DEF_SystemInformation_r8_IEs; + +#ifdef __cplusplus +} +#endif + +/* Referred external types */ +#include "SystemInformation-v8a0-IEs.h" + +#endif /* _SystemInformation_r8_IEs_H_ */ +#include diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c new file mode 100644 index 0000000000..239dbdc10f --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c @@ -0,0 +1,412 @@ +/*- + * Copyright (c) 2004, 2005, 2006 Lev Walkin . + * All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * Read the NativeInteger.h for the explanation wrt. differences between + * INTEGER and NativeInteger. + * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this + * implementation deals with the standard (machine-specific) representation + * of them instead of using the platform-independent buffer. + */ +#include +#include + +/* + * NativeInteger basic type description. + */ +static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_NativeInteger = { + "INTEGER", /* The ASN.1 type is still INTEGER */ + "INTEGER", + NativeInteger_free, + NativeInteger_print, + asn_generic_no_constraint, + NativeInteger_decode_ber, + NativeInteger_encode_der, + NativeInteger_decode_xer, + NativeInteger_encode_xer, + NativeInteger_decode_uper, /* Unaligned PER decoder */ + NativeInteger_encode_uper, /* Unaligned PER encoder */ + NativeInteger_decode_aper, /* Aligned PER decoder */ + NativeInteger_encode_aper, /* Aligned PER encoder */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_NativeInteger_tags, + sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), + asn_DEF_NativeInteger_tags, /* Same as above */ + sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), + 0, /* No PER visible constraints */ + 0, 0, /* No members */ + 0 /* No specifics */ +}; + +/* + * Decode INTEGER type. + */ +asn_dec_rval_t +NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, + void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + long *native = (long *)*nint_ptr; + asn_dec_rval_t rval; + ber_tlv_len_t length; + + /* + * If the structure is not there, allocate it. + */ + if(native == NULL) { + native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native))); + if(native == NULL) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + } + + ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", + td->name, tag_mode); + + /* + * Check tags. + */ + rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, + tag_mode, 0, &length, 0); + if(rval.code != RC_OK) + return rval; + + ASN_DEBUG("%s length is %d bytes", td->name, (int)length); + + /* + * Make sure we have this length. + */ + buf_ptr = ((const char *)buf_ptr) + rval.consumed; + size -= rval.consumed; + if(length > (ber_tlv_len_t)size) { + rval.code = RC_WMORE; + rval.consumed = 0; + return rval; + } + + /* + * ASN.1 encoded INTEGER: buf_ptr, length + * Fill the native, at the same time checking for overflow. + * If overflow occured, return with RC_FAIL. + */ + { + INTEGER_t tmp; + union { + const void *constbuf; + void *nonconstbuf; + } unconst_buf; + long l; + + unconst_buf.constbuf = buf_ptr; + tmp.buf = (uint8_t *)unconst_buf.nonconstbuf; + tmp.size = length; + + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&tmp, (unsigned long *)&l) /* sic */ + : asn_INTEGER2long(&tmp, &l)) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + + *native = l; + } + + rval.code = RC_OK; + rval.consumed += length; + + ASN_DEBUG("Took %ld/%ld bytes to encode %s (%ld)", + (long)rval.consumed, (long)length, td->name, (long)*native); + + return rval; +} + +/* + * Encode the NativeInteger using the standard INTEGER type DER encoder. + */ +asn_enc_rval_t +NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + unsigned long native = *(unsigned long *)ptr; /* Disable sign ext. */ + asn_enc_rval_t erval; + INTEGER_t tmp; + +#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */ + + tmp.buf = (uint8_t *)&native; + tmp.size = sizeof(native); + +#else /* Works even if WORDS_BIGENDIAN is not set where should've been */ + uint8_t buf[sizeof(native)]; + uint8_t *p; + + /* Prepare a fake INTEGER */ + for(p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) + *p = (uint8_t)native; + + tmp.buf = buf; + tmp.size = sizeof(buf); +#endif /* WORDS_BIGENDIAN */ + + /* Encode fake INTEGER */ + erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key); + if(erval.encoded == -1) { + assert(erval.structure_ptr == &tmp); + erval.structure_ptr = ptr; + } + return erval; +} + +/* + * Decode the chunk of XML text encoding INTEGER. + */ +asn_dec_rval_t +NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, + const void *buf_ptr, size_t size) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_dec_rval_t rval; + INTEGER_t st; + void *st_ptr = (void *)&st; + long *native = (long *)*sptr; + + if(!native) { + native = (long *)(*sptr = CALLOC(1, sizeof(*native))); + if(!native) _ASN_DECODE_FAILED; + } + + memset(&st, 0, sizeof(st)); + rval = INTEGER_decode_xer(opt_codec_ctx, td, &st_ptr, + opt_mname, buf_ptr, size); + if(rval.code == RC_OK) { + long l; + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&st, (unsigned long *)&l) /* sic */ + : asn_INTEGER2long(&st, &l)) { + rval.code = RC_FAIL; + rval.consumed = 0; + } else { + *native = l; + } + } else { + /* + * Cannot restart from the middle; + * there is no place to save state in the native type. + * Request a continuation from the very beginning. + */ + rval.consumed = 0; + } + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st); + return rval; +} + + +asn_enc_rval_t +NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + char scratch[32]; /* Enough for 64-bit int */ + asn_enc_rval_t er; + const long *native = (const long *)sptr; + + (void)ilevel; + (void)flags; + + if(!native) _ASN_ENCODE_FAILED; + + er.encoded = snprintf(scratch, sizeof(scratch), + (specs && specs->field_unsigned) + ? "%lu" : "%ld", *native); + if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) + || cb(scratch, er.encoded, app_key) < 0) + _ASN_ENCODE_FAILED; + + _ASN_ENCODED_OK(er); +} + +asn_dec_rval_t +NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_dec_rval_t rval; + long *native = (long *)*sptr; + INTEGER_t tmpint; + void *tmpintptr = &tmpint; + + (void)opt_codec_ctx; + ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name); + + if(!native) { + native = (long *)(*sptr = CALLOC(1, sizeof(*native))); + if(!native) _ASN_DECODE_FAILED; + } + + memset(&tmpint, 0, sizeof tmpint); + rval = INTEGER_decode_uper(opt_codec_ctx, td, constraints, + &tmpintptr, pd); + if(rval.code == RC_OK) { + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) + : asn_INTEGER2long(&tmpint, native)) + rval.code = RC_FAIL; + else + ASN_DEBUG("NativeInteger %s got value %ld", + td->name, *native); + } + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + + return rval; +} + +asn_dec_rval_t +NativeInteger_decode_aper(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_dec_rval_t rval; + long *native = (long *)*sptr; + INTEGER_t tmpint; + void *tmpintptr = &tmpint; + //int dynamic = 0; + + (void)opt_codec_ctx; + ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name); + + if(!native) { + native = (long *)(*sptr = CALLOC(1, sizeof(*native))); + //dynamic = 1; + if(!native) _ASN_DECODE_FAILED; + } + + memset(&tmpint, 0, sizeof tmpint); + rval = INTEGER_decode_aper(opt_codec_ctx, td, constraints, + &tmpintptr, pd); + if(rval.code == RC_OK) { + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) + : asn_INTEGER2long(&tmpint, native)) + rval.code = RC_FAIL; + else + ASN_DEBUG("NativeInteger %s got value %ld", + td->name, *native); + } + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + //if (dynamic) + // free(native); + + return rval; +} + +asn_enc_rval_t +NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_enc_rval_t er; + long native; + INTEGER_t tmpint; + + if(!sptr) _ASN_ENCODE_FAILED; + + native = *(long *)sptr; + + ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native); + + memset(&tmpint, 0, sizeof(tmpint)); + if((specs&&specs->field_unsigned) + ? asn_ulong2INTEGER(&tmpint, native) + : asn_long2INTEGER(&tmpint, native)) + _ASN_ENCODE_FAILED; + er = INTEGER_encode_uper(td, constraints, &tmpint, po); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + return er; +} + +asn_enc_rval_t +NativeInteger_encode_aper( + asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { + + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_enc_rval_t er; + INTEGER_t tmpint; + + if(!sptr) _ASN_ENCODE_FAILED; + memset(&tmpint, 0, sizeof(tmpint)); + + if(specs&&specs->field_unsigned) { + unsigned long native; + native = *(unsigned long *)sptr; + + ASN_DEBUG("Encoding NativeInteger %s %lu (APER) (unsigned)", td->name, native); + + if(asn_ulong2INTEGER(&tmpint, native)) + _ASN_ENCODE_FAILED; + } else { + long native; + native = *(long *)sptr; + + ASN_DEBUG("Encoding NativeInteger %s %ld (APER) (unsigned)", td->name, native); + if(asn_long2INTEGER(&tmpint, native)) + _ASN_ENCODE_FAILED; + } + +// if((specs&&specs->field_unsigned) +// ? asn_ulong2INTEGER(&tmpint, native) +// : asn_long2INTEGER(&tmpint, native)) +// _ASN_ENCODE_FAILED; + er = INTEGER_encode_aper(td, constraints, &tmpint, po); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + return er; +} + +/* + * INTEGER specific human-readable output. + */ +int +NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + const long *native = (const long *)sptr; + char scratch[32]; /* Enough for 64-bit int */ + int ret; + + (void)td; /* Unused argument */ + (void)ilevel; /* Unused argument */ + + if(native) { + ret = snprintf(scratch, sizeof(scratch), + (specs && specs->field_unsigned) + ? "%lu" : "%ld", *native); + assert(ret > 0 && (size_t)ret < sizeof(scratch)); + return (cb(scratch, ret, app_key) < 0) ? -1 : 0; + } else { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } +} + +void +NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { + + if(!td || !ptr) + return; + + ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", + td->name, contents_only, ptr); + + if(!contents_only) { + FREEMEM(ptr); + } +} + diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c new file mode 100644 index 0000000000..3e2d23b254 --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c @@ -0,0 +1,1041 @@ +/*- + * Copyright (c) 2003, 2004, 2005 Lev Walkin . + * All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +/* + * Number of bytes left for this structure. + * (ctx->left) indicates the number of bytes _transferred_ for the structure. + * (size) contains the number of bytes in the buffer passed. + */ +#define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) + +/* + * If the subprocessor function returns with an indication that it wants + * more data, it may well be a fatal decoding problem, because the + * size is constrained by the 's L, even if the buffer size allows + * reading more data. + * For example, consider the buffer containing the following TLVs: + * ... + * The TLV length clearly indicates that one byte is expected in V, but + * if the V processor returns with "want more data" even if the buffer + * contains way more data than the V processor have seen. + */ +#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) + +/* + * This macro "eats" the part of the buffer which is definitely "consumed", + * i.e. was correctly converted into local representation or rightfully skipped. + */ +#undef ADVANCE +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr = ((const char *)ptr) + num;\ + size -= num; \ + if(ctx->left >= 0) \ + ctx->left -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Switch to the next phase of parsing. + */ +#undef NEXT_PHASE +#undef PHASE_OUT +#define NEXT_PHASE(ctx) do { \ + ctx->phase++; \ + ctx->step = 0; \ + } while(0) +#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) + +/* + * Return a standardized complex structure. + */ +#undef RETURN +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +/* + * The decoder of the SET OF type. + */ +asn_dec_rval_t +SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **struct_ptr, const void *ptr, size_t size, int tag_mode) { + /* + * Bring closer parts of structure description. + */ + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; /* Single one */ + + /* + * Parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + asn_struct_ctx_t *ctx; /* Decoder context */ + + ber_tlv_tag_t tlv_tag; /* T from TLV */ + asn_dec_rval_t rval; /* Return code from subparsers */ + + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + + ASN_DEBUG("Decoding %s as SET OF", td->name); + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) { + RETURN(RC_FAIL); + } + } + + /* + * Restore parsing context. + */ + ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); + + /* + * Start to parse where left previously + */ + switch(ctx->phase) { + case 0: + /* + * PHASE 0. + * Check that the set of tags associated with given structure + * perfectly fits our expectations. + */ + + rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, + tag_mode, 1, &ctx->left, 0); + if(rval.code != RC_OK) { + ASN_DEBUG("%s tagging check failed: %d", + td->name, rval.code); + return rval; + } + + if(ctx->left >= 0) + ctx->left += rval.consumed; /* ?Substracted below! */ + ADVANCE(rval.consumed); + + ASN_DEBUG("Structure consumes %ld bytes, " + "buffer %ld", (long)ctx->left, (long)size); + + NEXT_PHASE(ctx); + /* Fall through */ + case 1: + /* + * PHASE 1. + * From the place where we've left it previously, + * try to decode the next item. + */ + for(;; ctx->step = 0) { + ssize_t tag_len; /* Length of TLV's T */ + + if(ctx->step & 1) + goto microphase2; + + /* + * MICROPHASE 1: Synchronize decoding. + */ + + if(ctx->left == 0) { + ASN_DEBUG("End of SET OF %s", td->name); + /* + * No more things to decode. + * Exit out of here. + */ + PHASE_OUT(ctx); + RETURN(RC_OK); + } + + /* + * Fetch the T from TLV. + */ + tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tag_len) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((const uint8_t *)ptr)[1] == 0) { + /* + * Found the terminator of the + * indefinite length structure. + */ + break; + } + } + + /* Outmost tag may be unknown and cannot be fetched/compared */ + if(elm->tag != (ber_tlv_tag_t)-1) { + if(BER_TAGS_EQUAL(tlv_tag, elm->tag)) { + /* + * The new list member of expected type has arrived. + */ + } else { + ASN_DEBUG("Unexpected tag %s fixed SET OF %s", + ber_tlv_tag_string(tlv_tag), td->name); + ASN_DEBUG("%s SET OF has tag %s", + td->name, ber_tlv_tag_string(elm->tag)); + RETURN(RC_FAIL); + } + } + + /* + * MICROPHASE 2: Invoke the member-specific decoder. + */ + ctx->step |= 1; /* Confirm entering next microphase */ + microphase2: + + /* + * Invoke the member fetch routine according to member's type + */ + rval = elm->type->ber_decoder(opt_codec_ctx, + elm->type, &ctx->ptr, ptr, LEFT, 0); + ASN_DEBUG("In %s SET OF %s code %d consumed %d", + td->name, elm->type->name, + rval.code, (int)rval.consumed); + switch(rval.code) { + case RC_OK: + { + asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); + if(ASN_SET_ADD(list, ctx->ptr) != 0) + RETURN(RC_FAIL); + else + ctx->ptr = 0; + } + break; + case RC_WMORE: /* More data expected */ + if(!SIZE_VIOLATION) { + ADVANCE(rval.consumed); + RETURN(RC_WMORE); + } + /* Fall through */ + case RC_FAIL: /* Fatal error */ + ASN_STRUCT_FREE(*elm->type, ctx->ptr); + ctx->ptr = 0; + RETURN(RC_FAIL); + } /* switch(rval) */ + + ADVANCE(rval.consumed); + } /* for(all list members) */ + + NEXT_PHASE(ctx); + case 2: + /* + * Read in all "end of content" TLVs. + */ + while(ctx->left < 0) { + if(LEFT < 2) { + if(LEFT > 0 && ((const char *)ptr)[0] != 0) { + /* Unexpected tag */ + RETURN(RC_FAIL); + } else { + RETURN(RC_WMORE); + } + } + if(((const char *)ptr)[0] == 0 + && ((const char *)ptr)[1] == 0) { + ADVANCE(2); + ctx->left++; + } else { + RETURN(RC_FAIL); + } + } + + PHASE_OUT(ctx); + } + + RETURN(RC_OK); +} + +/* + * Internally visible buffer holding a single encoded element. + */ +struct _el_buffer { + uint8_t *buf; + size_t length; + size_t size; +}; +/* Append bytes to the above structure */ +static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { + struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; + + if(el_buf->length + size > el_buf->size) + return -1; + + memcpy(el_buf->buf + el_buf->length, buffer, size); + + el_buf->length += size; + return 0; +} +static int _el_buf_cmp(const void *ap, const void *bp) { + const struct _el_buffer *a = (const struct _el_buffer *)ap; + const struct _el_buffer *b = (const struct _el_buffer *)bp; + int ret; + size_t common_len; + + if(a->length < b->length) + common_len = a->length; + else + common_len = b->length; + + ret = memcmp(a->buf, b->buf, common_len); + if(ret == 0) { + if(a->length < b->length) + ret = -1; + else if(a->length > b->length) + ret = 1; + } + + return ret; +} + +/* + * The DER encoder of the SET OF type. + */ +asn_enc_rval_t +SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_TYPE_member_t *elm = td->elements; + asn_TYPE_descriptor_t *elm_type = elm->type; + der_type_encoder_f *der_encoder = elm_type->der_encoder; + asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); + size_t computed_size = 0; + ssize_t encoding_size = 0; + struct _el_buffer *encoded_els; + ssize_t eels_count = 0; + size_t max_encoded_len = 1; + asn_enc_rval_t erval; + int ret; + int edx; + + ASN_DEBUG("Estimating size for SET OF %s", td->name); + + /* + * Gather the length of the underlying members sequence. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + if(!memb_ptr) continue; + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); + if(erval.encoded == -1) + return erval; + computed_size += erval.encoded; + + /* Compute maximum encoding's size */ + if(max_encoded_len < (size_t)erval.encoded) + max_encoded_len = erval.encoded; + } + + /* + * Encode the TLV for the sequence itself. + */ + encoding_size = der_write_tags(td, computed_size, tag_mode, 1, tag, + cb, app_key); + if(encoding_size == -1) { + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + return erval; + } + computed_size += encoding_size; + + if(!cb || list->count == 0) { + erval.encoded = computed_size; + _ASN_ENCODED_OK(erval); + } + + /* + * DER mandates dynamic sorting of the SET OF elements + * according to their encodings. Build an array of the + * encoded elements. + */ + encoded_els = (struct _el_buffer *)MALLOC( + list->count * sizeof(encoded_els[0])); + if(encoded_els == NULL) { + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + return erval; + } + + ASN_DEBUG("Encoding members of %s SET OF", td->name); + + /* + * Encode all members. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + struct _el_buffer *encoded_el = &encoded_els[eels_count]; + + if(!memb_ptr) continue; + + /* + * Prepare space for encoding. + */ + encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len); + if(encoded_el->buf) { + encoded_el->length = 0; + encoded_el->size = max_encoded_len; + } else { + for(edx--; edx >= 0; edx--) + FREEMEM(encoded_els[edx].buf); + FREEMEM(encoded_els); + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + return erval; + } + + /* + * Encode the member into the prepared space. + */ + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, + _el_addbytes, encoded_el); + if(erval.encoded == -1) { + for(; edx >= 0; edx--) + FREEMEM(encoded_els[edx].buf); + FREEMEM(encoded_els); + return erval; + } + encoding_size += erval.encoded; + eels_count++; + } + + /* + * Sort the encoded elements according to their encoding. + */ + qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); + + /* + * Report encoded elements to the application. + * Dispose of temporary sorted members table. + */ + ret = 0; + for(edx = 0; edx < eels_count; edx++) { + struct _el_buffer *encoded_el = &encoded_els[edx]; + /* Report encoded chunks to the application */ + if(ret == 0 + && cb(encoded_el->buf, encoded_el->length, app_key) < 0) + ret = -1; + FREEMEM(encoded_el->buf); + } + FREEMEM(encoded_els); + + if(ret || computed_size != (size_t)encoding_size) { + /* + * Standard callback failed, or + * encoded size is not equal to the computed size. + */ + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + } else { + erval.encoded = computed_size; + } + + _ASN_ENCODED_OK(erval); +} + +#undef XER_ADVANCE +#define XER_ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + buf_ptr = ((const char *)buf_ptr) + num;\ + size -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Decode the XER (XML) data. + */ +asn_dec_rval_t +SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **struct_ptr, const char *opt_mname, + const void *buf_ptr, size_t size) { + /* + * Bring closer parts of structure description. + */ + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *element = td->elements; + const char *elm_tag; + const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; + + /* + * ... and parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + asn_struct_ctx_t *ctx; /* Decoder context */ + + asn_dec_rval_t rval; /* Return value from a decoder */ + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) RETURN(RC_FAIL); + } + + /* Which tag is expected for the downstream */ + if(specs->as_XMLValueList) { + elm_tag = (specs->as_XMLValueList == 1) ? 0 : ""; + } else { + elm_tag = (*element->name) + ? element->name : element->type->xml_tag; + } + + /* + * Restore parsing context. + */ + ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); + + /* + * Phases of XER/XML processing: + * Phase 0: Check that the opening tag matches our expectations. + * Phase 1: Processing body and reacting on closing tag. + * Phase 2: Processing inner type. + */ + for(; ctx->phase <= 2;) { + pxer_chunk_type_e ch_type; /* XER chunk type */ + ssize_t ch_size; /* Chunk size */ + xer_check_tag_e tcv; /* Tag check value */ + + /* + * Go inside the inner member of a set. + */ + if(ctx->phase == 2) { + asn_dec_rval_t tmprval; + + /* Invoke the inner type decoder, m.b. multiple times */ + ASN_DEBUG("XER/SET OF element [%s]", elm_tag); + tmprval = element->type->xer_decoder(opt_codec_ctx, + element->type, &ctx->ptr, elm_tag, + buf_ptr, size); + if(tmprval.code == RC_OK) { + asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); + if(ASN_SET_ADD(list, ctx->ptr) != 0) + RETURN(RC_FAIL); + ctx->ptr = 0; + XER_ADVANCE(tmprval.consumed); + } else { + XER_ADVANCE(tmprval.consumed); + RETURN(tmprval.code); + } + ctx->phase = 1; /* Back to body processing */ + ASN_DEBUG("XER/SET OF phase => %d", ctx->phase); + /* Fall through */ + } + + /* + * Get the next part of the XML stream. + */ + ch_size = xer_next_token(&ctx->context, + buf_ptr, size, &ch_type); + switch(ch_size) { + case -1: RETURN(RC_FAIL); + case 0: RETURN(RC_WMORE); + default: + switch(ch_type) { + case PXER_COMMENT: /* Got XML comment */ + case PXER_TEXT: /* Ignore free-standing text */ + XER_ADVANCE(ch_size); /* Skip silently */ + continue; + case PXER_TAG: + break; /* Check the rest down there */ + } + } + + tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); + ASN_DEBUG("XER/SET OF: tcv = %d, ph=%d t=%s", + tcv, ctx->phase, xml_tag); + switch(tcv) { + case XCT_CLOSING: + if(ctx->phase == 0) break; + ctx->phase = 0; + /* Fall through */ + case XCT_BOTH: + if(ctx->phase == 0) { + /* No more things to decode */ + XER_ADVANCE(ch_size); + ctx->phase = 3; /* Phase out */ + RETURN(RC_OK); + } + /* Fall through */ + case XCT_OPENING: + if(ctx->phase == 0) { + XER_ADVANCE(ch_size); + ctx->phase = 1; /* Processing body phase */ + continue; + } + /* Fall through */ + case XCT_UNKNOWN_OP: + case XCT_UNKNOWN_BO: + + ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); + if(ctx->phase == 1) { + /* + * Process a single possible member. + */ + ctx->phase = 2; + continue; + } + /* Fall through */ + default: + break; + } + + ASN_DEBUG("Unexpected XML tag in SET OF"); + break; + } + + ctx->phase = 3; /* "Phase out" on hard failure */ + RETURN(RC_FAIL); +} + + + +typedef struct xer_tmp_enc_s { + void *buffer; + size_t offset; + size_t size; +} xer_tmp_enc_t; +static int +SET_OF_encode_xer_callback(const void *buffer, size_t size, void *key) { + xer_tmp_enc_t *t = (xer_tmp_enc_t *)key; + if(t->offset + size >= t->size) { + size_t newsize = (t->size << 2) + size; + void *p = REALLOC(t->buffer, newsize); + if(!p) return -1; + t->buffer = p; + t->size = newsize; + } + memcpy((char *)t->buffer + t->offset, buffer, size); + t->offset += size; + return 0; +} +static int +SET_OF_xer_order(const void *aptr, const void *bptr) { + const xer_tmp_enc_t *a = (const xer_tmp_enc_t *)aptr; + const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; + size_t minlen = a->offset; + int ret; + if(b->offset < minlen) minlen = b->offset; + /* Well-formed UTF-8 has this nice lexicographical property... */ + ret = memcmp(a->buffer, b->buffer, minlen); + if(ret != 0) return ret; + if(a->offset == b->offset) + return 0; + if(a->offset == minlen) + return -1; + return 1; +} + + +asn_enc_rval_t +SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_enc_rval_t er; + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; + asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr); + const char *mname = specs->as_XMLValueList + ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag); + size_t mlen = mname ? strlen(mname) : 0; + int xcan = (flags & XER_F_CANONICAL); + xer_tmp_enc_t *encs = 0; + size_t encs_count = 0; + void *original_app_key = app_key; + asn_app_consume_bytes_f *original_cb = cb; + int i; + + if(!sptr) _ASN_ENCODE_FAILED; + + if(xcan) { + encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); + if(!encs) _ASN_ENCODE_FAILED; + cb = SET_OF_encode_xer_callback; + } + + er.encoded = 0; + + for(i = 0; i < list->count; i++) { + asn_enc_rval_t tmper; + + void *memb_ptr = list->array[i]; + if(!memb_ptr) continue; + + if(encs) { + memset(&encs[encs_count], 0, sizeof(encs[0])); + app_key = &encs[encs_count]; + encs_count++; + } + + if(mname) { + if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); + } + + if(!xcan && specs->as_XMLValueList == 1) + _i_ASN_TEXT_INDENT(1, ilevel + 1); + tmper = elm->type->xer_encoder(elm->type, memb_ptr, + ilevel + (specs->as_XMLValueList != 2), + flags, cb, app_key); + if(tmper.encoded == -1) { + td = tmper.failed_type; + sptr = tmper.structure_ptr; + goto cb_failed; + } + if(tmper.encoded == 0 && specs->as_XMLValueList) { + const char *name = elm->type->xml_tag; + size_t len = strlen(name); + _ASN_CALLBACK3("<", 1, name, len, "/>", 2); + } + + if(mname) { + _ASN_CALLBACK3("", 1); + er.encoded += 5; + } + + er.encoded += (2 * mlen) + tmper.encoded; + } + + if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + + if(encs) { + xer_tmp_enc_t *enc = encs; + xer_tmp_enc_t *end = encs + encs_count; + ssize_t control_size = 0; + + cb = original_cb; + app_key = original_app_key; + qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order); + + for(; enc < end; enc++) { + _ASN_CALLBACK(enc->buffer, enc->offset); + FREEMEM(enc->buffer); + enc->buffer = 0; + control_size += enc->offset; + } + assert(control_size == er.encoded); + } + + goto cleanup; +cb_failed: + er.encoded = -1; + er.failed_type = td; + er.structure_ptr = sptr; +cleanup: + if(encs) { + while(encs_count-- > 0) { + if(encs[encs_count].buffer) + FREEMEM(encs[encs_count].buffer); + } + FREEMEM(encs); + } + _ASN_ENCODED_OK(er); +} + +int +SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_TYPE_member_t *elm = td->elements; + const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); + int ret; + int i; + + if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + + /* Dump preamble */ + if(cb(td->name, strlen(td->name), app_key) < 0 + || cb(" ::= {", 6, app_key) < 0) + return -1; + + for(i = 0; i < list->count; i++) { + const void *memb_ptr = list->array[i]; + if(!memb_ptr) continue; + + _i_INDENT(1); + + ret = elm->type->print_struct(elm->type, memb_ptr, + ilevel + 1, cb, app_key); + if(ret) return ret; + } + + ilevel--; + _i_INDENT(1); + + return (cb("}", 1, app_key) < 0) ? -1 : 0; +} + +void +SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { + if(td && ptr) { + asn_SET_OF_specifics_t *specs; + asn_TYPE_member_t *elm = td->elements; + asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); + asn_struct_ctx_t *ctx; /* Decoder context */ + int i; + + /* + * Could not use set_of_empty() because of (*free) + * incompatibility. + */ + for(i = 0; i < list->count; i++) { + void *memb_ptr = list->array[i]; + if(memb_ptr) + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } + list->count = 0; /* No meaningful elements left */ + + asn_set_empty(list); /* Remove (list->array) */ + + specs = (asn_SET_OF_specifics_t *)td->specifics; + ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset); + if(ctx->ptr) { + ASN_STRUCT_FREE(*elm->type, ctx->ptr); + ctx->ptr = 0; + } + + if(!contents_only) { + FREEMEM(ptr); + } + } +} + +int +SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) { + asn_TYPE_member_t *elm = td->elements; + asn_constr_check_f *constr; + const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); + int i; + + if(!sptr) { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + constr = elm->memb_constraints; + if(!constr) constr = elm->type->check_constraints; + + /* + * Iterate over the members of an array. + * Validate each in turn, until one fails. + */ + for(i = 0; i < list->count; i++) { + const void *memb_ptr = list->array[i]; + int ret; + + if(!memb_ptr) continue; + + ret = constr(elm->type, memb_ptr, ctfailcb, app_key); + if(ret) return ret; + } + + /* + * Cannot inherit it eralier: + * need to make sure we get the updated version. + */ + if(!elm->memb_constraints) + elm->memb_constraints = elm->type->check_constraints; + + return 0; +} + +asn_dec_rval_t +SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + asn_dec_rval_t rv; + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; /* Single one */ + void *st = *sptr; + asn_anonymous_set_ *list; + asn_per_constraint_t *ct; + int repeat = 0; + ssize_t nelems; + + if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + _ASN_DECODE_FAILED; + + /* + * Create the target structure if it is not present already. + */ + if(!st) { + st = *sptr = CALLOC(1, specs->struct_size); + if(!st) _ASN_DECODE_FAILED; + } + list = _A_SET_FROM_VOID(st); + + /* Figure out which constraints to use */ + if(constraints) ct = &constraints->size; + else if(td->per_constraints) ct = &td->per_constraints->size; + else ct = 0; + + if(ct && ct->flags & APC_EXTENSIBLE) { + int value = per_get_few_bits(pd, 1); + if(value < 0) _ASN_DECODE_STARVED; + if(value) ct = 0; /* Not restricted! */ + } + + if(ct && ct->effective_bits >= 0) { + /* X.691, #19.5: No length determinant */ + nelems = per_get_few_bits(pd, ct->effective_bits); + ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", + (long)nelems, ct->lower_bound, td->name); + if(nelems < 0) _ASN_DECODE_STARVED; + nelems += ct->lower_bound; + } else { + nelems = -1; + } + + do { + int i; + if(nelems < 0) { + nelems = uper_get_length(pd, + ct ? ct->effective_bits : -1, &repeat); + ASN_DEBUG("Got to decode %d elements (eff %d)", + (int)nelems, (int)(ct ? ct->effective_bits : -1)); + if(nelems < 0) _ASN_DECODE_STARVED; + } + + for(i = 0; i < nelems; i++) { + void *ptr = 0; + ASN_DEBUG("SET OF %s decoding", elm->type->name); + rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, + elm->per_constraints, &ptr, pd); + ASN_DEBUG("%s SET OF %s decoded %d, %p", + td->name, elm->type->name, rv.code, ptr); + if(rv.code == RC_OK) { + if(ASN_SET_ADD(list, ptr) == 0) + continue; + ASN_DEBUG("Failed to add element into %s", + td->name); + /* Fall through */ + rv.code = RC_FAIL; + } else { + ASN_DEBUG("Failed decoding %s of %s (SET OF)", + elm->type->name, td->name); + } + if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); + return rv; + } + + nelems = -1; /* Allow uper_get_length() */ + } while(repeat); + + ASN_DEBUG("Decoded %s as SET OF", td->name); + + rv.code = RC_OK; + rv.consumed = 0; + return rv; +} + +asn_dec_rval_t +SET_OF_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + asn_dec_rval_t rv; + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; /* Single one */ + void *st = *sptr; + asn_anonymous_set_ *list; + asn_per_constraint_t *ct; + int repeat = 0; + ssize_t nelems; + + if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + _ASN_DECODE_FAILED; + + /* + * Create the target structure if it is not present already. + */ + if(!st) { + st = *sptr = CALLOC(1, specs->struct_size); + if(!st) _ASN_DECODE_FAILED; + } + list = _A_SET_FROM_VOID(st); + + /* Figure out which constraints to use */ + if(constraints) ct = &constraints->size; + else if(td->per_constraints) ct = &td->per_constraints->size; + else ct = 0; + + if(ct && ct->flags & APC_EXTENSIBLE) { + int value = per_get_few_bits(pd, 1); + if(value < 0) _ASN_DECODE_STARVED; + if(value) ct = 0; /* Not restricted! */ + } + + if(ct && ct->effective_bits >= 0) { + /* X.691, #19.5: No length determinant */ +// nelems = per_get_few_bits(pd, ct->effective_bits); + nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound); + ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", + (long)nelems, ct->lower_bound, td->name); + if(nelems < 0) _ASN_DECODE_STARVED; + nelems += ct->lower_bound; + } else { + nelems = -1; + } + + do { + int i; + if(nelems < 0) { + nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1, + ct ? ct->effective_bits : -1, &repeat); + ASN_DEBUG("Got to decode %d elements (eff %d)", + (int)nelems, ct ? ct->effective_bits : -1); + if(nelems < 0) _ASN_DECODE_STARVED; + } + + for(i = 0; i < nelems; i++) { + void *ptr = 0; + ASN_DEBUG("SET OF %s decoding", elm->type->name); + rv = elm->type->aper_decoder(opt_codec_ctx, elm->type, + elm->per_constraints, &ptr, pd); + ASN_DEBUG("%s SET OF %s decoded %d, %p", + td->name, elm->type->name, rv.code, ptr); + if(rv.code == RC_OK) { + if(ASN_SET_ADD(list, ptr) == 0) + continue; + ASN_DEBUG("Failed to add element into %s", + td->name); + /* Fall through */ + rv.code = RC_FAIL; + } else { + ASN_DEBUG("Failed decoding %s of %s (SET OF)", + elm->type->name, td->name); + } + if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); + return rv; + } + + nelems = -1; /* Allow uper_get_length() */ + } while(repeat); + + ASN_DEBUG("Decoded %s as SET OF", td->name); + + rv.code = RC_OK; + rv.consumed = 0; + return rv; +} diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c new file mode 100644 index 0000000000..239dbdc10f --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c @@ -0,0 +1,412 @@ +/*- + * Copyright (c) 2004, 2005, 2006 Lev Walkin . + * All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +/* + * Read the NativeInteger.h for the explanation wrt. differences between + * INTEGER and NativeInteger. + * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this + * implementation deals with the standard (machine-specific) representation + * of them instead of using the platform-independent buffer. + */ +#include +#include + +/* + * NativeInteger basic type description. + */ +static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_NativeInteger = { + "INTEGER", /* The ASN.1 type is still INTEGER */ + "INTEGER", + NativeInteger_free, + NativeInteger_print, + asn_generic_no_constraint, + NativeInteger_decode_ber, + NativeInteger_encode_der, + NativeInteger_decode_xer, + NativeInteger_encode_xer, + NativeInteger_decode_uper, /* Unaligned PER decoder */ + NativeInteger_encode_uper, /* Unaligned PER encoder */ + NativeInteger_decode_aper, /* Aligned PER decoder */ + NativeInteger_encode_aper, /* Aligned PER encoder */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_NativeInteger_tags, + sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), + asn_DEF_NativeInteger_tags, /* Same as above */ + sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), + 0, /* No PER visible constraints */ + 0, 0, /* No members */ + 0 /* No specifics */ +}; + +/* + * Decode INTEGER type. + */ +asn_dec_rval_t +NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, + void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + long *native = (long *)*nint_ptr; + asn_dec_rval_t rval; + ber_tlv_len_t length; + + /* + * If the structure is not there, allocate it. + */ + if(native == NULL) { + native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native))); + if(native == NULL) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + } + + ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", + td->name, tag_mode); + + /* + * Check tags. + */ + rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, + tag_mode, 0, &length, 0); + if(rval.code != RC_OK) + return rval; + + ASN_DEBUG("%s length is %d bytes", td->name, (int)length); + + /* + * Make sure we have this length. + */ + buf_ptr = ((const char *)buf_ptr) + rval.consumed; + size -= rval.consumed; + if(length > (ber_tlv_len_t)size) { + rval.code = RC_WMORE; + rval.consumed = 0; + return rval; + } + + /* + * ASN.1 encoded INTEGER: buf_ptr, length + * Fill the native, at the same time checking for overflow. + * If overflow occured, return with RC_FAIL. + */ + { + INTEGER_t tmp; + union { + const void *constbuf; + void *nonconstbuf; + } unconst_buf; + long l; + + unconst_buf.constbuf = buf_ptr; + tmp.buf = (uint8_t *)unconst_buf.nonconstbuf; + tmp.size = length; + + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&tmp, (unsigned long *)&l) /* sic */ + : asn_INTEGER2long(&tmp, &l)) { + rval.code = RC_FAIL; + rval.consumed = 0; + return rval; + } + + *native = l; + } + + rval.code = RC_OK; + rval.consumed += length; + + ASN_DEBUG("Took %ld/%ld bytes to encode %s (%ld)", + (long)rval.consumed, (long)length, td->name, (long)*native); + + return rval; +} + +/* + * Encode the NativeInteger using the standard INTEGER type DER encoder. + */ +asn_enc_rval_t +NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + unsigned long native = *(unsigned long *)ptr; /* Disable sign ext. */ + asn_enc_rval_t erval; + INTEGER_t tmp; + +#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */ + + tmp.buf = (uint8_t *)&native; + tmp.size = sizeof(native); + +#else /* Works even if WORDS_BIGENDIAN is not set where should've been */ + uint8_t buf[sizeof(native)]; + uint8_t *p; + + /* Prepare a fake INTEGER */ + for(p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) + *p = (uint8_t)native; + + tmp.buf = buf; + tmp.size = sizeof(buf); +#endif /* WORDS_BIGENDIAN */ + + /* Encode fake INTEGER */ + erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key); + if(erval.encoded == -1) { + assert(erval.structure_ptr == &tmp); + erval.structure_ptr = ptr; + } + return erval; +} + +/* + * Decode the chunk of XML text encoding INTEGER. + */ +asn_dec_rval_t +NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, + const void *buf_ptr, size_t size) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_dec_rval_t rval; + INTEGER_t st; + void *st_ptr = (void *)&st; + long *native = (long *)*sptr; + + if(!native) { + native = (long *)(*sptr = CALLOC(1, sizeof(*native))); + if(!native) _ASN_DECODE_FAILED; + } + + memset(&st, 0, sizeof(st)); + rval = INTEGER_decode_xer(opt_codec_ctx, td, &st_ptr, + opt_mname, buf_ptr, size); + if(rval.code == RC_OK) { + long l; + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&st, (unsigned long *)&l) /* sic */ + : asn_INTEGER2long(&st, &l)) { + rval.code = RC_FAIL; + rval.consumed = 0; + } else { + *native = l; + } + } else { + /* + * Cannot restart from the middle; + * there is no place to save state in the native type. + * Request a continuation from the very beginning. + */ + rval.consumed = 0; + } + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st); + return rval; +} + + +asn_enc_rval_t +NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + char scratch[32]; /* Enough for 64-bit int */ + asn_enc_rval_t er; + const long *native = (const long *)sptr; + + (void)ilevel; + (void)flags; + + if(!native) _ASN_ENCODE_FAILED; + + er.encoded = snprintf(scratch, sizeof(scratch), + (specs && specs->field_unsigned) + ? "%lu" : "%ld", *native); + if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) + || cb(scratch, er.encoded, app_key) < 0) + _ASN_ENCODE_FAILED; + + _ASN_ENCODED_OK(er); +} + +asn_dec_rval_t +NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_dec_rval_t rval; + long *native = (long *)*sptr; + INTEGER_t tmpint; + void *tmpintptr = &tmpint; + + (void)opt_codec_ctx; + ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name); + + if(!native) { + native = (long *)(*sptr = CALLOC(1, sizeof(*native))); + if(!native) _ASN_DECODE_FAILED; + } + + memset(&tmpint, 0, sizeof tmpint); + rval = INTEGER_decode_uper(opt_codec_ctx, td, constraints, + &tmpintptr, pd); + if(rval.code == RC_OK) { + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) + : asn_INTEGER2long(&tmpint, native)) + rval.code = RC_FAIL; + else + ASN_DEBUG("NativeInteger %s got value %ld", + td->name, *native); + } + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + + return rval; +} + +asn_dec_rval_t +NativeInteger_decode_aper(asn_codec_ctx_t *opt_codec_ctx, + asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_dec_rval_t rval; + long *native = (long *)*sptr; + INTEGER_t tmpint; + void *tmpintptr = &tmpint; + //int dynamic = 0; + + (void)opt_codec_ctx; + ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name); + + if(!native) { + native = (long *)(*sptr = CALLOC(1, sizeof(*native))); + //dynamic = 1; + if(!native) _ASN_DECODE_FAILED; + } + + memset(&tmpint, 0, sizeof tmpint); + rval = INTEGER_decode_aper(opt_codec_ctx, td, constraints, + &tmpintptr, pd); + if(rval.code == RC_OK) { + if((specs&&specs->field_unsigned) + ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) + : asn_INTEGER2long(&tmpint, native)) + rval.code = RC_FAIL; + else + ASN_DEBUG("NativeInteger %s got value %ld", + td->name, *native); + } + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + //if (dynamic) + // free(native); + + return rval; +} + +asn_enc_rval_t +NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_enc_rval_t er; + long native; + INTEGER_t tmpint; + + if(!sptr) _ASN_ENCODE_FAILED; + + native = *(long *)sptr; + + ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native); + + memset(&tmpint, 0, sizeof(tmpint)); + if((specs&&specs->field_unsigned) + ? asn_ulong2INTEGER(&tmpint, native) + : asn_long2INTEGER(&tmpint, native)) + _ASN_ENCODE_FAILED; + er = INTEGER_encode_uper(td, constraints, &tmpint, po); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + return er; +} + +asn_enc_rval_t +NativeInteger_encode_aper( + asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { + + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + asn_enc_rval_t er; + INTEGER_t tmpint; + + if(!sptr) _ASN_ENCODE_FAILED; + memset(&tmpint, 0, sizeof(tmpint)); + + if(specs&&specs->field_unsigned) { + unsigned long native; + native = *(unsigned long *)sptr; + + ASN_DEBUG("Encoding NativeInteger %s %lu (APER) (unsigned)", td->name, native); + + if(asn_ulong2INTEGER(&tmpint, native)) + _ASN_ENCODE_FAILED; + } else { + long native; + native = *(long *)sptr; + + ASN_DEBUG("Encoding NativeInteger %s %ld (APER) (unsigned)", td->name, native); + if(asn_long2INTEGER(&tmpint, native)) + _ASN_ENCODE_FAILED; + } + +// if((specs&&specs->field_unsigned) +// ? asn_ulong2INTEGER(&tmpint, native) +// : asn_long2INTEGER(&tmpint, native)) +// _ASN_ENCODE_FAILED; + er = INTEGER_encode_aper(td, constraints, &tmpint, po); + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + return er; +} + +/* + * INTEGER specific human-readable output. + */ +int +NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; + const long *native = (const long *)sptr; + char scratch[32]; /* Enough for 64-bit int */ + int ret; + + (void)td; /* Unused argument */ + (void)ilevel; /* Unused argument */ + + if(native) { + ret = snprintf(scratch, sizeof(scratch), + (specs && specs->field_unsigned) + ? "%lu" : "%ld", *native); + assert(ret > 0 && (size_t)ret < sizeof(scratch)); + return (cb(scratch, ret, app_key) < 0) ? -1 : 0; + } else { + return (cb("", 8, app_key) < 0) ? -1 : 0; + } +} + +void +NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { + + if(!td || !ptr) + return; + + ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", + td->name, contents_only, ptr); + + if(!contents_only) { + FREEMEM(ptr); + } +} + diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h new file mode 100644 index 0000000000..d9c9fd1b4b --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h @@ -0,0 +1,63 @@ +/* + * Generated by asn1c-0.9.24 (http://lionet.info/asn1c) + * From ASN.1 module "X2AP-IEs" + * found in "/roux/comments/openairinterface5g/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn" + * `asn1c -gen-PER` + */ + +#ifndef _X2ap_CriticalityDiagnostics_IE_List_H_ +#define _X2ap_CriticalityDiagnostics_IE_List_H_ + + +#include + +/* Including external dependencies */ +#include +#include "X2ap-Criticality.h" +#include "X2ap-ProtocolIE-ID.h" +#include "X2ap-TypeOfError.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward declarations */ +struct X2ap_IE_Extensions; + +struct X2ap_CriticalityDiagnostics_IE_List__Member { + X2ap_Criticality_t iECriticality; + X2ap_ProtocolIE_ID_t iE_ID; + X2ap_TypeOfError_t typeOfError; + struct X2ap_IE_Extensions *iE_Extensions /* OPTIONAL */; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + }; + +/* X2ap-CriticalityDiagnostics-IE-List */ +typedef struct X2ap_CriticalityDiagnostics_IE_List { + A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member + ) list; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} X2ap_CriticalityDiagnostics_IE_List_t; + +/* Implementation */ +extern asn_TYPE_descriptor_t asn_DEF_X2ap_CriticalityDiagnostics_IE_List; + +#ifdef __cplusplus +} +#endif + +/* Referred external types */ +#include "X2ap-IE-Extensions.h" + +#endif /* _X2ap_CriticalityDiagnostics_IE_List_H_ */ +#include diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c new file mode 100644 index 0000000000..3e2d23b254 --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c @@ -0,0 +1,1041 @@ +/*- + * Copyright (c) 2003, 2004, 2005 Lev Walkin . + * All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#include +#include +#include + +/* + * Number of bytes left for this structure. + * (ctx->left) indicates the number of bytes _transferred_ for the structure. + * (size) contains the number of bytes in the buffer passed. + */ +#define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) + +/* + * If the subprocessor function returns with an indication that it wants + * more data, it may well be a fatal decoding problem, because the + * size is constrained by the 's L, even if the buffer size allows + * reading more data. + * For example, consider the buffer containing the following TLVs: + * ... + * The TLV length clearly indicates that one byte is expected in V, but + * if the V processor returns with "want more data" even if the buffer + * contains way more data than the V processor have seen. + */ +#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) + +/* + * This macro "eats" the part of the buffer which is definitely "consumed", + * i.e. was correctly converted into local representation or rightfully skipped. + */ +#undef ADVANCE +#define ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + ptr = ((const char *)ptr) + num;\ + size -= num; \ + if(ctx->left >= 0) \ + ctx->left -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Switch to the next phase of parsing. + */ +#undef NEXT_PHASE +#undef PHASE_OUT +#define NEXT_PHASE(ctx) do { \ + ctx->phase++; \ + ctx->step = 0; \ + } while(0) +#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) + +/* + * Return a standardized complex structure. + */ +#undef RETURN +#define RETURN(_code) do { \ + rval.code = _code; \ + rval.consumed = consumed_myself;\ + return rval; \ + } while(0) + +/* + * The decoder of the SET OF type. + */ +asn_dec_rval_t +SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **struct_ptr, const void *ptr, size_t size, int tag_mode) { + /* + * Bring closer parts of structure description. + */ + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; /* Single one */ + + /* + * Parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + asn_struct_ctx_t *ctx; /* Decoder context */ + + ber_tlv_tag_t tlv_tag; /* T from TLV */ + asn_dec_rval_t rval; /* Return code from subparsers */ + + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + + ASN_DEBUG("Decoding %s as SET OF", td->name); + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) { + RETURN(RC_FAIL); + } + } + + /* + * Restore parsing context. + */ + ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); + + /* + * Start to parse where left previously + */ + switch(ctx->phase) { + case 0: + /* + * PHASE 0. + * Check that the set of tags associated with given structure + * perfectly fits our expectations. + */ + + rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, + tag_mode, 1, &ctx->left, 0); + if(rval.code != RC_OK) { + ASN_DEBUG("%s tagging check failed: %d", + td->name, rval.code); + return rval; + } + + if(ctx->left >= 0) + ctx->left += rval.consumed; /* ?Substracted below! */ + ADVANCE(rval.consumed); + + ASN_DEBUG("Structure consumes %ld bytes, " + "buffer %ld", (long)ctx->left, (long)size); + + NEXT_PHASE(ctx); + /* Fall through */ + case 1: + /* + * PHASE 1. + * From the place where we've left it previously, + * try to decode the next item. + */ + for(;; ctx->step = 0) { + ssize_t tag_len; /* Length of TLV's T */ + + if(ctx->step & 1) + goto microphase2; + + /* + * MICROPHASE 1: Synchronize decoding. + */ + + if(ctx->left == 0) { + ASN_DEBUG("End of SET OF %s", td->name); + /* + * No more things to decode. + * Exit out of here. + */ + PHASE_OUT(ctx); + RETURN(RC_OK); + } + + /* + * Fetch the T from TLV. + */ + tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); + switch(tag_len) { + case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); + /* Fall through */ + case -1: RETURN(RC_FAIL); + } + + if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { + if(LEFT < 2) { + if(SIZE_VIOLATION) + RETURN(RC_FAIL); + else + RETURN(RC_WMORE); + } else if(((const uint8_t *)ptr)[1] == 0) { + /* + * Found the terminator of the + * indefinite length structure. + */ + break; + } + } + + /* Outmost tag may be unknown and cannot be fetched/compared */ + if(elm->tag != (ber_tlv_tag_t)-1) { + if(BER_TAGS_EQUAL(tlv_tag, elm->tag)) { + /* + * The new list member of expected type has arrived. + */ + } else { + ASN_DEBUG("Unexpected tag %s fixed SET OF %s", + ber_tlv_tag_string(tlv_tag), td->name); + ASN_DEBUG("%s SET OF has tag %s", + td->name, ber_tlv_tag_string(elm->tag)); + RETURN(RC_FAIL); + } + } + + /* + * MICROPHASE 2: Invoke the member-specific decoder. + */ + ctx->step |= 1; /* Confirm entering next microphase */ + microphase2: + + /* + * Invoke the member fetch routine according to member's type + */ + rval = elm->type->ber_decoder(opt_codec_ctx, + elm->type, &ctx->ptr, ptr, LEFT, 0); + ASN_DEBUG("In %s SET OF %s code %d consumed %d", + td->name, elm->type->name, + rval.code, (int)rval.consumed); + switch(rval.code) { + case RC_OK: + { + asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); + if(ASN_SET_ADD(list, ctx->ptr) != 0) + RETURN(RC_FAIL); + else + ctx->ptr = 0; + } + break; + case RC_WMORE: /* More data expected */ + if(!SIZE_VIOLATION) { + ADVANCE(rval.consumed); + RETURN(RC_WMORE); + } + /* Fall through */ + case RC_FAIL: /* Fatal error */ + ASN_STRUCT_FREE(*elm->type, ctx->ptr); + ctx->ptr = 0; + RETURN(RC_FAIL); + } /* switch(rval) */ + + ADVANCE(rval.consumed); + } /* for(all list members) */ + + NEXT_PHASE(ctx); + case 2: + /* + * Read in all "end of content" TLVs. + */ + while(ctx->left < 0) { + if(LEFT < 2) { + if(LEFT > 0 && ((const char *)ptr)[0] != 0) { + /* Unexpected tag */ + RETURN(RC_FAIL); + } else { + RETURN(RC_WMORE); + } + } + if(((const char *)ptr)[0] == 0 + && ((const char *)ptr)[1] == 0) { + ADVANCE(2); + ctx->left++; + } else { + RETURN(RC_FAIL); + } + } + + PHASE_OUT(ctx); + } + + RETURN(RC_OK); +} + +/* + * Internally visible buffer holding a single encoded element. + */ +struct _el_buffer { + uint8_t *buf; + size_t length; + size_t size; +}; +/* Append bytes to the above structure */ +static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { + struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; + + if(el_buf->length + size > el_buf->size) + return -1; + + memcpy(el_buf->buf + el_buf->length, buffer, size); + + el_buf->length += size; + return 0; +} +static int _el_buf_cmp(const void *ap, const void *bp) { + const struct _el_buffer *a = (const struct _el_buffer *)ap; + const struct _el_buffer *b = (const struct _el_buffer *)bp; + int ret; + size_t common_len; + + if(a->length < b->length) + common_len = a->length; + else + common_len = b->length; + + ret = memcmp(a->buf, b->buf, common_len); + if(ret == 0) { + if(a->length < b->length) + ret = -1; + else if(a->length > b->length) + ret = 1; + } + + return ret; +} + +/* + * The DER encoder of the SET OF type. + */ +asn_enc_rval_t +SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, + int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_TYPE_member_t *elm = td->elements; + asn_TYPE_descriptor_t *elm_type = elm->type; + der_type_encoder_f *der_encoder = elm_type->der_encoder; + asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); + size_t computed_size = 0; + ssize_t encoding_size = 0; + struct _el_buffer *encoded_els; + ssize_t eels_count = 0; + size_t max_encoded_len = 1; + asn_enc_rval_t erval; + int ret; + int edx; + + ASN_DEBUG("Estimating size for SET OF %s", td->name); + + /* + * Gather the length of the underlying members sequence. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + if(!memb_ptr) continue; + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); + if(erval.encoded == -1) + return erval; + computed_size += erval.encoded; + + /* Compute maximum encoding's size */ + if(max_encoded_len < (size_t)erval.encoded) + max_encoded_len = erval.encoded; + } + + /* + * Encode the TLV for the sequence itself. + */ + encoding_size = der_write_tags(td, computed_size, tag_mode, 1, tag, + cb, app_key); + if(encoding_size == -1) { + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + return erval; + } + computed_size += encoding_size; + + if(!cb || list->count == 0) { + erval.encoded = computed_size; + _ASN_ENCODED_OK(erval); + } + + /* + * DER mandates dynamic sorting of the SET OF elements + * according to their encodings. Build an array of the + * encoded elements. + */ + encoded_els = (struct _el_buffer *)MALLOC( + list->count * sizeof(encoded_els[0])); + if(encoded_els == NULL) { + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + return erval; + } + + ASN_DEBUG("Encoding members of %s SET OF", td->name); + + /* + * Encode all members. + */ + for(edx = 0; edx < list->count; edx++) { + void *memb_ptr = list->array[edx]; + struct _el_buffer *encoded_el = &encoded_els[eels_count]; + + if(!memb_ptr) continue; + + /* + * Prepare space for encoding. + */ + encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len); + if(encoded_el->buf) { + encoded_el->length = 0; + encoded_el->size = max_encoded_len; + } else { + for(edx--; edx >= 0; edx--) + FREEMEM(encoded_els[edx].buf); + FREEMEM(encoded_els); + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + return erval; + } + + /* + * Encode the member into the prepared space. + */ + erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, + _el_addbytes, encoded_el); + if(erval.encoded == -1) { + for(; edx >= 0; edx--) + FREEMEM(encoded_els[edx].buf); + FREEMEM(encoded_els); + return erval; + } + encoding_size += erval.encoded; + eels_count++; + } + + /* + * Sort the encoded elements according to their encoding. + */ + qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); + + /* + * Report encoded elements to the application. + * Dispose of temporary sorted members table. + */ + ret = 0; + for(edx = 0; edx < eels_count; edx++) { + struct _el_buffer *encoded_el = &encoded_els[edx]; + /* Report encoded chunks to the application */ + if(ret == 0 + && cb(encoded_el->buf, encoded_el->length, app_key) < 0) + ret = -1; + FREEMEM(encoded_el->buf); + } + FREEMEM(encoded_els); + + if(ret || computed_size != (size_t)encoding_size) { + /* + * Standard callback failed, or + * encoded size is not equal to the computed size. + */ + erval.encoded = -1; + erval.failed_type = td; + erval.structure_ptr = ptr; + } else { + erval.encoded = computed_size; + } + + _ASN_ENCODED_OK(erval); +} + +#undef XER_ADVANCE +#define XER_ADVANCE(num_bytes) do { \ + size_t num = num_bytes; \ + buf_ptr = ((const char *)buf_ptr) + num;\ + size -= num; \ + consumed_myself += num; \ + } while(0) + +/* + * Decode the XER (XML) data. + */ +asn_dec_rval_t +SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **struct_ptr, const char *opt_mname, + const void *buf_ptr, size_t size) { + /* + * Bring closer parts of structure description. + */ + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *element = td->elements; + const char *elm_tag; + const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; + + /* + * ... and parts of the structure being constructed. + */ + void *st = *struct_ptr; /* Target structure. */ + asn_struct_ctx_t *ctx; /* Decoder context */ + + asn_dec_rval_t rval; /* Return value from a decoder */ + ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ + + /* + * Create the target structure if it is not present already. + */ + if(st == 0) { + st = *struct_ptr = CALLOC(1, specs->struct_size); + if(st == 0) RETURN(RC_FAIL); + } + + /* Which tag is expected for the downstream */ + if(specs->as_XMLValueList) { + elm_tag = (specs->as_XMLValueList == 1) ? 0 : ""; + } else { + elm_tag = (*element->name) + ? element->name : element->type->xml_tag; + } + + /* + * Restore parsing context. + */ + ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); + + /* + * Phases of XER/XML processing: + * Phase 0: Check that the opening tag matches our expectations. + * Phase 1: Processing body and reacting on closing tag. + * Phase 2: Processing inner type. + */ + for(; ctx->phase <= 2;) { + pxer_chunk_type_e ch_type; /* XER chunk type */ + ssize_t ch_size; /* Chunk size */ + xer_check_tag_e tcv; /* Tag check value */ + + /* + * Go inside the inner member of a set. + */ + if(ctx->phase == 2) { + asn_dec_rval_t tmprval; + + /* Invoke the inner type decoder, m.b. multiple times */ + ASN_DEBUG("XER/SET OF element [%s]", elm_tag); + tmprval = element->type->xer_decoder(opt_codec_ctx, + element->type, &ctx->ptr, elm_tag, + buf_ptr, size); + if(tmprval.code == RC_OK) { + asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); + if(ASN_SET_ADD(list, ctx->ptr) != 0) + RETURN(RC_FAIL); + ctx->ptr = 0; + XER_ADVANCE(tmprval.consumed); + } else { + XER_ADVANCE(tmprval.consumed); + RETURN(tmprval.code); + } + ctx->phase = 1; /* Back to body processing */ + ASN_DEBUG("XER/SET OF phase => %d", ctx->phase); + /* Fall through */ + } + + /* + * Get the next part of the XML stream. + */ + ch_size = xer_next_token(&ctx->context, + buf_ptr, size, &ch_type); + switch(ch_size) { + case -1: RETURN(RC_FAIL); + case 0: RETURN(RC_WMORE); + default: + switch(ch_type) { + case PXER_COMMENT: /* Got XML comment */ + case PXER_TEXT: /* Ignore free-standing text */ + XER_ADVANCE(ch_size); /* Skip silently */ + continue; + case PXER_TAG: + break; /* Check the rest down there */ + } + } + + tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); + ASN_DEBUG("XER/SET OF: tcv = %d, ph=%d t=%s", + tcv, ctx->phase, xml_tag); + switch(tcv) { + case XCT_CLOSING: + if(ctx->phase == 0) break; + ctx->phase = 0; + /* Fall through */ + case XCT_BOTH: + if(ctx->phase == 0) { + /* No more things to decode */ + XER_ADVANCE(ch_size); + ctx->phase = 3; /* Phase out */ + RETURN(RC_OK); + } + /* Fall through */ + case XCT_OPENING: + if(ctx->phase == 0) { + XER_ADVANCE(ch_size); + ctx->phase = 1; /* Processing body phase */ + continue; + } + /* Fall through */ + case XCT_UNKNOWN_OP: + case XCT_UNKNOWN_BO: + + ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); + if(ctx->phase == 1) { + /* + * Process a single possible member. + */ + ctx->phase = 2; + continue; + } + /* Fall through */ + default: + break; + } + + ASN_DEBUG("Unexpected XML tag in SET OF"); + break; + } + + ctx->phase = 3; /* "Phase out" on hard failure */ + RETURN(RC_FAIL); +} + + + +typedef struct xer_tmp_enc_s { + void *buffer; + size_t offset; + size_t size; +} xer_tmp_enc_t; +static int +SET_OF_encode_xer_callback(const void *buffer, size_t size, void *key) { + xer_tmp_enc_t *t = (xer_tmp_enc_t *)key; + if(t->offset + size >= t->size) { + size_t newsize = (t->size << 2) + size; + void *p = REALLOC(t->buffer, newsize); + if(!p) return -1; + t->buffer = p; + t->size = newsize; + } + memcpy((char *)t->buffer + t->offset, buffer, size); + t->offset += size; + return 0; +} +static int +SET_OF_xer_order(const void *aptr, const void *bptr) { + const xer_tmp_enc_t *a = (const xer_tmp_enc_t *)aptr; + const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; + size_t minlen = a->offset; + int ret; + if(b->offset < minlen) minlen = b->offset; + /* Well-formed UTF-8 has this nice lexicographical property... */ + ret = memcmp(a->buffer, b->buffer, minlen); + if(ret != 0) return ret; + if(a->offset == b->offset) + return 0; + if(a->offset == minlen) + return -1; + return 1; +} + + +asn_enc_rval_t +SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_enc_rval_t er; + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; + asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr); + const char *mname = specs->as_XMLValueList + ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag); + size_t mlen = mname ? strlen(mname) : 0; + int xcan = (flags & XER_F_CANONICAL); + xer_tmp_enc_t *encs = 0; + size_t encs_count = 0; + void *original_app_key = app_key; + asn_app_consume_bytes_f *original_cb = cb; + int i; + + if(!sptr) _ASN_ENCODE_FAILED; + + if(xcan) { + encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); + if(!encs) _ASN_ENCODE_FAILED; + cb = SET_OF_encode_xer_callback; + } + + er.encoded = 0; + + for(i = 0; i < list->count; i++) { + asn_enc_rval_t tmper; + + void *memb_ptr = list->array[i]; + if(!memb_ptr) continue; + + if(encs) { + memset(&encs[encs_count], 0, sizeof(encs[0])); + app_key = &encs[encs_count]; + encs_count++; + } + + if(mname) { + if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); + _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); + } + + if(!xcan && specs->as_XMLValueList == 1) + _i_ASN_TEXT_INDENT(1, ilevel + 1); + tmper = elm->type->xer_encoder(elm->type, memb_ptr, + ilevel + (specs->as_XMLValueList != 2), + flags, cb, app_key); + if(tmper.encoded == -1) { + td = tmper.failed_type; + sptr = tmper.structure_ptr; + goto cb_failed; + } + if(tmper.encoded == 0 && specs->as_XMLValueList) { + const char *name = elm->type->xml_tag; + size_t len = strlen(name); + _ASN_CALLBACK3("<", 1, name, len, "/>", 2); + } + + if(mname) { + _ASN_CALLBACK3("", 1); + er.encoded += 5; + } + + er.encoded += (2 * mlen) + tmper.encoded; + } + + if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); + + if(encs) { + xer_tmp_enc_t *enc = encs; + xer_tmp_enc_t *end = encs + encs_count; + ssize_t control_size = 0; + + cb = original_cb; + app_key = original_app_key; + qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order); + + for(; enc < end; enc++) { + _ASN_CALLBACK(enc->buffer, enc->offset); + FREEMEM(enc->buffer); + enc->buffer = 0; + control_size += enc->offset; + } + assert(control_size == er.encoded); + } + + goto cleanup; +cb_failed: + er.encoded = -1; + er.failed_type = td; + er.structure_ptr = sptr; +cleanup: + if(encs) { + while(encs_count-- > 0) { + if(encs[encs_count].buffer) + FREEMEM(encs[encs_count].buffer); + } + FREEMEM(encs); + } + _ASN_ENCODED_OK(er); +} + +int +SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, + asn_app_consume_bytes_f *cb, void *app_key) { + asn_TYPE_member_t *elm = td->elements; + const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); + int ret; + int i; + + if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; + + /* Dump preamble */ + if(cb(td->name, strlen(td->name), app_key) < 0 + || cb(" ::= {", 6, app_key) < 0) + return -1; + + for(i = 0; i < list->count; i++) { + const void *memb_ptr = list->array[i]; + if(!memb_ptr) continue; + + _i_INDENT(1); + + ret = elm->type->print_struct(elm->type, memb_ptr, + ilevel + 1, cb, app_key); + if(ret) return ret; + } + + ilevel--; + _i_INDENT(1); + + return (cb("}", 1, app_key) < 0) ? -1 : 0; +} + +void +SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { + if(td && ptr) { + asn_SET_OF_specifics_t *specs; + asn_TYPE_member_t *elm = td->elements; + asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); + asn_struct_ctx_t *ctx; /* Decoder context */ + int i; + + /* + * Could not use set_of_empty() because of (*free) + * incompatibility. + */ + for(i = 0; i < list->count; i++) { + void *memb_ptr = list->array[i]; + if(memb_ptr) + ASN_STRUCT_FREE(*elm->type, memb_ptr); + } + list->count = 0; /* No meaningful elements left */ + + asn_set_empty(list); /* Remove (list->array) */ + + specs = (asn_SET_OF_specifics_t *)td->specifics; + ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset); + if(ctx->ptr) { + ASN_STRUCT_FREE(*elm->type, ctx->ptr); + ctx->ptr = 0; + } + + if(!contents_only) { + FREEMEM(ptr); + } + } +} + +int +SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) { + asn_TYPE_member_t *elm = td->elements; + asn_constr_check_f *constr; + const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); + int i; + + if(!sptr) { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + constr = elm->memb_constraints; + if(!constr) constr = elm->type->check_constraints; + + /* + * Iterate over the members of an array. + * Validate each in turn, until one fails. + */ + for(i = 0; i < list->count; i++) { + const void *memb_ptr = list->array[i]; + int ret; + + if(!memb_ptr) continue; + + ret = constr(elm->type, memb_ptr, ctfailcb, app_key); + if(ret) return ret; + } + + /* + * Cannot inherit it eralier: + * need to make sure we get the updated version. + */ + if(!elm->memb_constraints) + elm->memb_constraints = elm->type->check_constraints; + + return 0; +} + +asn_dec_rval_t +SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + asn_dec_rval_t rv; + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; /* Single one */ + void *st = *sptr; + asn_anonymous_set_ *list; + asn_per_constraint_t *ct; + int repeat = 0; + ssize_t nelems; + + if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + _ASN_DECODE_FAILED; + + /* + * Create the target structure if it is not present already. + */ + if(!st) { + st = *sptr = CALLOC(1, specs->struct_size); + if(!st) _ASN_DECODE_FAILED; + } + list = _A_SET_FROM_VOID(st); + + /* Figure out which constraints to use */ + if(constraints) ct = &constraints->size; + else if(td->per_constraints) ct = &td->per_constraints->size; + else ct = 0; + + if(ct && ct->flags & APC_EXTENSIBLE) { + int value = per_get_few_bits(pd, 1); + if(value < 0) _ASN_DECODE_STARVED; + if(value) ct = 0; /* Not restricted! */ + } + + if(ct && ct->effective_bits >= 0) { + /* X.691, #19.5: No length determinant */ + nelems = per_get_few_bits(pd, ct->effective_bits); + ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", + (long)nelems, ct->lower_bound, td->name); + if(nelems < 0) _ASN_DECODE_STARVED; + nelems += ct->lower_bound; + } else { + nelems = -1; + } + + do { + int i; + if(nelems < 0) { + nelems = uper_get_length(pd, + ct ? ct->effective_bits : -1, &repeat); + ASN_DEBUG("Got to decode %d elements (eff %d)", + (int)nelems, (int)(ct ? ct->effective_bits : -1)); + if(nelems < 0) _ASN_DECODE_STARVED; + } + + for(i = 0; i < nelems; i++) { + void *ptr = 0; + ASN_DEBUG("SET OF %s decoding", elm->type->name); + rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, + elm->per_constraints, &ptr, pd); + ASN_DEBUG("%s SET OF %s decoded %d, %p", + td->name, elm->type->name, rv.code, ptr); + if(rv.code == RC_OK) { + if(ASN_SET_ADD(list, ptr) == 0) + continue; + ASN_DEBUG("Failed to add element into %s", + td->name); + /* Fall through */ + rv.code = RC_FAIL; + } else { + ASN_DEBUG("Failed decoding %s of %s (SET OF)", + elm->type->name, td->name); + } + if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); + return rv; + } + + nelems = -1; /* Allow uper_get_length() */ + } while(repeat); + + ASN_DEBUG("Decoded %s as SET OF", td->name); + + rv.code = RC_OK; + rv.consumed = 0; + return rv; +} + +asn_dec_rval_t +SET_OF_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { + asn_dec_rval_t rv; + asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; + asn_TYPE_member_t *elm = td->elements; /* Single one */ + void *st = *sptr; + asn_anonymous_set_ *list; + asn_per_constraint_t *ct; + int repeat = 0; + ssize_t nelems; + + if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) + _ASN_DECODE_FAILED; + + /* + * Create the target structure if it is not present already. + */ + if(!st) { + st = *sptr = CALLOC(1, specs->struct_size); + if(!st) _ASN_DECODE_FAILED; + } + list = _A_SET_FROM_VOID(st); + + /* Figure out which constraints to use */ + if(constraints) ct = &constraints->size; + else if(td->per_constraints) ct = &td->per_constraints->size; + else ct = 0; + + if(ct && ct->flags & APC_EXTENSIBLE) { + int value = per_get_few_bits(pd, 1); + if(value < 0) _ASN_DECODE_STARVED; + if(value) ct = 0; /* Not restricted! */ + } + + if(ct && ct->effective_bits >= 0) { + /* X.691, #19.5: No length determinant */ +// nelems = per_get_few_bits(pd, ct->effective_bits); + nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound); + ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", + (long)nelems, ct->lower_bound, td->name); + if(nelems < 0) _ASN_DECODE_STARVED; + nelems += ct->lower_bound; + } else { + nelems = -1; + } + + do { + int i; + if(nelems < 0) { + nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1, + ct ? ct->effective_bits : -1, &repeat); + ASN_DEBUG("Got to decode %d elements (eff %d)", + (int)nelems, ct ? ct->effective_bits : -1); + if(nelems < 0) _ASN_DECODE_STARVED; + } + + for(i = 0; i < nelems; i++) { + void *ptr = 0; + ASN_DEBUG("SET OF %s decoding", elm->type->name); + rv = elm->type->aper_decoder(opt_codec_ctx, elm->type, + elm->per_constraints, &ptr, pd); + ASN_DEBUG("%s SET OF %s decoded %d, %p", + td->name, elm->type->name, rv.code, ptr); + if(rv.code == RC_OK) { + if(ASN_SET_ADD(list, ptr) == 0) + continue; + ASN_DEBUG("Failed to add element into %s", + td->name); + /* Fall through */ + rv.code = RC_FAIL; + } else { + ASN_DEBUG("Failed decoding %s of %s (SET OF)", + elm->type->name, td->name); + } + if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); + return rv; + } + + nelems = -1; /* Allow uper_get_length() */ + } while(repeat); + + ASN_DEBUG("Decoded %s as SET OF", td->name); + + rv.code = RC_OK; + rv.consumed = 0; + return rv; +} From 9108ecbdf6f01e0bd5b6115f2d7a951fb981b79d Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 22 Feb 2016 11:40:26 +0100 Subject: [PATCH 02/21] Use diff files and 'patch' instead of copying full files. --- cmake_targets/tools/fix_asn1 | 46 +- .../RRC.rel10/SystemInformation-r8-IEs.h | 109 -- .../RRC.rel10/SystemInformation-r8-IEs.h.diff | 23 + .../S1AP.rel10.5/NativeInteger.c | 412 ------- .../S1AP.rel10.5/NativeInteger.c.diff | 8 + .../S1AP.rel10.5/constr_SET_OF.c | 1041 ----------------- .../S1AP.rel10.5/constr_SET_OF.c.diff | 4 + .../X2AP.rel11.2/NativeInteger.c | 412 ------- .../X2AP.rel11.2/NativeInteger.c.diff | 8 + .../X2ap-CriticalityDiagnostics-IE-List.h | 63 - ...X2ap-CriticalityDiagnostics-IE-List.h.diff | 15 + .../X2AP.rel11.2/constr_SET_OF.c | 1041 ----------------- .../X2AP.rel11.2/constr_SET_OF.c.diff | 4 + 13 files changed, 85 insertions(+), 3101 deletions(-) delete mode 100644 cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h create mode 100644 cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff delete mode 100644 cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c create mode 100644 cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff delete mode 100644 cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c create mode 100644 cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff delete mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c create mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff delete mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h create mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff delete mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c create mode 100644 cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 index f222374fae..ba8f15d8ec 100755 --- a/cmake_targets/tools/fix_asn1 +++ b/cmake_targets/tools/fix_asn1 @@ -1,26 +1,26 @@ #!/bin/bash # in those arrays, each line is: -# +# RRC_Rel10=( - "SystemInformation-r8-IEs.h" 819eda3db27516f7c6780d832fb3c462e2264ea7 "fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h" + "SystemInformation-r8-IEs.h" 819eda3db27516f7c6780d832fb3c462e2264ea7 "fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff" ) X2AP_Rel11_2=( - "X2ap-CriticalityDiagnostics-IE-List.h" f0e2414992bfacfbc4b9fd15c977241d6d7fabeb "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h" - "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/X2AP.rel11.2/NativeInteger.c" - "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c" + "X2ap-CriticalityDiagnostics-IE-List.h" f0e2414992bfacfbc4b9fd15c977241d6d7fabeb "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff" + "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" + "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" ) S1AP_Rel10_5=( - "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/S1AP.rel10.5/NativeInteger.c" - "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c" + "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" + "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" ) -red_color="\x1b[31m" -green_color="\x1b[32m" -reset_color="\x1b[0m" +red_color="$(tput setaf 1)" +green_color="$(tput setaf 2)" +reset_color="$(tput sgr0)" function error() { @@ -46,21 +46,21 @@ function check_sha1() fi } -function copy_file() +function patch_file() { - local file="$1" - local destination="$2" + local patch="$1" + local file="$2" - echo -e "$green_color""copy file $OPENAIR_DIR/cmake_targets/tools/$file to $destination""$reset_color" + echo -e "$green_color""patch file $file with $OPENAIR_DIR/cmake_targets/tools/$patch""$reset_color" - cp -f "$OPENAIR_DIR/cmake_targets/tools/$file" "$destination" + patch "$file" "$OPENAIR_DIR/cmake_targets/tools/$patch" if [ $? -ne 0 ] then - error "copy of $file to $destination failed" + error "patching of $file with $OPENAIR_DIR/cmake_targets/tools/$patch failed" fi } -function patch() +function apply_patches() { local directory="$1" local array=$2 @@ -69,7 +69,7 @@ function patch() local i local file local sha1 - local replace + local patch local item for (( i = 0; i < $len; i += 3 )) @@ -77,9 +77,9 @@ function patch() # special bash syntax to access the array item=$array[$i]; file=${!item} item=$array[$((i+1))]; sha1=${!item} - item=$array[$((i+2))]; replace=${!item} + item=$array[$((i+2))]; patch=${!item} check_sha1 "$directory/$file" "$sha1" - copy_file "$replace" "$directory" + patch_file "$patch" "$directory/$file" done } @@ -91,7 +91,7 @@ function patch_rrc() case "$version" in Rel10 ) echo "patching RRC files release 10" - patch "$directory" RRC_Rel10 ${#RRC_Rel10[*]} + apply_patches "$directory" RRC_Rel10 ${#RRC_Rel10[*]} ;; * ) error unknwon/unhandled RRC version \'"$version"\' @@ -107,7 +107,7 @@ function patch_x2ap() case "$version" in R11 ) echo "patching X2AP files release 11.2" - patch "$directory" X2AP_Rel11_2 ${#X2AP_Rel11_2[*]} + apply_patches "$directory" X2AP_Rel11_2 ${#X2AP_Rel11_2[*]} ;; * ) error unknwon/unhandled X2AP version \'"$version"\' @@ -123,7 +123,7 @@ function patch_s1ap() case "$version" in R10 ) echo "patching S1AP files release 10.5" - patch "$directory" S1AP_Rel10_5 ${#S1AP_Rel10_5[*]} + apply_patches "$directory" S1AP_Rel10_5 ${#S1AP_Rel10_5[*]} ;; * ) error unknwon/unhandled S1AP version \'"$version"\' diff --git a/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h b/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h deleted file mode 100644 index baa09c12ef..0000000000 --- a/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Generated by asn1c-0.9.24 (http://lionet.info/asn1c) - * From ASN.1 module "EUTRA-RRC-Definitions" - * found in "fixed_grammar.asn" - * `asn1c -gen-PER` - */ - -#ifndef _SystemInformation_r8_IEs_H_ -#define _SystemInformation_r8_IEs_H_ - - -#include - -/* Including external dependencies */ -#include -#include "SystemInformationBlockType2.h" -#include "SystemInformationBlockType3.h" -#include "SystemInformationBlockType4.h" -#include "SystemInformationBlockType5.h" -#include "SystemInformationBlockType6.h" -#include "SystemInformationBlockType7.h" -#include "SystemInformationBlockType8.h" -#include "SystemInformationBlockType9.h" -#include "SystemInformationBlockType10.h" -#include "SystemInformationBlockType11.h" -#include "SystemInformationBlockType12-r9.h" -#include "SystemInformationBlockType13-r9.h" -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Dependencies */ -typedef enum SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR { - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_NOTHING, /* No components present */ - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11, - /* Extensions may appear below */ - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920, - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920 -} SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR; - -/* Forward declarations */ -struct SystemInformation_v8a0_IEs; - - union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u { - SystemInformationBlockType2_t sib2; - SystemInformationBlockType3_t sib3; - SystemInformationBlockType4_t sib4; - SystemInformationBlockType5_t sib5; - SystemInformationBlockType6_t sib6; - SystemInformationBlockType7_t sib7; - SystemInformationBlockType8_t sib8; - SystemInformationBlockType9_t sib9; - SystemInformationBlockType10_t sib10; - SystemInformationBlockType11_t sib11; - /* - * This type is extensible, - * possible extensions are below. - */ - SystemInformationBlockType12_r9_t sib12_v920; - SystemInformationBlockType13_r9_t sib13_v920; - }; - - struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member { - SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present; - union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u choice; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - }; - -/* SystemInformation-r8-IEs */ -typedef struct SystemInformation_r8_IEs { - struct SystemInformation_r8_IEs__sib_TypeAndInfo { - A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member) list; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - } sib_TypeAndInfo; - struct SystemInformation_v8a0_IEs *nonCriticalExtension /* OPTIONAL */; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; -} SystemInformation_r8_IEs_t; - -/* Implementation */ -extern asn_TYPE_descriptor_t asn_DEF_SystemInformation_r8_IEs; - -#ifdef __cplusplus -} -#endif - -/* Referred external types */ -#include "SystemInformation-v8a0-IEs.h" - -#endif /* _SystemInformation_r8_IEs_H_ */ -#include diff --git a/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff b/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff new file mode 100644 index 0000000000..525e35ac9e --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff @@ -0,0 +1,23 @@ +57,61d56 +< /* SystemInformation-r8-IEs */ +< typedef struct SystemInformation_r8_IEs { +< struct SystemInformation_r8_IEs__sib_TypeAndInfo { +< A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member { +< SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present; +79c74,78 +< } choice; +--- +> }; +> +> struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member { +> SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present; +> union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u choice; +83c82,87 +< } ) list; +--- +> }; +> +> /* SystemInformation-r8-IEs */ +> typedef struct SystemInformation_r8_IEs { +> struct SystemInformation_r8_IEs__sib_TypeAndInfo { +> A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member) list; diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c deleted file mode 100644 index 239dbdc10f..0000000000 --- a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c +++ /dev/null @@ -1,412 +0,0 @@ -/*- - * Copyright (c) 2004, 2005, 2006 Lev Walkin . - * All rights reserved. - * Redistribution and modifications are permitted subject to BSD license. - */ -/* - * Read the NativeInteger.h for the explanation wrt. differences between - * INTEGER and NativeInteger. - * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this - * implementation deals with the standard (machine-specific) representation - * of them instead of using the platform-independent buffer. - */ -#include -#include - -/* - * NativeInteger basic type description. - */ -static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) -}; -asn_TYPE_descriptor_t asn_DEF_NativeInteger = { - "INTEGER", /* The ASN.1 type is still INTEGER */ - "INTEGER", - NativeInteger_free, - NativeInteger_print, - asn_generic_no_constraint, - NativeInteger_decode_ber, - NativeInteger_encode_der, - NativeInteger_decode_xer, - NativeInteger_encode_xer, - NativeInteger_decode_uper, /* Unaligned PER decoder */ - NativeInteger_encode_uper, /* Unaligned PER encoder */ - NativeInteger_decode_aper, /* Aligned PER decoder */ - NativeInteger_encode_aper, /* Aligned PER encoder */ - 0, /* Use generic outmost tag fetcher */ - asn_DEF_NativeInteger_tags, - sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), - asn_DEF_NativeInteger_tags, /* Same as above */ - sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), - 0, /* No PER visible constraints */ - 0, 0, /* No members */ - 0 /* No specifics */ -}; - -/* - * Decode INTEGER type. - */ -asn_dec_rval_t -NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, - void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - long *native = (long *)*nint_ptr; - asn_dec_rval_t rval; - ber_tlv_len_t length; - - /* - * If the structure is not there, allocate it. - */ - if(native == NULL) { - native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native))); - if(native == NULL) { - rval.code = RC_FAIL; - rval.consumed = 0; - return rval; - } - } - - ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", - td->name, tag_mode); - - /* - * Check tags. - */ - rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, - tag_mode, 0, &length, 0); - if(rval.code != RC_OK) - return rval; - - ASN_DEBUG("%s length is %d bytes", td->name, (int)length); - - /* - * Make sure we have this length. - */ - buf_ptr = ((const char *)buf_ptr) + rval.consumed; - size -= rval.consumed; - if(length > (ber_tlv_len_t)size) { - rval.code = RC_WMORE; - rval.consumed = 0; - return rval; - } - - /* - * ASN.1 encoded INTEGER: buf_ptr, length - * Fill the native, at the same time checking for overflow. - * If overflow occured, return with RC_FAIL. - */ - { - INTEGER_t tmp; - union { - const void *constbuf; - void *nonconstbuf; - } unconst_buf; - long l; - - unconst_buf.constbuf = buf_ptr; - tmp.buf = (uint8_t *)unconst_buf.nonconstbuf; - tmp.size = length; - - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&tmp, (unsigned long *)&l) /* sic */ - : asn_INTEGER2long(&tmp, &l)) { - rval.code = RC_FAIL; - rval.consumed = 0; - return rval; - } - - *native = l; - } - - rval.code = RC_OK; - rval.consumed += length; - - ASN_DEBUG("Took %ld/%ld bytes to encode %s (%ld)", - (long)rval.consumed, (long)length, td->name, (long)*native); - - return rval; -} - -/* - * Encode the NativeInteger using the standard INTEGER type DER encoder. - */ -asn_enc_rval_t -NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, - int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - unsigned long native = *(unsigned long *)ptr; /* Disable sign ext. */ - asn_enc_rval_t erval; - INTEGER_t tmp; - -#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */ - - tmp.buf = (uint8_t *)&native; - tmp.size = sizeof(native); - -#else /* Works even if WORDS_BIGENDIAN is not set where should've been */ - uint8_t buf[sizeof(native)]; - uint8_t *p; - - /* Prepare a fake INTEGER */ - for(p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) - *p = (uint8_t)native; - - tmp.buf = buf; - tmp.size = sizeof(buf); -#endif /* WORDS_BIGENDIAN */ - - /* Encode fake INTEGER */ - erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key); - if(erval.encoded == -1) { - assert(erval.structure_ptr == &tmp); - erval.structure_ptr = ptr; - } - return erval; -} - -/* - * Decode the chunk of XML text encoding INTEGER. - */ -asn_dec_rval_t -NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, - const void *buf_ptr, size_t size) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_dec_rval_t rval; - INTEGER_t st; - void *st_ptr = (void *)&st; - long *native = (long *)*sptr; - - if(!native) { - native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if(!native) _ASN_DECODE_FAILED; - } - - memset(&st, 0, sizeof(st)); - rval = INTEGER_decode_xer(opt_codec_ctx, td, &st_ptr, - opt_mname, buf_ptr, size); - if(rval.code == RC_OK) { - long l; - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&st, (unsigned long *)&l) /* sic */ - : asn_INTEGER2long(&st, &l)) { - rval.code = RC_FAIL; - rval.consumed = 0; - } else { - *native = l; - } - } else { - /* - * Cannot restart from the middle; - * there is no place to save state in the native type. - * Request a continuation from the very beginning. - */ - rval.consumed = 0; - } - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st); - return rval; -} - - -asn_enc_rval_t -NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - char scratch[32]; /* Enough for 64-bit int */ - asn_enc_rval_t er; - const long *native = (const long *)sptr; - - (void)ilevel; - (void)flags; - - if(!native) _ASN_ENCODE_FAILED; - - er.encoded = snprintf(scratch, sizeof(scratch), - (specs && specs->field_unsigned) - ? "%lu" : "%ld", *native); - if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) - || cb(scratch, er.encoded, app_key) < 0) - _ASN_ENCODE_FAILED; - - _ASN_ENCODED_OK(er); -} - -asn_dec_rval_t -NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_dec_rval_t rval; - long *native = (long *)*sptr; - INTEGER_t tmpint; - void *tmpintptr = &tmpint; - - (void)opt_codec_ctx; - ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name); - - if(!native) { - native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if(!native) _ASN_DECODE_FAILED; - } - - memset(&tmpint, 0, sizeof tmpint); - rval = INTEGER_decode_uper(opt_codec_ctx, td, constraints, - &tmpintptr, pd); - if(rval.code == RC_OK) { - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) - : asn_INTEGER2long(&tmpint, native)) - rval.code = RC_FAIL; - else - ASN_DEBUG("NativeInteger %s got value %ld", - td->name, *native); - } - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - - return rval; -} - -asn_dec_rval_t -NativeInteger_decode_aper(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_dec_rval_t rval; - long *native = (long *)*sptr; - INTEGER_t tmpint; - void *tmpintptr = &tmpint; - //int dynamic = 0; - - (void)opt_codec_ctx; - ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name); - - if(!native) { - native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - //dynamic = 1; - if(!native) _ASN_DECODE_FAILED; - } - - memset(&tmpint, 0, sizeof tmpint); - rval = INTEGER_decode_aper(opt_codec_ctx, td, constraints, - &tmpintptr, pd); - if(rval.code == RC_OK) { - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) - : asn_INTEGER2long(&tmpint, native)) - rval.code = RC_FAIL; - else - ASN_DEBUG("NativeInteger %s got value %ld", - td->name, *native); - } - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - //if (dynamic) - // free(native); - - return rval; -} - -asn_enc_rval_t -NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_enc_rval_t er; - long native; - INTEGER_t tmpint; - - if(!sptr) _ASN_ENCODE_FAILED; - - native = *(long *)sptr; - - ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native); - - memset(&tmpint, 0, sizeof(tmpint)); - if((specs&&specs->field_unsigned) - ? asn_ulong2INTEGER(&tmpint, native) - : asn_long2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; - er = INTEGER_encode_uper(td, constraints, &tmpint, po); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - return er; -} - -asn_enc_rval_t -NativeInteger_encode_aper( - asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_enc_rval_t er; - INTEGER_t tmpint; - - if(!sptr) _ASN_ENCODE_FAILED; - memset(&tmpint, 0, sizeof(tmpint)); - - if(specs&&specs->field_unsigned) { - unsigned long native; - native = *(unsigned long *)sptr; - - ASN_DEBUG("Encoding NativeInteger %s %lu (APER) (unsigned)", td->name, native); - - if(asn_ulong2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; - } else { - long native; - native = *(long *)sptr; - - ASN_DEBUG("Encoding NativeInteger %s %ld (APER) (unsigned)", td->name, native); - if(asn_long2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; - } - -// if((specs&&specs->field_unsigned) -// ? asn_ulong2INTEGER(&tmpint, native) -// : asn_long2INTEGER(&tmpint, native)) -// _ASN_ENCODE_FAILED; - er = INTEGER_encode_aper(td, constraints, &tmpint, po); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - return er; -} - -/* - * INTEGER specific human-readable output. - */ -int -NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - const long *native = (const long *)sptr; - char scratch[32]; /* Enough for 64-bit int */ - int ret; - - (void)td; /* Unused argument */ - (void)ilevel; /* Unused argument */ - - if(native) { - ret = snprintf(scratch, sizeof(scratch), - (specs && specs->field_unsigned) - ? "%lu" : "%ld", *native); - assert(ret > 0 && (size_t)ret < sizeof(scratch)); - return (cb(scratch, ret, app_key) < 0) ? -1 : 0; - } else { - return (cb("", 8, app_key) < 0) ? -1 : 0; - } -} - -void -NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - - if(!td || !ptr) - return; - - ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", - td->name, contents_only, ptr); - - if(!contents_only) { - FREEMEM(ptr); - } -} - diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff new file mode 100644 index 0000000000..c1649fd6f7 --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff @@ -0,0 +1,8 @@ +282c282 +< int dynamic = 0; +--- +> //int dynamic = 0; +289c289 +< dynamic = 1; +--- +> //dynamic = 1; diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c deleted file mode 100644 index 3e2d23b254..0000000000 --- a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c +++ /dev/null @@ -1,1041 +0,0 @@ -/*- - * Copyright (c) 2003, 2004, 2005 Lev Walkin . - * All rights reserved. - * Redistribution and modifications are permitted subject to BSD license. - */ -#include -#include -#include - -/* - * Number of bytes left for this structure. - * (ctx->left) indicates the number of bytes _transferred_ for the structure. - * (size) contains the number of bytes in the buffer passed. - */ -#define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) - -/* - * If the subprocessor function returns with an indication that it wants - * more data, it may well be a fatal decoding problem, because the - * size is constrained by the 's L, even if the buffer size allows - * reading more data. - * For example, consider the buffer containing the following TLVs: - * ... - * The TLV length clearly indicates that one byte is expected in V, but - * if the V processor returns with "want more data" even if the buffer - * contains way more data than the V processor have seen. - */ -#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) - -/* - * This macro "eats" the part of the buffer which is definitely "consumed", - * i.e. was correctly converted into local representation or rightfully skipped. - */ -#undef ADVANCE -#define ADVANCE(num_bytes) do { \ - size_t num = num_bytes; \ - ptr = ((const char *)ptr) + num;\ - size -= num; \ - if(ctx->left >= 0) \ - ctx->left -= num; \ - consumed_myself += num; \ - } while(0) - -/* - * Switch to the next phase of parsing. - */ -#undef NEXT_PHASE -#undef PHASE_OUT -#define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ - } while(0) -#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) - -/* - * Return a standardized complex structure. - */ -#undef RETURN -#define RETURN(_code) do { \ - rval.code = _code; \ - rval.consumed = consumed_myself;\ - return rval; \ - } while(0) - -/* - * The decoder of the SET OF type. - */ -asn_dec_rval_t -SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **struct_ptr, const void *ptr, size_t size, int tag_mode) { - /* - * Bring closer parts of structure description. - */ - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; /* Single one */ - - /* - * Parts of the structure being constructed. - */ - void *st = *struct_ptr; /* Target structure. */ - asn_struct_ctx_t *ctx; /* Decoder context */ - - ber_tlv_tag_t tlv_tag; /* T from TLV */ - asn_dec_rval_t rval; /* Return code from subparsers */ - - ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ - - ASN_DEBUG("Decoding %s as SET OF", td->name); - - /* - * Create the target structure if it is not present already. - */ - if(st == 0) { - st = *struct_ptr = CALLOC(1, specs->struct_size); - if(st == 0) { - RETURN(RC_FAIL); - } - } - - /* - * Restore parsing context. - */ - ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); - - /* - * Start to parse where left previously - */ - switch(ctx->phase) { - case 0: - /* - * PHASE 0. - * Check that the set of tags associated with given structure - * perfectly fits our expectations. - */ - - rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, - tag_mode, 1, &ctx->left, 0); - if(rval.code != RC_OK) { - ASN_DEBUG("%s tagging check failed: %d", - td->name, rval.code); - return rval; - } - - if(ctx->left >= 0) - ctx->left += rval.consumed; /* ?Substracted below! */ - ADVANCE(rval.consumed); - - ASN_DEBUG("Structure consumes %ld bytes, " - "buffer %ld", (long)ctx->left, (long)size); - - NEXT_PHASE(ctx); - /* Fall through */ - case 1: - /* - * PHASE 1. - * From the place where we've left it previously, - * try to decode the next item. - */ - for(;; ctx->step = 0) { - ssize_t tag_len; /* Length of TLV's T */ - - if(ctx->step & 1) - goto microphase2; - - /* - * MICROPHASE 1: Synchronize decoding. - */ - - if(ctx->left == 0) { - ASN_DEBUG("End of SET OF %s", td->name); - /* - * No more things to decode. - * Exit out of here. - */ - PHASE_OUT(ctx); - RETURN(RC_OK); - } - - /* - * Fetch the T from TLV. - */ - tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); - switch(tag_len) { - case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); - /* Fall through */ - case -1: RETURN(RC_FAIL); - } - - if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { - if(LEFT < 2) { - if(SIZE_VIOLATION) - RETURN(RC_FAIL); - else - RETURN(RC_WMORE); - } else if(((const uint8_t *)ptr)[1] == 0) { - /* - * Found the terminator of the - * indefinite length structure. - */ - break; - } - } - - /* Outmost tag may be unknown and cannot be fetched/compared */ - if(elm->tag != (ber_tlv_tag_t)-1) { - if(BER_TAGS_EQUAL(tlv_tag, elm->tag)) { - /* - * The new list member of expected type has arrived. - */ - } else { - ASN_DEBUG("Unexpected tag %s fixed SET OF %s", - ber_tlv_tag_string(tlv_tag), td->name); - ASN_DEBUG("%s SET OF has tag %s", - td->name, ber_tlv_tag_string(elm->tag)); - RETURN(RC_FAIL); - } - } - - /* - * MICROPHASE 2: Invoke the member-specific decoder. - */ - ctx->step |= 1; /* Confirm entering next microphase */ - microphase2: - - /* - * Invoke the member fetch routine according to member's type - */ - rval = elm->type->ber_decoder(opt_codec_ctx, - elm->type, &ctx->ptr, ptr, LEFT, 0); - ASN_DEBUG("In %s SET OF %s code %d consumed %d", - td->name, elm->type->name, - rval.code, (int)rval.consumed); - switch(rval.code) { - case RC_OK: - { - asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); - if(ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); - else - ctx->ptr = 0; - } - break; - case RC_WMORE: /* More data expected */ - if(!SIZE_VIOLATION) { - ADVANCE(rval.consumed); - RETURN(RC_WMORE); - } - /* Fall through */ - case RC_FAIL: /* Fatal error */ - ASN_STRUCT_FREE(*elm->type, ctx->ptr); - ctx->ptr = 0; - RETURN(RC_FAIL); - } /* switch(rval) */ - - ADVANCE(rval.consumed); - } /* for(all list members) */ - - NEXT_PHASE(ctx); - case 2: - /* - * Read in all "end of content" TLVs. - */ - while(ctx->left < 0) { - if(LEFT < 2) { - if(LEFT > 0 && ((const char *)ptr)[0] != 0) { - /* Unexpected tag */ - RETURN(RC_FAIL); - } else { - RETURN(RC_WMORE); - } - } - if(((const char *)ptr)[0] == 0 - && ((const char *)ptr)[1] == 0) { - ADVANCE(2); - ctx->left++; - } else { - RETURN(RC_FAIL); - } - } - - PHASE_OUT(ctx); - } - - RETURN(RC_OK); -} - -/* - * Internally visible buffer holding a single encoded element. - */ -struct _el_buffer { - uint8_t *buf; - size_t length; - size_t size; -}; -/* Append bytes to the above structure */ -static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { - struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; - - if(el_buf->length + size > el_buf->size) - return -1; - - memcpy(el_buf->buf + el_buf->length, buffer, size); - - el_buf->length += size; - return 0; -} -static int _el_buf_cmp(const void *ap, const void *bp) { - const struct _el_buffer *a = (const struct _el_buffer *)ap; - const struct _el_buffer *b = (const struct _el_buffer *)bp; - int ret; - size_t common_len; - - if(a->length < b->length) - common_len = a->length; - else - common_len = b->length; - - ret = memcmp(a->buf, b->buf, common_len); - if(ret == 0) { - if(a->length < b->length) - ret = -1; - else if(a->length > b->length) - ret = 1; - } - - return ret; -} - -/* - * The DER encoder of the SET OF type. - */ -asn_enc_rval_t -SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, - int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_TYPE_member_t *elm = td->elements; - asn_TYPE_descriptor_t *elm_type = elm->type; - der_type_encoder_f *der_encoder = elm_type->der_encoder; - asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); - size_t computed_size = 0; - ssize_t encoding_size = 0; - struct _el_buffer *encoded_els; - ssize_t eels_count = 0; - size_t max_encoded_len = 1; - asn_enc_rval_t erval; - int ret; - int edx; - - ASN_DEBUG("Estimating size for SET OF %s", td->name); - - /* - * Gather the length of the underlying members sequence. - */ - for(edx = 0; edx < list->count; edx++) { - void *memb_ptr = list->array[edx]; - if(!memb_ptr) continue; - erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); - if(erval.encoded == -1) - return erval; - computed_size += erval.encoded; - - /* Compute maximum encoding's size */ - if(max_encoded_len < (size_t)erval.encoded) - max_encoded_len = erval.encoded; - } - - /* - * Encode the TLV for the sequence itself. - */ - encoding_size = der_write_tags(td, computed_size, tag_mode, 1, tag, - cb, app_key); - if(encoding_size == -1) { - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - return erval; - } - computed_size += encoding_size; - - if(!cb || list->count == 0) { - erval.encoded = computed_size; - _ASN_ENCODED_OK(erval); - } - - /* - * DER mandates dynamic sorting of the SET OF elements - * according to their encodings. Build an array of the - * encoded elements. - */ - encoded_els = (struct _el_buffer *)MALLOC( - list->count * sizeof(encoded_els[0])); - if(encoded_els == NULL) { - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - return erval; - } - - ASN_DEBUG("Encoding members of %s SET OF", td->name); - - /* - * Encode all members. - */ - for(edx = 0; edx < list->count; edx++) { - void *memb_ptr = list->array[edx]; - struct _el_buffer *encoded_el = &encoded_els[eels_count]; - - if(!memb_ptr) continue; - - /* - * Prepare space for encoding. - */ - encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len); - if(encoded_el->buf) { - encoded_el->length = 0; - encoded_el->size = max_encoded_len; - } else { - for(edx--; edx >= 0; edx--) - FREEMEM(encoded_els[edx].buf); - FREEMEM(encoded_els); - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - return erval; - } - - /* - * Encode the member into the prepared space. - */ - erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, - _el_addbytes, encoded_el); - if(erval.encoded == -1) { - for(; edx >= 0; edx--) - FREEMEM(encoded_els[edx].buf); - FREEMEM(encoded_els); - return erval; - } - encoding_size += erval.encoded; - eels_count++; - } - - /* - * Sort the encoded elements according to their encoding. - */ - qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); - - /* - * Report encoded elements to the application. - * Dispose of temporary sorted members table. - */ - ret = 0; - for(edx = 0; edx < eels_count; edx++) { - struct _el_buffer *encoded_el = &encoded_els[edx]; - /* Report encoded chunks to the application */ - if(ret == 0 - && cb(encoded_el->buf, encoded_el->length, app_key) < 0) - ret = -1; - FREEMEM(encoded_el->buf); - } - FREEMEM(encoded_els); - - if(ret || computed_size != (size_t)encoding_size) { - /* - * Standard callback failed, or - * encoded size is not equal to the computed size. - */ - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - } else { - erval.encoded = computed_size; - } - - _ASN_ENCODED_OK(erval); -} - -#undef XER_ADVANCE -#define XER_ADVANCE(num_bytes) do { \ - size_t num = num_bytes; \ - buf_ptr = ((const char *)buf_ptr) + num;\ - size -= num; \ - consumed_myself += num; \ - } while(0) - -/* - * Decode the XER (XML) data. - */ -asn_dec_rval_t -SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **struct_ptr, const char *opt_mname, - const void *buf_ptr, size_t size) { - /* - * Bring closer parts of structure description. - */ - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *element = td->elements; - const char *elm_tag; - const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; - - /* - * ... and parts of the structure being constructed. - */ - void *st = *struct_ptr; /* Target structure. */ - asn_struct_ctx_t *ctx; /* Decoder context */ - - asn_dec_rval_t rval; /* Return value from a decoder */ - ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ - - /* - * Create the target structure if it is not present already. - */ - if(st == 0) { - st = *struct_ptr = CALLOC(1, specs->struct_size); - if(st == 0) RETURN(RC_FAIL); - } - - /* Which tag is expected for the downstream */ - if(specs->as_XMLValueList) { - elm_tag = (specs->as_XMLValueList == 1) ? 0 : ""; - } else { - elm_tag = (*element->name) - ? element->name : element->type->xml_tag; - } - - /* - * Restore parsing context. - */ - ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); - - /* - * Phases of XER/XML processing: - * Phase 0: Check that the opening tag matches our expectations. - * Phase 1: Processing body and reacting on closing tag. - * Phase 2: Processing inner type. - */ - for(; ctx->phase <= 2;) { - pxer_chunk_type_e ch_type; /* XER chunk type */ - ssize_t ch_size; /* Chunk size */ - xer_check_tag_e tcv; /* Tag check value */ - - /* - * Go inside the inner member of a set. - */ - if(ctx->phase == 2) { - asn_dec_rval_t tmprval; - - /* Invoke the inner type decoder, m.b. multiple times */ - ASN_DEBUG("XER/SET OF element [%s]", elm_tag); - tmprval = element->type->xer_decoder(opt_codec_ctx, - element->type, &ctx->ptr, elm_tag, - buf_ptr, size); - if(tmprval.code == RC_OK) { - asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); - if(ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); - ctx->ptr = 0; - XER_ADVANCE(tmprval.consumed); - } else { - XER_ADVANCE(tmprval.consumed); - RETURN(tmprval.code); - } - ctx->phase = 1; /* Back to body processing */ - ASN_DEBUG("XER/SET OF phase => %d", ctx->phase); - /* Fall through */ - } - - /* - * Get the next part of the XML stream. - */ - ch_size = xer_next_token(&ctx->context, - buf_ptr, size, &ch_type); - switch(ch_size) { - case -1: RETURN(RC_FAIL); - case 0: RETURN(RC_WMORE); - default: - switch(ch_type) { - case PXER_COMMENT: /* Got XML comment */ - case PXER_TEXT: /* Ignore free-standing text */ - XER_ADVANCE(ch_size); /* Skip silently */ - continue; - case PXER_TAG: - break; /* Check the rest down there */ - } - } - - tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); - ASN_DEBUG("XER/SET OF: tcv = %d, ph=%d t=%s", - tcv, ctx->phase, xml_tag); - switch(tcv) { - case XCT_CLOSING: - if(ctx->phase == 0) break; - ctx->phase = 0; - /* Fall through */ - case XCT_BOTH: - if(ctx->phase == 0) { - /* No more things to decode */ - XER_ADVANCE(ch_size); - ctx->phase = 3; /* Phase out */ - RETURN(RC_OK); - } - /* Fall through */ - case XCT_OPENING: - if(ctx->phase == 0) { - XER_ADVANCE(ch_size); - ctx->phase = 1; /* Processing body phase */ - continue; - } - /* Fall through */ - case XCT_UNKNOWN_OP: - case XCT_UNKNOWN_BO: - - ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); - if(ctx->phase == 1) { - /* - * Process a single possible member. - */ - ctx->phase = 2; - continue; - } - /* Fall through */ - default: - break; - } - - ASN_DEBUG("Unexpected XML tag in SET OF"); - break; - } - - ctx->phase = 3; /* "Phase out" on hard failure */ - RETURN(RC_FAIL); -} - - - -typedef struct xer_tmp_enc_s { - void *buffer; - size_t offset; - size_t size; -} xer_tmp_enc_t; -static int -SET_OF_encode_xer_callback(const void *buffer, size_t size, void *key) { - xer_tmp_enc_t *t = (xer_tmp_enc_t *)key; - if(t->offset + size >= t->size) { - size_t newsize = (t->size << 2) + size; - void *p = REALLOC(t->buffer, newsize); - if(!p) return -1; - t->buffer = p; - t->size = newsize; - } - memcpy((char *)t->buffer + t->offset, buffer, size); - t->offset += size; - return 0; -} -static int -SET_OF_xer_order(const void *aptr, const void *bptr) { - const xer_tmp_enc_t *a = (const xer_tmp_enc_t *)aptr; - const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; - size_t minlen = a->offset; - int ret; - if(b->offset < minlen) minlen = b->offset; - /* Well-formed UTF-8 has this nice lexicographical property... */ - ret = memcmp(a->buffer, b->buffer, minlen); - if(ret != 0) return ret; - if(a->offset == b->offset) - return 0; - if(a->offset == minlen) - return -1; - return 1; -} - - -asn_enc_rval_t -SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_enc_rval_t er; - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; - asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr); - const char *mname = specs->as_XMLValueList - ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag); - size_t mlen = mname ? strlen(mname) : 0; - int xcan = (flags & XER_F_CANONICAL); - xer_tmp_enc_t *encs = 0; - size_t encs_count = 0; - void *original_app_key = app_key; - asn_app_consume_bytes_f *original_cb = cb; - int i; - - if(!sptr) _ASN_ENCODE_FAILED; - - if(xcan) { - encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); - if(!encs) _ASN_ENCODE_FAILED; - cb = SET_OF_encode_xer_callback; - } - - er.encoded = 0; - - for(i = 0; i < list->count; i++) { - asn_enc_rval_t tmper; - - void *memb_ptr = list->array[i]; - if(!memb_ptr) continue; - - if(encs) { - memset(&encs[encs_count], 0, sizeof(encs[0])); - app_key = &encs[encs_count]; - encs_count++; - } - - if(mname) { - if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); - _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); - } - - if(!xcan && specs->as_XMLValueList == 1) - _i_ASN_TEXT_INDENT(1, ilevel + 1); - tmper = elm->type->xer_encoder(elm->type, memb_ptr, - ilevel + (specs->as_XMLValueList != 2), - flags, cb, app_key); - if(tmper.encoded == -1) { - td = tmper.failed_type; - sptr = tmper.structure_ptr; - goto cb_failed; - } - if(tmper.encoded == 0 && specs->as_XMLValueList) { - const char *name = elm->type->xml_tag; - size_t len = strlen(name); - _ASN_CALLBACK3("<", 1, name, len, "/>", 2); - } - - if(mname) { - _ASN_CALLBACK3("", 1); - er.encoded += 5; - } - - er.encoded += (2 * mlen) + tmper.encoded; - } - - if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); - - if(encs) { - xer_tmp_enc_t *enc = encs; - xer_tmp_enc_t *end = encs + encs_count; - ssize_t control_size = 0; - - cb = original_cb; - app_key = original_app_key; - qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order); - - for(; enc < end; enc++) { - _ASN_CALLBACK(enc->buffer, enc->offset); - FREEMEM(enc->buffer); - enc->buffer = 0; - control_size += enc->offset; - } - assert(control_size == er.encoded); - } - - goto cleanup; -cb_failed: - er.encoded = -1; - er.failed_type = td; - er.structure_ptr = sptr; -cleanup: - if(encs) { - while(encs_count-- > 0) { - if(encs[encs_count].buffer) - FREEMEM(encs[encs_count].buffer); - } - FREEMEM(encs); - } - _ASN_ENCODED_OK(er); -} - -int -SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_TYPE_member_t *elm = td->elements; - const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); - int ret; - int i; - - if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; - - /* Dump preamble */ - if(cb(td->name, strlen(td->name), app_key) < 0 - || cb(" ::= {", 6, app_key) < 0) - return -1; - - for(i = 0; i < list->count; i++) { - const void *memb_ptr = list->array[i]; - if(!memb_ptr) continue; - - _i_INDENT(1); - - ret = elm->type->print_struct(elm->type, memb_ptr, - ilevel + 1, cb, app_key); - if(ret) return ret; - } - - ilevel--; - _i_INDENT(1); - - return (cb("}", 1, app_key) < 0) ? -1 : 0; -} - -void -SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - if(td && ptr) { - asn_SET_OF_specifics_t *specs; - asn_TYPE_member_t *elm = td->elements; - asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); - asn_struct_ctx_t *ctx; /* Decoder context */ - int i; - - /* - * Could not use set_of_empty() because of (*free) - * incompatibility. - */ - for(i = 0; i < list->count; i++) { - void *memb_ptr = list->array[i]; - if(memb_ptr) - ASN_STRUCT_FREE(*elm->type, memb_ptr); - } - list->count = 0; /* No meaningful elements left */ - - asn_set_empty(list); /* Remove (list->array) */ - - specs = (asn_SET_OF_specifics_t *)td->specifics; - ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset); - if(ctx->ptr) { - ASN_STRUCT_FREE(*elm->type, ctx->ptr); - ctx->ptr = 0; - } - - if(!contents_only) { - FREEMEM(ptr); - } - } -} - -int -SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - asn_TYPE_member_t *elm = td->elements; - asn_constr_check_f *constr; - const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); - int i; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - constr = elm->memb_constraints; - if(!constr) constr = elm->type->check_constraints; - - /* - * Iterate over the members of an array. - * Validate each in turn, until one fails. - */ - for(i = 0; i < list->count; i++) { - const void *memb_ptr = list->array[i]; - int ret; - - if(!memb_ptr) continue; - - ret = constr(elm->type, memb_ptr, ctfailcb, app_key); - if(ret) return ret; - } - - /* - * Cannot inherit it eralier: - * need to make sure we get the updated version. - */ - if(!elm->memb_constraints) - elm->memb_constraints = elm->type->check_constraints; - - return 0; -} - -asn_dec_rval_t -SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; /* Single one */ - void *st = *sptr; - asn_anonymous_set_ *list; - asn_per_constraint_t *ct; - int repeat = 0; - ssize_t nelems; - - if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) - _ASN_DECODE_FAILED; - - /* - * Create the target structure if it is not present already. - */ - if(!st) { - st = *sptr = CALLOC(1, specs->struct_size); - if(!st) _ASN_DECODE_FAILED; - } - list = _A_SET_FROM_VOID(st); - - /* Figure out which constraints to use */ - if(constraints) ct = &constraints->size; - else if(td->per_constraints) ct = &td->per_constraints->size; - else ct = 0; - - if(ct && ct->flags & APC_EXTENSIBLE) { - int value = per_get_few_bits(pd, 1); - if(value < 0) _ASN_DECODE_STARVED; - if(value) ct = 0; /* Not restricted! */ - } - - if(ct && ct->effective_bits >= 0) { - /* X.691, #19.5: No length determinant */ - nelems = per_get_few_bits(pd, ct->effective_bits); - ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", - (long)nelems, ct->lower_bound, td->name); - if(nelems < 0) _ASN_DECODE_STARVED; - nelems += ct->lower_bound; - } else { - nelems = -1; - } - - do { - int i; - if(nelems < 0) { - nelems = uper_get_length(pd, - ct ? ct->effective_bits : -1, &repeat); - ASN_DEBUG("Got to decode %d elements (eff %d)", - (int)nelems, (int)(ct ? ct->effective_bits : -1)); - if(nelems < 0) _ASN_DECODE_STARVED; - } - - for(i = 0; i < nelems; i++) { - void *ptr = 0; - ASN_DEBUG("SET OF %s decoding", elm->type->name); - rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, - elm->per_constraints, &ptr, pd); - ASN_DEBUG("%s SET OF %s decoded %d, %p", - td->name, elm->type->name, rv.code, ptr); - if(rv.code == RC_OK) { - if(ASN_SET_ADD(list, ptr) == 0) - continue; - ASN_DEBUG("Failed to add element into %s", - td->name); - /* Fall through */ - rv.code = RC_FAIL; - } else { - ASN_DEBUG("Failed decoding %s of %s (SET OF)", - elm->type->name, td->name); - } - if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); - return rv; - } - - nelems = -1; /* Allow uper_get_length() */ - } while(repeat); - - ASN_DEBUG("Decoded %s as SET OF", td->name); - - rv.code = RC_OK; - rv.consumed = 0; - return rv; -} - -asn_dec_rval_t -SET_OF_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; /* Single one */ - void *st = *sptr; - asn_anonymous_set_ *list; - asn_per_constraint_t *ct; - int repeat = 0; - ssize_t nelems; - - if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) - _ASN_DECODE_FAILED; - - /* - * Create the target structure if it is not present already. - */ - if(!st) { - st = *sptr = CALLOC(1, specs->struct_size); - if(!st) _ASN_DECODE_FAILED; - } - list = _A_SET_FROM_VOID(st); - - /* Figure out which constraints to use */ - if(constraints) ct = &constraints->size; - else if(td->per_constraints) ct = &td->per_constraints->size; - else ct = 0; - - if(ct && ct->flags & APC_EXTENSIBLE) { - int value = per_get_few_bits(pd, 1); - if(value < 0) _ASN_DECODE_STARVED; - if(value) ct = 0; /* Not restricted! */ - } - - if(ct && ct->effective_bits >= 0) { - /* X.691, #19.5: No length determinant */ -// nelems = per_get_few_bits(pd, ct->effective_bits); - nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound); - ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", - (long)nelems, ct->lower_bound, td->name); - if(nelems < 0) _ASN_DECODE_STARVED; - nelems += ct->lower_bound; - } else { - nelems = -1; - } - - do { - int i; - if(nelems < 0) { - nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1, - ct ? ct->effective_bits : -1, &repeat); - ASN_DEBUG("Got to decode %d elements (eff %d)", - (int)nelems, ct ? ct->effective_bits : -1); - if(nelems < 0) _ASN_DECODE_STARVED; - } - - for(i = 0; i < nelems; i++) { - void *ptr = 0; - ASN_DEBUG("SET OF %s decoding", elm->type->name); - rv = elm->type->aper_decoder(opt_codec_ctx, elm->type, - elm->per_constraints, &ptr, pd); - ASN_DEBUG("%s SET OF %s decoded %d, %p", - td->name, elm->type->name, rv.code, ptr); - if(rv.code == RC_OK) { - if(ASN_SET_ADD(list, ptr) == 0) - continue; - ASN_DEBUG("Failed to add element into %s", - td->name); - /* Fall through */ - rv.code = RC_FAIL; - } else { - ASN_DEBUG("Failed decoding %s of %s (SET OF)", - elm->type->name, td->name); - } - if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); - return rv; - } - - nelems = -1; /* Allow uper_get_length() */ - } while(repeat); - - ASN_DEBUG("Decoded %s as SET OF", td->name); - - rv.code = RC_OK; - rv.consumed = 0; - return rv; -} diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff new file mode 100644 index 0000000000..3ceaf5e3e5 --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff @@ -0,0 +1,4 @@ +1007c1007 +< (int)nelems, (int)ct ? ct->effective_bits : -1); +--- +> (int)nelems, ct ? ct->effective_bits : -1); diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c deleted file mode 100644 index 239dbdc10f..0000000000 --- a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c +++ /dev/null @@ -1,412 +0,0 @@ -/*- - * Copyright (c) 2004, 2005, 2006 Lev Walkin . - * All rights reserved. - * Redistribution and modifications are permitted subject to BSD license. - */ -/* - * Read the NativeInteger.h for the explanation wrt. differences between - * INTEGER and NativeInteger. - * Basically, both are decoders and encoders of ASN.1 INTEGER type, but this - * implementation deals with the standard (machine-specific) representation - * of them instead of using the platform-independent buffer. - */ -#include -#include - -/* - * NativeInteger basic type description. - */ -static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) -}; -asn_TYPE_descriptor_t asn_DEF_NativeInteger = { - "INTEGER", /* The ASN.1 type is still INTEGER */ - "INTEGER", - NativeInteger_free, - NativeInteger_print, - asn_generic_no_constraint, - NativeInteger_decode_ber, - NativeInteger_encode_der, - NativeInteger_decode_xer, - NativeInteger_encode_xer, - NativeInteger_decode_uper, /* Unaligned PER decoder */ - NativeInteger_encode_uper, /* Unaligned PER encoder */ - NativeInteger_decode_aper, /* Aligned PER decoder */ - NativeInteger_encode_aper, /* Aligned PER encoder */ - 0, /* Use generic outmost tag fetcher */ - asn_DEF_NativeInteger_tags, - sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), - asn_DEF_NativeInteger_tags, /* Same as above */ - sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), - 0, /* No PER visible constraints */ - 0, 0, /* No members */ - 0 /* No specifics */ -}; - -/* - * Decode INTEGER type. - */ -asn_dec_rval_t -NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, - void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - long *native = (long *)*nint_ptr; - asn_dec_rval_t rval; - ber_tlv_len_t length; - - /* - * If the structure is not there, allocate it. - */ - if(native == NULL) { - native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native))); - if(native == NULL) { - rval.code = RC_FAIL; - rval.consumed = 0; - return rval; - } - } - - ASN_DEBUG("Decoding %s as INTEGER (tm=%d)", - td->name, tag_mode); - - /* - * Check tags. - */ - rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, - tag_mode, 0, &length, 0); - if(rval.code != RC_OK) - return rval; - - ASN_DEBUG("%s length is %d bytes", td->name, (int)length); - - /* - * Make sure we have this length. - */ - buf_ptr = ((const char *)buf_ptr) + rval.consumed; - size -= rval.consumed; - if(length > (ber_tlv_len_t)size) { - rval.code = RC_WMORE; - rval.consumed = 0; - return rval; - } - - /* - * ASN.1 encoded INTEGER: buf_ptr, length - * Fill the native, at the same time checking for overflow. - * If overflow occured, return with RC_FAIL. - */ - { - INTEGER_t tmp; - union { - const void *constbuf; - void *nonconstbuf; - } unconst_buf; - long l; - - unconst_buf.constbuf = buf_ptr; - tmp.buf = (uint8_t *)unconst_buf.nonconstbuf; - tmp.size = length; - - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&tmp, (unsigned long *)&l) /* sic */ - : asn_INTEGER2long(&tmp, &l)) { - rval.code = RC_FAIL; - rval.consumed = 0; - return rval; - } - - *native = l; - } - - rval.code = RC_OK; - rval.consumed += length; - - ASN_DEBUG("Took %ld/%ld bytes to encode %s (%ld)", - (long)rval.consumed, (long)length, td->name, (long)*native); - - return rval; -} - -/* - * Encode the NativeInteger using the standard INTEGER type DER encoder. - */ -asn_enc_rval_t -NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr, - int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - unsigned long native = *(unsigned long *)ptr; /* Disable sign ext. */ - asn_enc_rval_t erval; - INTEGER_t tmp; - -#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */ - - tmp.buf = (uint8_t *)&native; - tmp.size = sizeof(native); - -#else /* Works even if WORDS_BIGENDIAN is not set where should've been */ - uint8_t buf[sizeof(native)]; - uint8_t *p; - - /* Prepare a fake INTEGER */ - for(p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8) - *p = (uint8_t)native; - - tmp.buf = buf; - tmp.size = sizeof(buf); -#endif /* WORDS_BIGENDIAN */ - - /* Encode fake INTEGER */ - erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key); - if(erval.encoded == -1) { - assert(erval.structure_ptr == &tmp); - erval.structure_ptr = ptr; - } - return erval; -} - -/* - * Decode the chunk of XML text encoding INTEGER. - */ -asn_dec_rval_t -NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname, - const void *buf_ptr, size_t size) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_dec_rval_t rval; - INTEGER_t st; - void *st_ptr = (void *)&st; - long *native = (long *)*sptr; - - if(!native) { - native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if(!native) _ASN_DECODE_FAILED; - } - - memset(&st, 0, sizeof(st)); - rval = INTEGER_decode_xer(opt_codec_ctx, td, &st_ptr, - opt_mname, buf_ptr, size); - if(rval.code == RC_OK) { - long l; - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&st, (unsigned long *)&l) /* sic */ - : asn_INTEGER2long(&st, &l)) { - rval.code = RC_FAIL; - rval.consumed = 0; - } else { - *native = l; - } - } else { - /* - * Cannot restart from the middle; - * there is no place to save state in the native type. - * Request a continuation from the very beginning. - */ - rval.consumed = 0; - } - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &st); - return rval; -} - - -asn_enc_rval_t -NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - char scratch[32]; /* Enough for 64-bit int */ - asn_enc_rval_t er; - const long *native = (const long *)sptr; - - (void)ilevel; - (void)flags; - - if(!native) _ASN_ENCODE_FAILED; - - er.encoded = snprintf(scratch, sizeof(scratch), - (specs && specs->field_unsigned) - ? "%lu" : "%ld", *native); - if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) - || cb(scratch, er.encoded, app_key) < 0) - _ASN_ENCODE_FAILED; - - _ASN_ENCODED_OK(er); -} - -asn_dec_rval_t -NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_dec_rval_t rval; - long *native = (long *)*sptr; - INTEGER_t tmpint; - void *tmpintptr = &tmpint; - - (void)opt_codec_ctx; - ASN_DEBUG("Decoding NativeInteger %s (UPER)", td->name); - - if(!native) { - native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - if(!native) _ASN_DECODE_FAILED; - } - - memset(&tmpint, 0, sizeof tmpint); - rval = INTEGER_decode_uper(opt_codec_ctx, td, constraints, - &tmpintptr, pd); - if(rval.code == RC_OK) { - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) - : asn_INTEGER2long(&tmpint, native)) - rval.code = RC_FAIL; - else - ASN_DEBUG("NativeInteger %s got value %ld", - td->name, *native); - } - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - - return rval; -} - -asn_dec_rval_t -NativeInteger_decode_aper(asn_codec_ctx_t *opt_codec_ctx, - asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_dec_rval_t rval; - long *native = (long *)*sptr; - INTEGER_t tmpint; - void *tmpintptr = &tmpint; - //int dynamic = 0; - - (void)opt_codec_ctx; - ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name); - - if(!native) { - native = (long *)(*sptr = CALLOC(1, sizeof(*native))); - //dynamic = 1; - if(!native) _ASN_DECODE_FAILED; - } - - memset(&tmpint, 0, sizeof tmpint); - rval = INTEGER_decode_aper(opt_codec_ctx, td, constraints, - &tmpintptr, pd); - if(rval.code == RC_OK) { - if((specs&&specs->field_unsigned) - ? asn_INTEGER2ulong(&tmpint, (unsigned long *)native) - : asn_INTEGER2long(&tmpint, native)) - rval.code = RC_FAIL; - else - ASN_DEBUG("NativeInteger %s got value %ld", - td->name, *native); - } - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - //if (dynamic) - // free(native); - - return rval; -} - -asn_enc_rval_t -NativeInteger_encode_uper(asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_enc_rval_t er; - long native; - INTEGER_t tmpint; - - if(!sptr) _ASN_ENCODE_FAILED; - - native = *(long *)sptr; - - ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native); - - memset(&tmpint, 0, sizeof(tmpint)); - if((specs&&specs->field_unsigned) - ? asn_ulong2INTEGER(&tmpint, native) - : asn_long2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; - er = INTEGER_encode_uper(td, constraints, &tmpint, po); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - return er; -} - -asn_enc_rval_t -NativeInteger_encode_aper( - asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - asn_enc_rval_t er; - INTEGER_t tmpint; - - if(!sptr) _ASN_ENCODE_FAILED; - memset(&tmpint, 0, sizeof(tmpint)); - - if(specs&&specs->field_unsigned) { - unsigned long native; - native = *(unsigned long *)sptr; - - ASN_DEBUG("Encoding NativeInteger %s %lu (APER) (unsigned)", td->name, native); - - if(asn_ulong2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; - } else { - long native; - native = *(long *)sptr; - - ASN_DEBUG("Encoding NativeInteger %s %ld (APER) (unsigned)", td->name, native); - if(asn_long2INTEGER(&tmpint, native)) - _ASN_ENCODE_FAILED; - } - -// if((specs&&specs->field_unsigned) -// ? asn_ulong2INTEGER(&tmpint, native) -// : asn_long2INTEGER(&tmpint, native)) -// _ASN_ENCODE_FAILED; - er = INTEGER_encode_aper(td, constraints, &tmpint, po); - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - return er; -} - -/* - * INTEGER specific human-readable output. - */ -int -NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics; - const long *native = (const long *)sptr; - char scratch[32]; /* Enough for 64-bit int */ - int ret; - - (void)td; /* Unused argument */ - (void)ilevel; /* Unused argument */ - - if(native) { - ret = snprintf(scratch, sizeof(scratch), - (specs && specs->field_unsigned) - ? "%lu" : "%ld", *native); - assert(ret > 0 && (size_t)ret < sizeof(scratch)); - return (cb(scratch, ret, app_key) < 0) ? -1 : 0; - } else { - return (cb("", 8, app_key) < 0) ? -1 : 0; - } -} - -void -NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - - if(!td || !ptr) - return; - - ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", - td->name, contents_only, ptr); - - if(!contents_only) { - FREEMEM(ptr); - } -} - diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff new file mode 100644 index 0000000000..c1649fd6f7 --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff @@ -0,0 +1,8 @@ +282c282 +< int dynamic = 0; +--- +> //int dynamic = 0; +289c289 +< dynamic = 1; +--- +> //dynamic = 1; diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h deleted file mode 100644 index d9c9fd1b4b..0000000000 --- a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Generated by asn1c-0.9.24 (http://lionet.info/asn1c) - * From ASN.1 module "X2AP-IEs" - * found in "/roux/comments/openairinterface5g/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn" - * `asn1c -gen-PER` - */ - -#ifndef _X2ap_CriticalityDiagnostics_IE_List_H_ -#define _X2ap_CriticalityDiagnostics_IE_List_H_ - - -#include - -/* Including external dependencies */ -#include -#include "X2ap-Criticality.h" -#include "X2ap-ProtocolIE-ID.h" -#include "X2ap-TypeOfError.h" -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward declarations */ -struct X2ap_IE_Extensions; - -struct X2ap_CriticalityDiagnostics_IE_List__Member { - X2ap_Criticality_t iECriticality; - X2ap_ProtocolIE_ID_t iE_ID; - X2ap_TypeOfError_t typeOfError; - struct X2ap_IE_Extensions *iE_Extensions /* OPTIONAL */; - /* - * This type is extensible, - * possible extensions are below. - */ - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - }; - -/* X2ap-CriticalityDiagnostics-IE-List */ -typedef struct X2ap_CriticalityDiagnostics_IE_List { - A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member - ) list; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; -} X2ap_CriticalityDiagnostics_IE_List_t; - -/* Implementation */ -extern asn_TYPE_descriptor_t asn_DEF_X2ap_CriticalityDiagnostics_IE_List; - -#ifdef __cplusplus -} -#endif - -/* Referred external types */ -#include "X2ap-IE-Extensions.h" - -#endif /* _X2ap_CriticalityDiagnostics_IE_List_H_ */ -#include diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff new file mode 100644 index 0000000000..6ea7b2454e --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff @@ -0,0 +1,15 @@ +29,31c29 +< /* X2ap-CriticalityDiagnostics-IE-List */ +< typedef struct X2ap_CriticalityDiagnostics_IE_List { +< A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member { +--- +> struct X2ap_CriticalityDiagnostics_IE_List__Member { +43c41,46 +< } ) list; +--- +> }; +> +> /* X2ap-CriticalityDiagnostics-IE-List */ +> typedef struct X2ap_CriticalityDiagnostics_IE_List { +> A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member +> ) list; diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c deleted file mode 100644 index 3e2d23b254..0000000000 --- a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c +++ /dev/null @@ -1,1041 +0,0 @@ -/*- - * Copyright (c) 2003, 2004, 2005 Lev Walkin . - * All rights reserved. - * Redistribution and modifications are permitted subject to BSD license. - */ -#include -#include -#include - -/* - * Number of bytes left for this structure. - * (ctx->left) indicates the number of bytes _transferred_ for the structure. - * (size) contains the number of bytes in the buffer passed. - */ -#define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left) - -/* - * If the subprocessor function returns with an indication that it wants - * more data, it may well be a fatal decoding problem, because the - * size is constrained by the 's L, even if the buffer size allows - * reading more data. - * For example, consider the buffer containing the following TLVs: - * ... - * The TLV length clearly indicates that one byte is expected in V, but - * if the V processor returns with "want more data" even if the buffer - * contains way more data than the V processor have seen. - */ -#define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size) - -/* - * This macro "eats" the part of the buffer which is definitely "consumed", - * i.e. was correctly converted into local representation or rightfully skipped. - */ -#undef ADVANCE -#define ADVANCE(num_bytes) do { \ - size_t num = num_bytes; \ - ptr = ((const char *)ptr) + num;\ - size -= num; \ - if(ctx->left >= 0) \ - ctx->left -= num; \ - consumed_myself += num; \ - } while(0) - -/* - * Switch to the next phase of parsing. - */ -#undef NEXT_PHASE -#undef PHASE_OUT -#define NEXT_PHASE(ctx) do { \ - ctx->phase++; \ - ctx->step = 0; \ - } while(0) -#define PHASE_OUT(ctx) do { ctx->phase = 10; } while(0) - -/* - * Return a standardized complex structure. - */ -#undef RETURN -#define RETURN(_code) do { \ - rval.code = _code; \ - rval.consumed = consumed_myself;\ - return rval; \ - } while(0) - -/* - * The decoder of the SET OF type. - */ -asn_dec_rval_t -SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **struct_ptr, const void *ptr, size_t size, int tag_mode) { - /* - * Bring closer parts of structure description. - */ - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; /* Single one */ - - /* - * Parts of the structure being constructed. - */ - void *st = *struct_ptr; /* Target structure. */ - asn_struct_ctx_t *ctx; /* Decoder context */ - - ber_tlv_tag_t tlv_tag; /* T from TLV */ - asn_dec_rval_t rval; /* Return code from subparsers */ - - ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ - - ASN_DEBUG("Decoding %s as SET OF", td->name); - - /* - * Create the target structure if it is not present already. - */ - if(st == 0) { - st = *struct_ptr = CALLOC(1, specs->struct_size); - if(st == 0) { - RETURN(RC_FAIL); - } - } - - /* - * Restore parsing context. - */ - ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); - - /* - * Start to parse where left previously - */ - switch(ctx->phase) { - case 0: - /* - * PHASE 0. - * Check that the set of tags associated with given structure - * perfectly fits our expectations. - */ - - rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size, - tag_mode, 1, &ctx->left, 0); - if(rval.code != RC_OK) { - ASN_DEBUG("%s tagging check failed: %d", - td->name, rval.code); - return rval; - } - - if(ctx->left >= 0) - ctx->left += rval.consumed; /* ?Substracted below! */ - ADVANCE(rval.consumed); - - ASN_DEBUG("Structure consumes %ld bytes, " - "buffer %ld", (long)ctx->left, (long)size); - - NEXT_PHASE(ctx); - /* Fall through */ - case 1: - /* - * PHASE 1. - * From the place where we've left it previously, - * try to decode the next item. - */ - for(;; ctx->step = 0) { - ssize_t tag_len; /* Length of TLV's T */ - - if(ctx->step & 1) - goto microphase2; - - /* - * MICROPHASE 1: Synchronize decoding. - */ - - if(ctx->left == 0) { - ASN_DEBUG("End of SET OF %s", td->name); - /* - * No more things to decode. - * Exit out of here. - */ - PHASE_OUT(ctx); - RETURN(RC_OK); - } - - /* - * Fetch the T from TLV. - */ - tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag); - switch(tag_len) { - case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE); - /* Fall through */ - case -1: RETURN(RC_FAIL); - } - - if(ctx->left < 0 && ((const uint8_t *)ptr)[0] == 0) { - if(LEFT < 2) { - if(SIZE_VIOLATION) - RETURN(RC_FAIL); - else - RETURN(RC_WMORE); - } else if(((const uint8_t *)ptr)[1] == 0) { - /* - * Found the terminator of the - * indefinite length structure. - */ - break; - } - } - - /* Outmost tag may be unknown and cannot be fetched/compared */ - if(elm->tag != (ber_tlv_tag_t)-1) { - if(BER_TAGS_EQUAL(tlv_tag, elm->tag)) { - /* - * The new list member of expected type has arrived. - */ - } else { - ASN_DEBUG("Unexpected tag %s fixed SET OF %s", - ber_tlv_tag_string(tlv_tag), td->name); - ASN_DEBUG("%s SET OF has tag %s", - td->name, ber_tlv_tag_string(elm->tag)); - RETURN(RC_FAIL); - } - } - - /* - * MICROPHASE 2: Invoke the member-specific decoder. - */ - ctx->step |= 1; /* Confirm entering next microphase */ - microphase2: - - /* - * Invoke the member fetch routine according to member's type - */ - rval = elm->type->ber_decoder(opt_codec_ctx, - elm->type, &ctx->ptr, ptr, LEFT, 0); - ASN_DEBUG("In %s SET OF %s code %d consumed %d", - td->name, elm->type->name, - rval.code, (int)rval.consumed); - switch(rval.code) { - case RC_OK: - { - asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); - if(ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); - else - ctx->ptr = 0; - } - break; - case RC_WMORE: /* More data expected */ - if(!SIZE_VIOLATION) { - ADVANCE(rval.consumed); - RETURN(RC_WMORE); - } - /* Fall through */ - case RC_FAIL: /* Fatal error */ - ASN_STRUCT_FREE(*elm->type, ctx->ptr); - ctx->ptr = 0; - RETURN(RC_FAIL); - } /* switch(rval) */ - - ADVANCE(rval.consumed); - } /* for(all list members) */ - - NEXT_PHASE(ctx); - case 2: - /* - * Read in all "end of content" TLVs. - */ - while(ctx->left < 0) { - if(LEFT < 2) { - if(LEFT > 0 && ((const char *)ptr)[0] != 0) { - /* Unexpected tag */ - RETURN(RC_FAIL); - } else { - RETURN(RC_WMORE); - } - } - if(((const char *)ptr)[0] == 0 - && ((const char *)ptr)[1] == 0) { - ADVANCE(2); - ctx->left++; - } else { - RETURN(RC_FAIL); - } - } - - PHASE_OUT(ctx); - } - - RETURN(RC_OK); -} - -/* - * Internally visible buffer holding a single encoded element. - */ -struct _el_buffer { - uint8_t *buf; - size_t length; - size_t size; -}; -/* Append bytes to the above structure */ -static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr) { - struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr; - - if(el_buf->length + size > el_buf->size) - return -1; - - memcpy(el_buf->buf + el_buf->length, buffer, size); - - el_buf->length += size; - return 0; -} -static int _el_buf_cmp(const void *ap, const void *bp) { - const struct _el_buffer *a = (const struct _el_buffer *)ap; - const struct _el_buffer *b = (const struct _el_buffer *)bp; - int ret; - size_t common_len; - - if(a->length < b->length) - common_len = a->length; - else - common_len = b->length; - - ret = memcmp(a->buf, b->buf, common_len); - if(ret == 0) { - if(a->length < b->length) - ret = -1; - else if(a->length > b->length) - ret = 1; - } - - return ret; -} - -/* - * The DER encoder of the SET OF type. - */ -asn_enc_rval_t -SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, - int tag_mode, ber_tlv_tag_t tag, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_TYPE_member_t *elm = td->elements; - asn_TYPE_descriptor_t *elm_type = elm->type; - der_type_encoder_f *der_encoder = elm_type->der_encoder; - asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); - size_t computed_size = 0; - ssize_t encoding_size = 0; - struct _el_buffer *encoded_els; - ssize_t eels_count = 0; - size_t max_encoded_len = 1; - asn_enc_rval_t erval; - int ret; - int edx; - - ASN_DEBUG("Estimating size for SET OF %s", td->name); - - /* - * Gather the length of the underlying members sequence. - */ - for(edx = 0; edx < list->count; edx++) { - void *memb_ptr = list->array[edx]; - if(!memb_ptr) continue; - erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0); - if(erval.encoded == -1) - return erval; - computed_size += erval.encoded; - - /* Compute maximum encoding's size */ - if(max_encoded_len < (size_t)erval.encoded) - max_encoded_len = erval.encoded; - } - - /* - * Encode the TLV for the sequence itself. - */ - encoding_size = der_write_tags(td, computed_size, tag_mode, 1, tag, - cb, app_key); - if(encoding_size == -1) { - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - return erval; - } - computed_size += encoding_size; - - if(!cb || list->count == 0) { - erval.encoded = computed_size; - _ASN_ENCODED_OK(erval); - } - - /* - * DER mandates dynamic sorting of the SET OF elements - * according to their encodings. Build an array of the - * encoded elements. - */ - encoded_els = (struct _el_buffer *)MALLOC( - list->count * sizeof(encoded_els[0])); - if(encoded_els == NULL) { - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - return erval; - } - - ASN_DEBUG("Encoding members of %s SET OF", td->name); - - /* - * Encode all members. - */ - for(edx = 0; edx < list->count; edx++) { - void *memb_ptr = list->array[edx]; - struct _el_buffer *encoded_el = &encoded_els[eels_count]; - - if(!memb_ptr) continue; - - /* - * Prepare space for encoding. - */ - encoded_el->buf = (uint8_t *)MALLOC(max_encoded_len); - if(encoded_el->buf) { - encoded_el->length = 0; - encoded_el->size = max_encoded_len; - } else { - for(edx--; edx >= 0; edx--) - FREEMEM(encoded_els[edx].buf); - FREEMEM(encoded_els); - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - return erval; - } - - /* - * Encode the member into the prepared space. - */ - erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, - _el_addbytes, encoded_el); - if(erval.encoded == -1) { - for(; edx >= 0; edx--) - FREEMEM(encoded_els[edx].buf); - FREEMEM(encoded_els); - return erval; - } - encoding_size += erval.encoded; - eels_count++; - } - - /* - * Sort the encoded elements according to their encoding. - */ - qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp); - - /* - * Report encoded elements to the application. - * Dispose of temporary sorted members table. - */ - ret = 0; - for(edx = 0; edx < eels_count; edx++) { - struct _el_buffer *encoded_el = &encoded_els[edx]; - /* Report encoded chunks to the application */ - if(ret == 0 - && cb(encoded_el->buf, encoded_el->length, app_key) < 0) - ret = -1; - FREEMEM(encoded_el->buf); - } - FREEMEM(encoded_els); - - if(ret || computed_size != (size_t)encoding_size) { - /* - * Standard callback failed, or - * encoded size is not equal to the computed size. - */ - erval.encoded = -1; - erval.failed_type = td; - erval.structure_ptr = ptr; - } else { - erval.encoded = computed_size; - } - - _ASN_ENCODED_OK(erval); -} - -#undef XER_ADVANCE -#define XER_ADVANCE(num_bytes) do { \ - size_t num = num_bytes; \ - buf_ptr = ((const char *)buf_ptr) + num;\ - size -= num; \ - consumed_myself += num; \ - } while(0) - -/* - * Decode the XER (XML) data. - */ -asn_dec_rval_t -SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - void **struct_ptr, const char *opt_mname, - const void *buf_ptr, size_t size) { - /* - * Bring closer parts of structure description. - */ - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *element = td->elements; - const char *elm_tag; - const char *xml_tag = opt_mname ? opt_mname : td->xml_tag; - - /* - * ... and parts of the structure being constructed. - */ - void *st = *struct_ptr; /* Target structure. */ - asn_struct_ctx_t *ctx; /* Decoder context */ - - asn_dec_rval_t rval; /* Return value from a decoder */ - ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ - - /* - * Create the target structure if it is not present already. - */ - if(st == 0) { - st = *struct_ptr = CALLOC(1, specs->struct_size); - if(st == 0) RETURN(RC_FAIL); - } - - /* Which tag is expected for the downstream */ - if(specs->as_XMLValueList) { - elm_tag = (specs->as_XMLValueList == 1) ? 0 : ""; - } else { - elm_tag = (*element->name) - ? element->name : element->type->xml_tag; - } - - /* - * Restore parsing context. - */ - ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset); - - /* - * Phases of XER/XML processing: - * Phase 0: Check that the opening tag matches our expectations. - * Phase 1: Processing body and reacting on closing tag. - * Phase 2: Processing inner type. - */ - for(; ctx->phase <= 2;) { - pxer_chunk_type_e ch_type; /* XER chunk type */ - ssize_t ch_size; /* Chunk size */ - xer_check_tag_e tcv; /* Tag check value */ - - /* - * Go inside the inner member of a set. - */ - if(ctx->phase == 2) { - asn_dec_rval_t tmprval; - - /* Invoke the inner type decoder, m.b. multiple times */ - ASN_DEBUG("XER/SET OF element [%s]", elm_tag); - tmprval = element->type->xer_decoder(opt_codec_ctx, - element->type, &ctx->ptr, elm_tag, - buf_ptr, size); - if(tmprval.code == RC_OK) { - asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); - if(ASN_SET_ADD(list, ctx->ptr) != 0) - RETURN(RC_FAIL); - ctx->ptr = 0; - XER_ADVANCE(tmprval.consumed); - } else { - XER_ADVANCE(tmprval.consumed); - RETURN(tmprval.code); - } - ctx->phase = 1; /* Back to body processing */ - ASN_DEBUG("XER/SET OF phase => %d", ctx->phase); - /* Fall through */ - } - - /* - * Get the next part of the XML stream. - */ - ch_size = xer_next_token(&ctx->context, - buf_ptr, size, &ch_type); - switch(ch_size) { - case -1: RETURN(RC_FAIL); - case 0: RETURN(RC_WMORE); - default: - switch(ch_type) { - case PXER_COMMENT: /* Got XML comment */ - case PXER_TEXT: /* Ignore free-standing text */ - XER_ADVANCE(ch_size); /* Skip silently */ - continue; - case PXER_TAG: - break; /* Check the rest down there */ - } - } - - tcv = xer_check_tag(buf_ptr, ch_size, xml_tag); - ASN_DEBUG("XER/SET OF: tcv = %d, ph=%d t=%s", - tcv, ctx->phase, xml_tag); - switch(tcv) { - case XCT_CLOSING: - if(ctx->phase == 0) break; - ctx->phase = 0; - /* Fall through */ - case XCT_BOTH: - if(ctx->phase == 0) { - /* No more things to decode */ - XER_ADVANCE(ch_size); - ctx->phase = 3; /* Phase out */ - RETURN(RC_OK); - } - /* Fall through */ - case XCT_OPENING: - if(ctx->phase == 0) { - XER_ADVANCE(ch_size); - ctx->phase = 1; /* Processing body phase */ - continue; - } - /* Fall through */ - case XCT_UNKNOWN_OP: - case XCT_UNKNOWN_BO: - - ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); - if(ctx->phase == 1) { - /* - * Process a single possible member. - */ - ctx->phase = 2; - continue; - } - /* Fall through */ - default: - break; - } - - ASN_DEBUG("Unexpected XML tag in SET OF"); - break; - } - - ctx->phase = 3; /* "Phase out" on hard failure */ - RETURN(RC_FAIL); -} - - - -typedef struct xer_tmp_enc_s { - void *buffer; - size_t offset; - size_t size; -} xer_tmp_enc_t; -static int -SET_OF_encode_xer_callback(const void *buffer, size_t size, void *key) { - xer_tmp_enc_t *t = (xer_tmp_enc_t *)key; - if(t->offset + size >= t->size) { - size_t newsize = (t->size << 2) + size; - void *p = REALLOC(t->buffer, newsize); - if(!p) return -1; - t->buffer = p; - t->size = newsize; - } - memcpy((char *)t->buffer + t->offset, buffer, size); - t->offset += size; - return 0; -} -static int -SET_OF_xer_order(const void *aptr, const void *bptr) { - const xer_tmp_enc_t *a = (const xer_tmp_enc_t *)aptr; - const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr; - size_t minlen = a->offset; - int ret; - if(b->offset < minlen) minlen = b->offset; - /* Well-formed UTF-8 has this nice lexicographical property... */ - ret = memcmp(a->buffer, b->buffer, minlen); - if(ret != 0) return ret; - if(a->offset == b->offset) - return 0; - if(a->offset == minlen) - return -1; - return 1; -} - - -asn_enc_rval_t -SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, - int ilevel, enum xer_encoder_flags_e flags, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_enc_rval_t er; - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; - asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr); - const char *mname = specs->as_XMLValueList - ? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag); - size_t mlen = mname ? strlen(mname) : 0; - int xcan = (flags & XER_F_CANONICAL); - xer_tmp_enc_t *encs = 0; - size_t encs_count = 0; - void *original_app_key = app_key; - asn_app_consume_bytes_f *original_cb = cb; - int i; - - if(!sptr) _ASN_ENCODE_FAILED; - - if(xcan) { - encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0])); - if(!encs) _ASN_ENCODE_FAILED; - cb = SET_OF_encode_xer_callback; - } - - er.encoded = 0; - - for(i = 0; i < list->count; i++) { - asn_enc_rval_t tmper; - - void *memb_ptr = list->array[i]; - if(!memb_ptr) continue; - - if(encs) { - memset(&encs[encs_count], 0, sizeof(encs[0])); - app_key = &encs[encs_count]; - encs_count++; - } - - if(mname) { - if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel); - _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1); - } - - if(!xcan && specs->as_XMLValueList == 1) - _i_ASN_TEXT_INDENT(1, ilevel + 1); - tmper = elm->type->xer_encoder(elm->type, memb_ptr, - ilevel + (specs->as_XMLValueList != 2), - flags, cb, app_key); - if(tmper.encoded == -1) { - td = tmper.failed_type; - sptr = tmper.structure_ptr; - goto cb_failed; - } - if(tmper.encoded == 0 && specs->as_XMLValueList) { - const char *name = elm->type->xml_tag; - size_t len = strlen(name); - _ASN_CALLBACK3("<", 1, name, len, "/>", 2); - } - - if(mname) { - _ASN_CALLBACK3("", 1); - er.encoded += 5; - } - - er.encoded += (2 * mlen) + tmper.encoded; - } - - if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1); - - if(encs) { - xer_tmp_enc_t *enc = encs; - xer_tmp_enc_t *end = encs + encs_count; - ssize_t control_size = 0; - - cb = original_cb; - app_key = original_app_key; - qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order); - - for(; enc < end; enc++) { - _ASN_CALLBACK(enc->buffer, enc->offset); - FREEMEM(enc->buffer); - enc->buffer = 0; - control_size += enc->offset; - } - assert(control_size == er.encoded); - } - - goto cleanup; -cb_failed: - er.encoded = -1; - er.failed_type = td; - er.structure_ptr = sptr; -cleanup: - if(encs) { - while(encs_count-- > 0) { - if(encs[encs_count].buffer) - FREEMEM(encs[encs_count].buffer); - } - FREEMEM(encs); - } - _ASN_ENCODED_OK(er); -} - -int -SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, - asn_app_consume_bytes_f *cb, void *app_key) { - asn_TYPE_member_t *elm = td->elements; - const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); - int ret; - int i; - - if(!sptr) return (cb("", 8, app_key) < 0) ? -1 : 0; - - /* Dump preamble */ - if(cb(td->name, strlen(td->name), app_key) < 0 - || cb(" ::= {", 6, app_key) < 0) - return -1; - - for(i = 0; i < list->count; i++) { - const void *memb_ptr = list->array[i]; - if(!memb_ptr) continue; - - _i_INDENT(1); - - ret = elm->type->print_struct(elm->type, memb_ptr, - ilevel + 1, cb, app_key); - if(ret) return ret; - } - - ilevel--; - _i_INDENT(1); - - return (cb("}", 1, app_key) < 0) ? -1 : 0; -} - -void -SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - if(td && ptr) { - asn_SET_OF_specifics_t *specs; - asn_TYPE_member_t *elm = td->elements; - asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); - asn_struct_ctx_t *ctx; /* Decoder context */ - int i; - - /* - * Could not use set_of_empty() because of (*free) - * incompatibility. - */ - for(i = 0; i < list->count; i++) { - void *memb_ptr = list->array[i]; - if(memb_ptr) - ASN_STRUCT_FREE(*elm->type, memb_ptr); - } - list->count = 0; /* No meaningful elements left */ - - asn_set_empty(list); /* Remove (list->array) */ - - specs = (asn_SET_OF_specifics_t *)td->specifics; - ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset); - if(ctx->ptr) { - ASN_STRUCT_FREE(*elm->type, ctx->ptr); - ctx->ptr = 0; - } - - if(!contents_only) { - FREEMEM(ptr); - } - } -} - -int -SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr, - asn_app_constraint_failed_f *ctfailcb, void *app_key) { - asn_TYPE_member_t *elm = td->elements; - asn_constr_check_f *constr; - const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr); - int i; - - if(!sptr) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value not given (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } - - constr = elm->memb_constraints; - if(!constr) constr = elm->type->check_constraints; - - /* - * Iterate over the members of an array. - * Validate each in turn, until one fails. - */ - for(i = 0; i < list->count; i++) { - const void *memb_ptr = list->array[i]; - int ret; - - if(!memb_ptr) continue; - - ret = constr(elm->type, memb_ptr, ctfailcb, app_key); - if(ret) return ret; - } - - /* - * Cannot inherit it eralier: - * need to make sure we get the updated version. - */ - if(!elm->memb_constraints) - elm->memb_constraints = elm->type->check_constraints; - - return 0; -} - -asn_dec_rval_t -SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; /* Single one */ - void *st = *sptr; - asn_anonymous_set_ *list; - asn_per_constraint_t *ct; - int repeat = 0; - ssize_t nelems; - - if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) - _ASN_DECODE_FAILED; - - /* - * Create the target structure if it is not present already. - */ - if(!st) { - st = *sptr = CALLOC(1, specs->struct_size); - if(!st) _ASN_DECODE_FAILED; - } - list = _A_SET_FROM_VOID(st); - - /* Figure out which constraints to use */ - if(constraints) ct = &constraints->size; - else if(td->per_constraints) ct = &td->per_constraints->size; - else ct = 0; - - if(ct && ct->flags & APC_EXTENSIBLE) { - int value = per_get_few_bits(pd, 1); - if(value < 0) _ASN_DECODE_STARVED; - if(value) ct = 0; /* Not restricted! */ - } - - if(ct && ct->effective_bits >= 0) { - /* X.691, #19.5: No length determinant */ - nelems = per_get_few_bits(pd, ct->effective_bits); - ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", - (long)nelems, ct->lower_bound, td->name); - if(nelems < 0) _ASN_DECODE_STARVED; - nelems += ct->lower_bound; - } else { - nelems = -1; - } - - do { - int i; - if(nelems < 0) { - nelems = uper_get_length(pd, - ct ? ct->effective_bits : -1, &repeat); - ASN_DEBUG("Got to decode %d elements (eff %d)", - (int)nelems, (int)(ct ? ct->effective_bits : -1)); - if(nelems < 0) _ASN_DECODE_STARVED; - } - - for(i = 0; i < nelems; i++) { - void *ptr = 0; - ASN_DEBUG("SET OF %s decoding", elm->type->name); - rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, - elm->per_constraints, &ptr, pd); - ASN_DEBUG("%s SET OF %s decoded %d, %p", - td->name, elm->type->name, rv.code, ptr); - if(rv.code == RC_OK) { - if(ASN_SET_ADD(list, ptr) == 0) - continue; - ASN_DEBUG("Failed to add element into %s", - td->name); - /* Fall through */ - rv.code = RC_FAIL; - } else { - ASN_DEBUG("Failed decoding %s of %s (SET OF)", - elm->type->name, td->name); - } - if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); - return rv; - } - - nelems = -1; /* Allow uper_get_length() */ - } while(repeat); - - ASN_DEBUG("Decoded %s as SET OF", td->name); - - rv.code = RC_OK; - rv.consumed = 0; - return rv; -} - -asn_dec_rval_t -SET_OF_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, - asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; - asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; - asn_TYPE_member_t *elm = td->elements; /* Single one */ - void *st = *sptr; - asn_anonymous_set_ *list; - asn_per_constraint_t *ct; - int repeat = 0; - ssize_t nelems; - - if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) - _ASN_DECODE_FAILED; - - /* - * Create the target structure if it is not present already. - */ - if(!st) { - st = *sptr = CALLOC(1, specs->struct_size); - if(!st) _ASN_DECODE_FAILED; - } - list = _A_SET_FROM_VOID(st); - - /* Figure out which constraints to use */ - if(constraints) ct = &constraints->size; - else if(td->per_constraints) ct = &td->per_constraints->size; - else ct = 0; - - if(ct && ct->flags & APC_EXTENSIBLE) { - int value = per_get_few_bits(pd, 1); - if(value < 0) _ASN_DECODE_STARVED; - if(value) ct = 0; /* Not restricted! */ - } - - if(ct && ct->effective_bits >= 0) { - /* X.691, #19.5: No length determinant */ -// nelems = per_get_few_bits(pd, ct->effective_bits); - nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound); - ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s", - (long)nelems, ct->lower_bound, td->name); - if(nelems < 0) _ASN_DECODE_STARVED; - nelems += ct->lower_bound; - } else { - nelems = -1; - } - - do { - int i; - if(nelems < 0) { - nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1, - ct ? ct->effective_bits : -1, &repeat); - ASN_DEBUG("Got to decode %d elements (eff %d)", - (int)nelems, ct ? ct->effective_bits : -1); - if(nelems < 0) _ASN_DECODE_STARVED; - } - - for(i = 0; i < nelems; i++) { - void *ptr = 0; - ASN_DEBUG("SET OF %s decoding", elm->type->name); - rv = elm->type->aper_decoder(opt_codec_ctx, elm->type, - elm->per_constraints, &ptr, pd); - ASN_DEBUG("%s SET OF %s decoded %d, %p", - td->name, elm->type->name, rv.code, ptr); - if(rv.code == RC_OK) { - if(ASN_SET_ADD(list, ptr) == 0) - continue; - ASN_DEBUG("Failed to add element into %s", - td->name); - /* Fall through */ - rv.code = RC_FAIL; - } else { - ASN_DEBUG("Failed decoding %s of %s (SET OF)", - elm->type->name, td->name); - } - if(ptr) ASN_STRUCT_FREE(*elm->type, ptr); - return rv; - } - - nelems = -1; /* Allow uper_get_length() */ - } while(repeat); - - ASN_DEBUG("Decoded %s as SET OF", td->name); - - rv.code = RC_OK; - rv.consumed = 0; - return rv; -} diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff new file mode 100644 index 0000000000..3ceaf5e3e5 --- /dev/null +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff @@ -0,0 +1,4 @@ +1007c1007 +< (int)nelems, (int)ct ? ct->effective_bits : -1); +--- +> (int)nelems, ct ? ct->effective_bits : -1); From bae725a3204ecc70efe08e21bc015c630c93f73b Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 22 Feb 2016 16:08:08 +0100 Subject: [PATCH 03/21] Deal with Rel8 RRC (not checked, just let fix_asn1 accept it). Also modified CMakeLists.txt to run asn1tostruct.py at cmake time, because the generated Makefile was wrong. When compiling with -j4 it would mess up by calling fix_asn1 twice with a weird timing, leading to failures. --- cmake_targets/CMakeLists.txt | 26 ++++++++++++++++++-------- cmake_targets/tools/fix_asn1 | 3 +++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6bebc2d655..c7058c1cff 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -321,10 +321,15 @@ set(S1AP_ASN_FILES ) set(S1AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) #message("calling ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}") -execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}) -execute_process( - COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} - RESULT_VARIABLE ret) +execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES} RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${asn1c_call}: error") +endif (NOT ${ret} STREQUAL 0) +execute_process(COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR} RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "asn1tostruct.py: error") +endif (NOT ${ret} STREQUAL 0) +execute_process(COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) @@ -395,10 +400,15 @@ set(X2AP_ASN_FILES set(X2AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) #message("calling ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}") -execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}) -execute_process( - COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} - RESULT_VARIABLE ret) +execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES} RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${asn1c_call}: error") +endif (NOT ${ret} STREQUAL 0) +execute_process(COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR} RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "asn1tostruct.py: error") +endif (NOT ${ret} STREQUAL 0) +execute_process(COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 index ba8f15d8ec..42893e05c6 100755 --- a/cmake_targets/tools/fix_asn1 +++ b/cmake_targets/tools/fix_asn1 @@ -93,6 +93,9 @@ function patch_rrc() echo "patching RRC files release 10" apply_patches "$directory" RRC_Rel10 ${#RRC_Rel10[*]} ;; + Rel8 ) + echo "patching RRC files release 8 TODO?" + ;; * ) error unknwon/unhandled RRC version \'"$version"\' ;; From 9330a890dc89a6bc9c4d08fd5c3f1a771f4f3442 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 22 Feb 2016 16:14:13 +0100 Subject: [PATCH 04/21] Small fixes in CMakeLists.txt --- cmake_targets/CMakeLists.txt | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index c7058c1cff..b551df03d8 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -269,13 +269,16 @@ set (RRC_FULL_DIR ${asn1_generated_dir}/${RRC_ASN1_VERSION}) if(NOT EXISTS ${asn1c_call}) message( FATAL_ERROR "The script ${asn1c_call} must be present" ) endif(NOT EXISTS ${asn1c_call}) -execute_process(COMMAND ${asn1c_call} ${RRC_FULL_DIR} ${RRC_GRAMMAR}) +execute_process(COMMAND ${asn1c_call} ${RRC_FULL_DIR} ${RRC_GRAMMAR} + RESULT_VARIABLE ret) +if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${asn1c_call}: error") +endif (NOT ${ret} STREQUAL 0) if(NOT EXISTS ${fix_asn1c_call}) message( FATAL_ERROR "The script ${fix_asn1c_call} must be present" ) endif(NOT EXISTS ${fix_asn1c_call}) -execute_process( - COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION} - RESULT_VARIABLE ret) +execute_process(COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) @@ -321,15 +324,18 @@ set(S1AP_ASN_FILES ) set(S1AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) #message("calling ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}") -execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES} RESULT_VARIABLE ret) +execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) -execute_process(COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR} RESULT_VARIABLE ret) +execute_process(COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "asn1tostruct.py: error") endif (NOT ${ret} STREQUAL 0) -execute_process(COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} RESULT_VARIABLE ret) +execute_process(COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) @@ -400,15 +406,18 @@ set(X2AP_ASN_FILES set(X2AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR}) #message("calling ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}") -execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES} RESULT_VARIABLE ret) +execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) -execute_process(COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR} RESULT_VARIABLE ret) +execute_process(COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "asn1tostruct.py: error") endif (NOT ${ret} STREQUAL 0) -execute_process(COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} RESULT_VARIABLE ret) +execute_process(COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION} + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${fix_asn1c_call}: error") endif (NOT ${ret} STREQUAL 0) From 120369a6a0e8122e4cf8ffa562d7427d4776e8a4 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 22 Feb 2016 16:15:09 +0100 Subject: [PATCH 05/21] better logging in autotests --- cmake_targets/autotests/run_compilation_autotests.bash | 6 +++--- cmake_targets/tools/test_helper | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake_targets/autotests/run_compilation_autotests.bash b/cmake_targets/autotests/run_compilation_autotests.bash index afe7aa4873..a7b056dc81 100755 --- a/cmake_targets/autotests/run_compilation_autotests.bash +++ b/cmake_targets/autotests/run_compilation_autotests.bash @@ -20,7 +20,7 @@ test_compile() { compile_prog=$2 exec_prog=$3 build_dir=$tdir/$1/build - log_file=$tdir/log/test.$1.txt + log_file=$tdir/log/test.$1.$2.$5.txt target=$5 echo "Compiling test case $test_name. Log file = $log_file" rm -fr $build_dir @@ -34,10 +34,10 @@ test_compile() { if [ -s $exec_prog ] ; then cp $exec_prog $tdir/bin/`basename $exec_prog`.$target.$test_name echo_success "$test_name $exec_prog $target compiled" - xUnit_success "compilation" $test_name "PASS" 1 + xUnit_success "compilation" $test_name "PASS" 1 "$results_file" else echo_error "$test_name $exec_prog $target compilation failed" - xUnit_fail "compilation" $test_name "FAIL" 1 + xUnit_fail "compilation" $test_name "FAIL" 1 "$results_file" fi } diff --git a/cmake_targets/tools/test_helper b/cmake_targets/tools/test_helper index 49a9910573..cae0bacbe0 100644 --- a/cmake_targets/tools/test_helper +++ b/cmake_targets/tools/test_helper @@ -35,7 +35,7 @@ xUnit_fail() { currtime=$(date +%s.%N) time=$(echo "$currtime - $XUNIT_START" | bc -l) xml="" - echo -e $xml >> $xmlfile_testcase + echo -e "$xml" >> "$xmlfile_testcase" XUNIT_TESTCASES_XML="$XUNIT_TESTCASES_XML \n$xml" XUNIT_FAILED=$((XUNIT_FAILED+1)) } From 1657e0897c9b06d72195792917fadb0dc8768339 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 22 Feb 2016 17:48:31 +0100 Subject: [PATCH 06/21] Change the way we compute the sha1sum. Line 4 of *.h files depends on the directory containing openair; get rid of it. --- cmake_targets/tools/fix_asn1 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 index 42893e05c6..4c3940079a 100755 --- a/cmake_targets/tools/fix_asn1 +++ b/cmake_targets/tools/fix_asn1 @@ -1,21 +1,21 @@ #!/bin/bash # in those arrays, each line is: -# +# RRC_Rel10=( - "SystemInformation-r8-IEs.h" 819eda3db27516f7c6780d832fb3c462e2264ea7 "fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff" + "SystemInformation-r8-IEs.h" 603cd6615cff36ec7020692d72c0d6de7c4859cb "fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff" ) X2AP_Rel11_2=( - "X2ap-CriticalityDiagnostics-IE-List.h" f0e2414992bfacfbc4b9fd15c977241d6d7fabeb "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff" - "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" - "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" + "X2ap-CriticalityDiagnostics-IE-List.h" ae96308b37fcbcbf39da5012e42968135fc5f27b "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff" + "NativeInteger.c" f815a276f31ec54e03ed008d4f01faee579f00be "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" + "constr_SET_OF.c" aeae707ba2471104a862477eb0107f04f4793ff4 "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" ) S1AP_Rel10_5=( - "NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" - "constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" + "NativeInteger.c" f815a276f31ec54e03ed008d4f01faee579f00be "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" + "constr_SET_OF.c" aeae707ba2471104a862477eb0107f04f4793ff4 "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" ) red_color="$(tput setaf 1)" @@ -38,7 +38,12 @@ function check_sha1() error "$file: no such file" fi - local computed_sha1=$(sha1sum "$file" | cut -f 1 -d ' ') + # we don't use the line 4 of the file + # it contains the location of the ASN1 grammar + # and this location is not the same on every + # installation (this is for *.h files, for *.c + # files it's no big deal to skip that line) + local computed_sha1=$(sed 4d "$file" | sha1sum | cut -f 1 -d ' ') if [ "$target_sha1" != "$computed_sha1" ] then From ffd02335a428116355f6b8b55a5e51bf50f4be6d Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Wed, 23 Mar 2016 16:49:17 +0100 Subject: [PATCH 07/21] fixes to take into account new asn1 patch --- cmake_targets/tools/fix_asn1 | 8 ++++---- .../tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff | 4 ++-- .../tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 index 4c3940079a..dcc00d5e37 100755 --- a/cmake_targets/tools/fix_asn1 +++ b/cmake_targets/tools/fix_asn1 @@ -9,13 +9,13 @@ RRC_Rel10=( X2AP_Rel11_2=( "X2ap-CriticalityDiagnostics-IE-List.h" ae96308b37fcbcbf39da5012e42968135fc5f27b "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff" - "NativeInteger.c" f815a276f31ec54e03ed008d4f01faee579f00be "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" - "constr_SET_OF.c" aeae707ba2471104a862477eb0107f04f4793ff4 "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" + "NativeInteger.c" 9f173e87daa1e7378618dbb060a10aae752d74be "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" + "constr_SET_OF.c" 5c8765a1e0fc44a48e406d0aa7628004bf3aac2a "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" ) S1AP_Rel10_5=( - "NativeInteger.c" f815a276f31ec54e03ed008d4f01faee579f00be "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" - "constr_SET_OF.c" aeae707ba2471104a862477eb0107f04f4793ff4 "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" + "NativeInteger.c" 9f173e87daa1e7378618dbb060a10aae752d74be "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" + "constr_SET_OF.c" 5c8765a1e0fc44a48e406d0aa7628004bf3aac2a "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" ) red_color="$(tput setaf 1)" diff --git a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff index c1649fd6f7..3b51426ad3 100644 --- a/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff +++ b/cmake_targets/tools/fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff @@ -1,8 +1,8 @@ -282c282 +283c283 < int dynamic = 0; --- > //int dynamic = 0; -289c289 +290c290 < dynamic = 1; --- > //dynamic = 1; diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff index c1649fd6f7..3b51426ad3 100644 --- a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff +++ b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff @@ -1,8 +1,8 @@ -282c282 +283c283 < int dynamic = 0; --- > //int dynamic = 0; -289c289 +290c290 < dynamic = 1; --- > //dynamic = 1; From 8028652a71158149f0b3f5ac188f48bda7750428 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Fri, 25 Mar 2016 20:08:04 +0100 Subject: [PATCH 08/21] hotfix for enb/EPC local config file --- .../GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf index 3043256628..1ea7b64740 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf @@ -144,7 +144,6 @@ eNBs = ENB_INTERFACE_NAME_FOR_S1U = "eth0:4"; ENB_IPV4_ADDRESS_FOR_S1U = "192.170.1.2/24"; - ENB_IPV4_ADDRESS_FOR_S1U = "192.170.0.2/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; @@ -167,4 +166,4 @@ eNBs = }; } -); +); \ No newline at end of file From a56b0a1f702f85d04cfeeae4998148fed832b402 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 25 Mar 2016 22:14:54 +0100 Subject: [PATCH 09/21] clean liblfds (comment #pragma lines) --- .../src/lfds611_freelist/lfds611_freelist_new.c | 4 ++-- .../liblfds611/src/lfds611_queue/lfds611_queue_delete.c | 4 ++-- .../liblfds611/src/lfds611_queue/lfds611_queue_new.c | 8 ++++---- .../liblfds611/src/lfds611_queue/lfds611_queue_query.c | 4 ++-- .../src/lfds611_ringbuffer/lfds611_ringbuffer_new.c | 4 ++-- .../src/lfds611_ringbuffer/lfds611_ringbuffer_query.c | 4 ++-- .../liblfds611/src/lfds611_slist/lfds611_slist_new.c | 4 ++-- .../liblfds611/src/lfds611_stack/lfds611_stack_delete.c | 4 ++-- .../liblfds611/src/lfds611_stack/lfds611_stack_new.c | 8 ++++---- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c index 477887e76f..2eeae80097 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_freelist/lfds611_freelist_new.c @@ -48,7 +48,7 @@ int lfds611_freelist_new( struct lfds611_freelist_state **fs, lfds611_atom_t num /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_freelist_use( struct lfds611_freelist_state *fs ) { @@ -59,7 +59,7 @@ void lfds611_freelist_use( struct lfds611_freelist_state *fs ) return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c index 718cfe1ae9..a11b501e56 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_delete.c @@ -41,7 +41,7 @@ void lfds611_queue_delete( struct lfds611_queue_state *qs, void (*user_data_dele /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_queue_internal_freelist_delete_function( void *user_data, void *user_state ) { @@ -53,5 +53,5 @@ void lfds611_queue_internal_freelist_delete_function( void *user_data, void *use return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c index accc6c3769..7fec0a2e90 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_new.c @@ -46,7 +46,7 @@ int lfds611_queue_new( struct lfds611_queue_state **qs, lfds611_atom_t number_el /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_queue_use( struct lfds611_queue_state *qs ) { @@ -57,14 +57,14 @@ void lfds611_queue_use( struct lfds611_queue_state *qs ) return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) int lfds611_queue_internal_freelist_init_function( void **user_data, void *user_state ) { @@ -82,7 +82,7 @@ int lfds611_queue_internal_freelist_init_function( void **user_data, void *user_ return( rv ); } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c index 2a546dde39..504485d7b5 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_queue/lfds611_queue_query.c @@ -5,7 +5,7 @@ /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_queue_query( struct lfds611_queue_state *qs, enum lfds611_queue_query_type query_type, void *query_input, void *query_output ) { @@ -31,7 +31,7 @@ void lfds611_queue_query( struct lfds611_queue_state *qs, enum lfds611_queue_que return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c index 2fafe52a37..6d8dde2a54 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_new.c @@ -48,7 +48,7 @@ int lfds611_ringbuffer_new( struct lfds611_ringbuffer_state **rs, lfds611_atom_t /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_ringbuffer_use( struct lfds611_ringbuffer_state *rs ) { @@ -59,5 +59,5 @@ void lfds611_ringbuffer_use( struct lfds611_ringbuffer_state *rs ) return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c index ad3d56a788..11bf8b0b6e 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_ringbuffer/lfds611_ringbuffer_query.c @@ -5,7 +5,7 @@ /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_ringbuffer_query( struct lfds611_ringbuffer_state *rs, enum lfds611_ringbuffer_query_type query_type, void *query_input, void *query_output ) { @@ -26,7 +26,7 @@ void lfds611_ringbuffer_query( struct lfds611_ringbuffer_state *rs, enum lfds611 return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c index 7142694a67..b48e349ab0 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_slist/lfds611_slist_new.c @@ -31,7 +31,7 @@ int lfds611_slist_new( struct lfds611_slist_state **ss, void (*user_data_delete_ /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_slist_use( struct lfds611_slist_state *ss ) { @@ -42,7 +42,7 @@ void lfds611_slist_use( struct lfds611_slist_state *ss ) return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c index 6a79156a52..75700e6b39 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_delete.c @@ -51,7 +51,7 @@ void lfds611_stack_clear( struct lfds611_stack_state *ss, void (*user_data_clear /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_stack_internal_freelist_delete_function( void *user_data, void *user_state ) { @@ -63,5 +63,5 @@ void lfds611_stack_internal_freelist_delete_function( void *user_data, void *use return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) diff --git a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c index 820e51bcc5..927f28c88c 100644 --- a/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c +++ b/openair2/UTIL/LFDS/liblfds6.1.1/liblfds611/src/lfds611_stack/lfds611_stack_new.c @@ -42,7 +42,7 @@ int lfds611_stack_new( struct lfds611_stack_state **ss, lfds611_atom_t number_el /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) void lfds611_stack_use( struct lfds611_stack_state *ss ) { @@ -53,14 +53,14 @@ void lfds611_stack_use( struct lfds611_stack_state *ss ) return; } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) /****************************************************************************/ -#pragma warning( disable : 4100 ) +//#pragma warning( disable : 4100 ) int lfds611_stack_internal_freelist_init_function( void **user_data, void *user_state ) { @@ -78,7 +78,7 @@ int lfds611_stack_internal_freelist_init_function( void **user_data, void *user_ return( rv ); } -#pragma warning( default : 4100 ) +//#pragma warning( default : 4100 ) From 3f8c74caba1a7699f7b422472fa0ccef8520379b Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 25 Mar 2016 22:26:40 +0100 Subject: [PATCH 10/21] avoid duplicate #define --- common/utils/itti/memory_pools.c | 2 ++ openair1/PHY/defs.h | 10 ++++++---- openair2/COMMON/openair_defs.h | 8 +++++++- openair2/RRC/LITE/rrc_eNB_S1AP.c | 1 + openair2/UTIL/OMV/structures.h | 4 +++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/common/utils/itti/memory_pools.c b/common/utils/itti/memory_pools.c index dadc80ca2a..97ec7d8e38 100644 --- a/common/utils/itti/memory_pools.c +++ b/common/utils/itti/memory_pools.c @@ -54,7 +54,9 @@ uint64_t vcd_mp_free; #endif /*------------------------------------------------------------------------------*/ +#ifndef CHARS_TO_UINT32 #define CHARS_TO_UINT32(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4)) +#endif #define MEMORY_POOL_ITEM_INFO_NUMBER 2 diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 578b05634c..3c16ce0cd3 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -65,10 +65,12 @@ //use msg in the real-time thread context #define msg_nrt printf //use msg_nrt in the non real-time context (for initialization, ...) -#ifdef __AVX2__ -#define malloc16(x) memalign(32,x) -#else -#define malloc16(x) memalign(16,x) +#ifndef malloc16 +# ifdef __AVX2__ +# define malloc16(x) memalign(32,x) +# else +# define malloc16(x) memalign(16,x) +# endif #endif #define free16(y,x) free(y) #define bigmalloc malloc diff --git a/openair2/COMMON/openair_defs.h b/openair2/COMMON/openair_defs.h index 0a6b88ce33..c2dd4d0616 100755 --- a/openair2/COMMON/openair_defs.h +++ b/openair2/COMMON/openair_defs.h @@ -41,7 +41,13 @@ #if !defined (msg) # define msg(aRGS...) LOG_D(PHY, ##aRGS) #endif -#define malloc16(x) memalign(16,x) //malloc(x) +#ifndef malloc16 +# ifdef __AVX2__ +# define malloc16(x) memalign(32,x) +# else +# define malloc16(x) memalign(16,x) +# endif +#endif #define free16(y,x) free(y) #define bigmalloc malloc #define bigmalloc16 malloc16 diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index d93b8eea2f..375fc3e0cf 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -392,6 +392,7 @@ rrc_pdcp_config_security( #define DEBUG_SECURITY 1 #if defined (DEBUG_SECURITY) +#undef msg #define msg printf if (print_keys ==1 ) { diff --git a/openair2/UTIL/OMV/structures.h b/openair2/UTIL/OMV/structures.h index f3b2b69d73..6c131371cb 100755 --- a/openair2/UTIL/OMV/structures.h +++ b/openair2/UTIL/OMV/structures.h @@ -44,7 +44,9 @@ #define Maxneighbor 64 #define NUMBER_OF_UE_MAX 64 #define NUMBER_OF_eNB_MAX 3 -#define NB_ANTENNAS_RX 4 +#ifndef NB_ANTENNAS_RX +# define NB_ANTENNAS_RX 4 +#endif #endif // From 04eed3bd6e6a80fcd37d21f5172700a179633186 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 25 Mar 2016 23:58:58 +0100 Subject: [PATCH 11/21] remove "unused variable" and "set but not used" warnings --- cmake_targets/tools/fix_asn1 | 4 ++-- common/utils/collection/hashtable/hashtable.c | 1 - openair1/PHY/INIT/lte_init.c | 8 ++++---- openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c | 4 ++-- openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c | 2 +- openair1/SCHED/phy_mac_stub.c | 6 +++--- openair1/SCHED/phy_procedures_lte_eNb.c | 3 +++ openair1/SCHED/pucch_pc.c | 10 +++++----- openair2/ENB_APP/enb_config.c | 4 ++-- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 10 +++++----- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- openair2/LAYER2/MAC/pre_processor.c | 6 +++--- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 ++ openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 3 +++ openair2/LAYER2/RLC/rlc_rrc.c | 2 +- openair2/LAYER2/openair2_proc.c | 2 +- openair2/RRC/LITE/rrc_UE.c | 2 ++ openair2/RRC/LITE/rrc_common.c | 5 ++++- openair2/RRC/LITE/rrc_eNB.c | 14 +++++++------- openair2/RRC/LITE/rrc_eNB_GTPV1U.c | 1 + openair2/RRC/LITE/rrc_eNB_S1AP.c | 6 +++--- openair2/UTIL/OMG/common.c | 9 ++------- openair2/UTIL/OMG/omg.c | 2 +- openair2/UTIL/OMG/steadystaterwp.c | 6 +++--- openair2/UTIL/OMG/trace.c | 4 ++-- openair2/UTIL/OMG/trace_hashtable.c | 2 -- openair2/UTIL/OSA/osa_stream_eea.c | 2 -- openair3/GTPV1-U/gtpv1u_eNB.c | 7 ++++--- openair3/NAS/COMMON/IES/MsNetworkFeatureSupport.c | 4 ++-- openair3/NAS/UE/EMM/EmmStatusHdl.c | 2 +- openair3/NAS/UE/EMM/LowerLayer.c | 2 +- openair3/NAS/UE/EMM/SAP/emm_fsm.c | 2 +- openair3/NAS/UE/ESM/esm_ebr_context.c | 12 +++++++----- openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 | 6 ++---- openair3/S1AP/s1ap_eNB_handlers.c | 1 + openair3/SECU/nas_stream_eea1.c | 4 ++-- openair3/SECU/nas_stream_eia2.c | 1 + openair3/UDP/udp_eNB_task.c | 8 ++++---- targets/RT/USER/lte-softmodem.c | 11 ++++++----- targets/RT/USER/lte-ue.c | 2 +- 40 files changed, 96 insertions(+), 88 deletions(-) diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 index dcc00d5e37..5f182c8f7e 100755 --- a/cmake_targets/tools/fix_asn1 +++ b/cmake_targets/tools/fix_asn1 @@ -10,12 +10,12 @@ RRC_Rel10=( X2AP_Rel11_2=( "X2ap-CriticalityDiagnostics-IE-List.h" ae96308b37fcbcbf39da5012e42968135fc5f27b "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff" "NativeInteger.c" 9f173e87daa1e7378618dbb060a10aae752d74be "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" - "constr_SET_OF.c" 5c8765a1e0fc44a48e406d0aa7628004bf3aac2a "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" + "constr_SET_OF.c" 5352abd70c1784a0a2ef3c2e287b30ea3cdcf760 "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" ) S1AP_Rel10_5=( "NativeInteger.c" 9f173e87daa1e7378618dbb060a10aae752d74be "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" - "constr_SET_OF.c" 5c8765a1e0fc44a48e406d0aa7628004bf3aac2a "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" + "constr_SET_OF.c" 5352abd70c1784a0a2ef3c2e287b30ea3cdcf760 "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" ) red_color="$(tput setaf 1)" diff --git a/common/utils/collection/hashtable/hashtable.c b/common/utils/collection/hashtable/hashtable.c index d424e2a0ad..4ce0ee7a7e 100755 --- a/common/utils/collection/hashtable/hashtable.c +++ b/common/utils/collection/hashtable/hashtable.c @@ -177,7 +177,6 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char { hash_node_t *node = NULL; unsigned int i = 0; - unsigned int num_elements = 0; if (hashtblP == NULL) { *remaining_bytes_in_buffer_pP = snprintf( buffer_pP, diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index c819704bd2..8fcc33a6d2 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -128,8 +128,8 @@ void phy_config_sib2_eNB(uint8_t Mod_id, { LTE_DL_FRAME_PARMS *lte_frame_parms = &PHY_vars_eNB_g[Mod_id][CC_id]->lte_frame_parms; - LTE_eNB_UE_stats *eNB_UE_stats = PHY_vars_eNB_g[Mod_id][CC_id]->eNB_UE_stats; - int32_t rx_total_gain_eNB_dB = PHY_vars_eNB_g[Mod_id][CC_id]->rx_total_gain_eNB_dB; + //LTE_eNB_UE_stats *eNB_UE_stats = PHY_vars_eNB_g[Mod_id][CC_id]->eNB_UE_stats; + //int32_t rx_total_gain_eNB_dB = PHY_vars_eNB_g[Mod_id][CC_id]->rx_total_gain_eNB_dB; int i; LOG_D(PHY,"[eNB%d] CCid %d Frame %d: Applying radioResourceConfigCommon\n",Mod_id,CC_id,PHY_vars_eNB_g[Mod_id][CC_id]->proc[8].frame_tx); @@ -683,11 +683,11 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id, int CC_id) { - PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[Mod_id][CC_id]; + //PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[Mod_id][CC_id]; uint8_t UE_id = find_ue(rnti,PHY_vars_eNB_g[Mod_id][0]); struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; //struct RadioResourceConfigCommonSCell_r10 *physicalConfigCommonSCell_r10 = sCellToAddMod_r10->radioResourceConfigCommonSCell_r10; - PhysCellId_t physCellId_r10 = sCellToAddMod_r10->cellIdentification_r10->physCellId_r10; + //PhysCellId_t physCellId_r10 = sCellToAddMod_r10->cellIdentification_r10->physCellId_r10; ARFCN_ValueEUTRA_t dl_CarrierFreq_r10 = sCellToAddMod_r10->cellIdentification_r10->dl_CarrierFreq_r10; uint32_t carrier_freq_local; diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c index 14e1c18571..378832ccf7 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c @@ -50,13 +50,13 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *phy_vars_eNB, PHY_MEASUREMENTS_eNB *phy_measurements = &phy_vars_eNB->PHY_measurements_eNB[eNB_id]; int32_t *rb_mask = phy_vars_eNB->rb_mask_ul; - uint32_t aarx,rx_power_correction; + uint32_t aarx /* ,rx_power_correction */; uint32_t rb; int32_t *ul_ch; int32_t n0_power_tot; int len; int offset; - int Nsymb = (frame_parms->Ncp==NORMAL)?14:12; + //int Nsymb = (frame_parms->Ncp==NORMAL)?14:12; // noise measurements // for the moment we measure the noise on the 7th OFDM symbol (in S subframe) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c index 65c4214427..3bc26ad7e8 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ue_measurements.c @@ -572,7 +572,7 @@ void lte_ue_measurements(PHY_VARS_UE *phy_vars_ue, // skip the first 4 RE due to interpolation filter length of 5 (not possible to skip 5 due to 128i alignment, must be multiple of 128bit) #if defined(__x86_64__) || defined(__i386__) - __m128i pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1,mmtmpPMI2,mmtmpPMI3; + __m128i pmi128_re,pmi128_im,mmtmpPMI0,mmtmpPMI1 /* ,mmtmpPMI2,mmtmpPMI3 */ ; dl_ch0_128 = (__m128i *)&phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_id][aarx][4]; dl_ch1_128 = (__m128i *)&phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_id][2+aarx][4]; diff --git a/openair1/SCHED/phy_mac_stub.c b/openair1/SCHED/phy_mac_stub.c index 9bcba1072c..6e90960bfc 100644 --- a/openair1/SCHED/phy_mac_stub.c +++ b/openair1/SCHED/phy_mac_stub.c @@ -54,11 +54,11 @@ void fill_dci(DCI_PDU *DCI_pdu, uint8_t sched_subframe, PHY_VARS_eNB *phy_vars_e { int i; - uint8_t cooperation_flag = phy_vars_eNB->cooperation_flag; + //uint8_t cooperation_flag = phy_vars_eNB->cooperation_flag; uint8_t transmission_mode = phy_vars_eNB->transmission_mode[0]; uint32_t rballoc = 0x7FFF; - uint32_t rballoc2 = 0x000F; + //uint32_t rballoc2 = 0x000F; int subframe = phy_vars_eNB->proc[sched_subframe].subframe_tx; LTE_eNB_DLSCH_t *DLSCH_ptr = phy_vars_eNB->dlsch_eNB[0][0]; @@ -585,7 +585,7 @@ void fill_dci_emos(DCI_PDU *DCI_pdu, uint8_t subframe, PHY_VARS_eNB *phy_vars_eN { int i; - uint8_t cooperation_flag = phy_vars_eNB->cooperation_flag; + //uint8_t cooperation_flag = phy_vars_eNB->cooperation_flag; uint8_t transmission_mode = phy_vars_eNB->transmission_mode[0]; //uint32_t rballoc = 0x00F0; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 375c0dcd1f..4042cb511c 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1822,6 +1822,7 @@ void phy_procedures_eNB_TX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_e stop_meas(&phy_vars_eNB->phy_proc_tx); + (void)re_allocated; /* remove gcc warning "set but not used" */ } void process_Msg3(PHY_VARS_eNB *phy_vars_eNB,uint8_t sched_subframe,uint8_t UE_id, uint8_t harq_pid) @@ -2493,6 +2494,7 @@ void phy_procedures_eNB_RX(const unsigned char sched_subframe,PHY_VARS_eNB *phy_ } sect_id = 0; + (void)sect_id; /* remove gcc warning "set but not used" */ /* for (UE_id=0;UE_iddlsch_ue[eNB_id][0]->harq_ack[subframe].harq_id; + //if ((pucch_fmt == pucch_format1a) || + // (pucch_fmt == pucch_format1b)) { // Update g_pucch based on TPC/delta_PUCCH received in PDCCH for this process + //harq_pid = phy_vars_ue->dlsch_ue[eNB_id][0]->harq_ack[subframe].harq_id; //this is now done in dci_tools //phy_vars_ue->g_pucch[eNB_id] += phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->delta_PUCCH; - } + //} Po_PUCCH = get_PL(phy_vars_ue->Mod_id,phy_vars_ue->CC_id,eNB_id)+ phy_vars_ue->lte_frame_parms.ul_power_control_config_common.p0_NominalPUCCH+ diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index cc63eb8671..e96ef91326 100755 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -562,9 +562,9 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) const char* pusch_alpha = NULL; libconfig_int pucch_p0_Nominal = 0; libconfig_int msg3_delta_Preamble = 0; - libconfig_int ul_CyclicPrefixLength = 0; + //libconfig_int ul_CyclicPrefixLength = 0; const char* pucch_deltaF_Format1 = NULL; - const char* pucch_deltaF_Format1a = NULL; + //const char* pucch_deltaF_Format1a = NULL; const char* pucch_deltaF_Format1b = NULL; const char* pucch_deltaF_Format2 = NULL; const char* pucch_deltaF_Format2a = NULL; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 2a52d8779a..f7d109aa31 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1488,23 +1488,23 @@ fill_DLSCH_dci( // loop over all allocated UEs and compute frequency allocations for PDSCH int UE_id = -1; - uint8_t first_rb,nb_rb=3; + uint8_t /* first_rb, */ nb_rb=3; rnti_t rnti; - unsigned char *vrb_map; + //unsigned char *vrb_map; uint8_t rballoc_sub[25]; //uint8_t number_of_subbands=13; - unsigned char round; + //unsigned char round; unsigned char harq_pid; void *DLSCH_dci=NULL; DCI_PDU *DCI_pdu; int i; - void *BCCH_alloc_pdu; + //void *BCCH_alloc_pdu; int size_bits,size_bytes; int CC_id; eNB_MAC_INST *eNB =&eNB_mac_inst[module_idP]; UE_list_t *UE_list = &eNB->UE_list; - RA_TEMPLATE *RA_template; + //RA_TEMPLATE *RA_template; start_meas(&eNB->fill_DLSCH_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,VCD_FUNCTION_IN); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 9cabd6b622..79529c3284 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1082,7 +1082,7 @@ boolean_t CCE_allocation_infeasible(int module_idP, DCI_PDU *DCI_pdu = &eNB_mac_inst[module_idP].common_channels[CC_idP].DCI_pdu; - DCI_ALLOC_t *dci_alloc; + //DCI_ALLOC_t *dci_alloc; int ret; boolean_t res=FALSE; diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 410d454419..39c4aedb4d 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -751,7 +751,7 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, uint8_t *vrb_map = &eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; int RBGsize = PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.N_RB_DL/N_RBG; #ifdef SF05_LIMIT - int subframe05_limit=0; + //int subframe05_limit=0; int sf05_upper=-1,sf05_lower=-1; #endif LTE_eNB_UE_stats *eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,CC_id,rnti); @@ -1085,7 +1085,7 @@ void ulsch_scheduler_pre_processor(module_id_t module_idP, void store_ulsch_buffer(module_id_t module_idP, int frameP, sub_frame_t subframeP) { - int UE_id,pCC_id,lcgid; + int UE_id, /* pCC_id, */ lcgid; UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; UE_TEMPLATE *UE_template; @@ -1231,7 +1231,7 @@ void sort_ue_ul (module_id_t module_idP,int frameP, sub_frame_t subframeP) int UE_id1,UE_id2; int pCCid1,pCCid2; int round1,round2; - int i=0,ii=0,j=0; + int i=0,ii=0; rnti_t rnti1,rnti2; UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index f25e921570..a2dbf9d9b8 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1032,6 +1032,8 @@ pdcp_remove_UE( } + (void)h_rc; /* remove gcc warning "set but not used" */ + return 1; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index ec303172b0..b92340348a 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -599,6 +599,7 @@ rlc_am_mac_status_indication ( rlc_sn_t sn_end = (rlc->vt_a - 1) & RLC_AM_SN_MASK; int found_pdu = 0; rlc_sn_t found_pdu_sn = 0; // avoid warning + (void)found_pdu_sn; /* avoid gcc warning "set but not used" */ while (sn != sn_end) { @@ -917,6 +918,8 @@ rlc_am_mac_data_indication ( int octet_index, index; #endif + (void)l_rlc_p; /* avoid gcc warning "unused variable" */ + #if TRACE_RLC_AM_PDU || MESSAGE_CHART_GENERATOR if (data_indP.data.nb_elements > 0) { diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index 05ad79d7d4..50f4e4b9bd 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -634,7 +634,7 @@ rlc_op_status_t rrc_rlc_config_req ( const rlc_info_t rlc_infoP) { //----------------------------------------------------------------------------- - rlc_op_status_t status; + //rlc_op_status_t status; LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG_REQ for RAB %u\n", PROTOCOL_CTXT_ARGS(ctxt_pP), diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index 35684d239a..284f91a7f8 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -74,7 +74,7 @@ int dump_eNB_l2_stats(char *buffer, int length) int eNB_id,UE_id,number_of_cards; int len= length; int CC_id=0; - int i,j; + int i; protocol_ctxt_t ctxt; rlc_op_status_t rlc_status; unsigned int stat_rlc_mode; diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index a919a055f2..ee35f317cd 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -261,6 +261,7 @@ static void init_SI_UE( const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_ #ifdef Rel10 //----------------------------------------------------------------------------- +#if 0 static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) { int i; @@ -274,6 +275,7 @@ static void init_MCCH_UE(module_id_t ue_mod_idP, uint8_t eNB_index) } } #endif +#endif //----------------------------------------------------------------------------- static void openair_rrc_lite_ue_init_security( const protocol_ctxt_t* const ctxt_pP ) diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index e2d8a6c69b..2a37ccde00 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -411,7 +411,7 @@ rrc_rx_tx( ) //----------------------------------------------------------------------------- { - uint8_t UE_id; + //uint8_t UE_id; int32_t current_timestamp_ms, ref_timestamp_ms; struct timeval ts; #ifdef LOCALIZATION @@ -547,6 +547,9 @@ rrc_rx_tx( } #endif + (void)ts; /* remove gcc warning "unused variable" */ + (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */ + (void)current_timestamp_ms; /* remove gcc warning "unused variable" */ } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 1d0b5f2902..deab2d04a3 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -1131,8 +1131,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( int i; // configure SRB1/SRB2, PhysicalConfigDedicated, MAC_MainConfig for UE - eNB_RRC_INST* rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id]; - struct PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; + //eNB_RRC_INST* rrc_inst = &eNB_rrc_inst[ctxt_pP->module_id]; + //struct PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct SRB_ToAddMod *SRB2_config = NULL; struct SRB_ToAddMod__rlc_Config *SRB2_rlc_config = NULL; @@ -1145,7 +1145,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( struct DRB_ToAddMod *DRB_config = NULL; struct RLC_Config *DRB_rlc_config = NULL; struct PDCP_Config *DRB_pdcp_config = NULL; - struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; + //struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; struct LogicalChannelConfig *DRB_lchan_config = NULL; struct LogicalChannelConfig__ul_SpecificParameters @@ -1163,7 +1163,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( #if Rel10 long *sr_ProhibitTimer_r9 = NULL; // uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); - uint8_t sCellIndexToAdd = 0; + //uint8_t sCellIndexToAdd = 0; #endif long *logicalchannelgroup, *logicalchannelgroup_drb; @@ -2097,8 +2097,8 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( QuantityConfig_t *quantityConfig; MobilityControlInfo_t *mobilityInfo; // HandoverCommand_t handoverCommand; - uint8_t sourceModId = - get_adjacent_cell_mod_id(ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId); + //uint8_t sourceModId = + // get_adjacent_cell_mod_id(ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId); #if Rel10 long *sr_ProhibitTimer_r9; #endif @@ -3010,7 +3010,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( uint8_t *kUPenc = NULL; DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; - SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; + //SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; #if defined(ENABLE_SECURITY) diff --git a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c index b85933ad47..29ff0d9dc2 100755 --- a/openair2/RRC/LITE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LITE/rrc_eNB_GTPV1U.c @@ -86,6 +86,7 @@ rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( create_tunnel_resp_pP->num_tunnels, ue_context_p->ue_context.enb_gtp_ebi[0], ue_context_p->ue_context.enb_gtp_teid[0]); + (void)rnti; /* avoid gcc warning "set but not used" */ return 0; } else { return -1; diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 375fc3e0cf..b8b5aba4ae 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -672,7 +672,7 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( if (rrcConnectionSetupComplete->registeredMME != NULL) { /* Fill GUMMEI */ struct RegisteredMME *r_mme = rrcConnectionSetupComplete->registeredMME; - int selected_plmn_identity = rrcConnectionSetupComplete->selectedPLMN_Identity; + //int selected_plmn_identity = rrcConnectionSetupComplete->selectedPLMN_Identity; S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_gummei; @@ -859,7 +859,7 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char { uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; - MessageDef *message_gtpv1u_p = NULL; + //MessageDef *message_gtpv1u_p = NULL; gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; @@ -1170,7 +1170,7 @@ int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const ch */ { int e_rab; - int mod_id = 0; + //int mod_id = 0; MessageDef *msg_delete_tunnels_p = NULL; MSC_LOG_TX_MESSAGE( diff --git a/openair2/UTIL/OMG/common.c b/openair2/UTIL/OMG/common.c index dd12cb302a..d02ccf63ce 100644 --- a/openair2/UTIL/OMG/common.c +++ b/openair2/UTIL/OMG/common.c @@ -158,6 +158,7 @@ remove_node_entry (node_struct * node, node_list * node_vector) if (list->next->node->id == node->id) { toremove = tmp; // TODO delete the entry + (void)toremove; /* avoid gcc warning "set but not used" */ tmp = list->next->next; if (tmp != NULL) { @@ -259,13 +260,11 @@ node_list * remove_node (node_list * list, int nid, int node_type) { - int found; node_list *current = NULL, *previous = NULL; //int cond=0; //int i=0; if (list == NULL) { - found = 1; //false return NULL; } else { //start search @@ -280,12 +279,10 @@ remove_node (node_list * list, int nid, int node_type) //holds: current = NULL or type != node_type or.., but not both if (current == NULL) { - found = 1; LOG_E (OMG, " Element to remove is not found\n "); return NULL; } //value not found else { - found = 0; // true value found if (current == list) { list = current->next; @@ -322,7 +319,6 @@ node_struct * find_node (node_list * list, int nid, int node_type) { - int found; node_list *current; if (list == NULL) { @@ -340,7 +336,6 @@ find_node (node_list * list, int nid, int node_type) //holds: current = NULL or type != node_type or.., but not both if (current == NULL) { - found = 1; LOG_D (OMG, " Element to find in Node_Vector with ID: %d could not be found\n ", nid); @@ -380,7 +375,7 @@ node_list * reset_node_list (node_list * list) { node_list *tmp; - node_list *last = list; + //node_list *last = list; if (list == NULL) { //printf("Node_list is NULL\n"); diff --git a/openair2/UTIL/OMG/omg.c b/openair2/UTIL/OMG/omg.c index 11bdc62071..12b9395f75 100644 --- a/openair2/UTIL/OMG/omg.c +++ b/openair2/UTIL/OMG/omg.c @@ -301,7 +301,7 @@ set_new_mob_type (int id, int node_t, int mob_t, double cur_time) int prev_mob; node_list *tmp; - job_list *tmp2, *prev_job; + //job_list *tmp2, *prev_job; pair_struct *pair; double pause_p; diff --git a/openair2/UTIL/OMG/steadystaterwp.c b/openair2/UTIL/OMG/steadystaterwp.c index c466f3cd23..ba2e0d88f7 100644 --- a/openair2/UTIL/OMG/steadystaterwp.c +++ b/openair2/UTIL/OMG/steadystaterwp.c @@ -173,7 +173,7 @@ place_steadystaterwp_node (node_struct * node) void sleep_steadystaterwp_node (pair_struct * pair, double cur_time) { - static int initial = 1; + //static int initial = 1; node_struct *node; node = pair->b; node->mobile = 0; @@ -209,10 +209,10 @@ sleep_steadystaterwp_node (pair_struct * pair, double cur_time) void move_steadystaterwp_node (pair_struct * pair, double cur_time) { - static int initial = 1; + //static int initial = 1; double distance, journeytime_next, max_distance; double temp_x, temp_y, u1, u2; - int loc_num; + //int loc_num; double pr, block_xmin, block_ymin; //LOG_D (OMG, "[STEADY_RWP] move node: %d\n", node->ID); diff --git a/openair2/UTIL/OMG/trace.c b/openair2/UTIL/OMG/trace.c index 89a9377f93..144b9ae597 100644 --- a/openair2/UTIL/OMG/trace.c +++ b/openair2/UTIL/OMG/trace.c @@ -55,7 +55,7 @@ int start_trace_generator (omg_global_param omg_param_list) { double cur_time = 0.0; - int immobile = 0; + //int immobile = 0; int node_number; node_struct *node = NULL; mobility_struct *mobility = NULL; @@ -235,7 +235,7 @@ schedule_trace_node (pair_struct * pair, node_data * n_data, double cur_time) void sleep_trace_node (pair_struct * pair, node_data * n_data, double cur_time) { - double journeytime, distance; + //double journeytime, distance; node_struct *node = pair->b; node->mobile = 0; node->mob->speed = 0.0; diff --git a/openair2/UTIL/OMG/trace_hashtable.c b/openair2/UTIL/OMG/trace_hashtable.c index 2ecb392219..51f745de89 100644 --- a/openair2/UTIL/OMG/trace_hashtable.c +++ b/openair2/UTIL/OMG/trace_hashtable.c @@ -58,8 +58,6 @@ hash_table_t **table; void create_new_table (int node_type) { - int i; - if(table==NULL) table = (hash_table_t **) calloc (MAX_NUM_NODE_TYPES, sizeof (hash_table_t*)); diff --git a/openair2/UTIL/OSA/osa_stream_eea.c b/openair2/UTIL/OSA/osa_stream_eea.c index 0a044e2e01..8e346631ec 100644 --- a/openair2/UTIL/OSA/osa_stream_eea.c +++ b/openair2/UTIL/OSA/osa_stream_eea.c @@ -78,7 +78,6 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out) int n ; int i = 0; uint32_t zero_bit = 0; - uint32_t byte_length; uint32_t *KS; uint32_t K[4],IV[4]; @@ -89,7 +88,6 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out) n = ( stream_cipher->blength + 31 ) / 32; zero_bit = stream_cipher->blength & 0x7; - byte_length = stream_cipher->blength >> 3; memset(&snow_3g_context, 0, sizeof(snow_3g_context)); /*Initialisation*/ diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index ca492469b1..ff049ba1b4 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -673,7 +673,7 @@ gtpv1u_create_s1u_tunnel( teid_t s1u_teid = 0; gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL; gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL; - MessageDef *message_p = NULL; + //MessageDef *message_p = NULL; hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; int i; ebi_t eps_bearer_id = 0; @@ -996,7 +996,7 @@ void *gtpv1u_eNB_task(void *args) { int rc = 0; instance_t instance; - const char *msg_name_p; + //const char *msg_name_p; rc = gtpv1u_eNB_init(); AssertFatal(rc == 0, "gtpv1u_eNB_init Failed"); @@ -1014,7 +1014,7 @@ void *gtpv1u_eNB_task(void *args) DevAssert(received_message_p != NULL); instance = ITTI_MSG_INSTANCE(received_message_p); - msg_name_p = ITTI_MSG_NAME(received_message_p); + //msg_name_p = ITTI_MSG_NAME(received_message_p); switch (ITTI_MSG_ID(received_message_p)) { @@ -1081,6 +1081,7 @@ void *gtpv1u_eNB_task(void *args) LOG_E(GTPU, "nwGtpv1uGpduMsgNew failed: 0x%x\n", rc); MSC_LOG_EVENT(MSC_GTPU_ENB,"0 Failed send G-PDU ltid %u rtid %u size %u", enb_s1u_teid,sgw_s1u_teid,data_req_p->length); + (void)enb_s1u_teid; /* avoid gcc warning "set but not used" */ } else { rc = nwGtpv1uProcessUlpReq(gtpv1u_data_g.gtpv1u_stack, &stack_req); diff --git a/openair3/NAS/COMMON/IES/MsNetworkFeatureSupport.c b/openair3/NAS/COMMON/IES/MsNetworkFeatureSupport.c index d8efa5312b..08fee949a0 100644 --- a/openair3/NAS/COMMON/IES/MsNetworkFeatureSupport.c +++ b/openair3/NAS/COMMON/IES/MsNetworkFeatureSupport.c @@ -54,9 +54,9 @@ int decode_ms_network_feature_support(MsNetworkFeatureSupport *msnetworkfeatures } int encode_ms_network_feature_support(MsNetworkFeatureSupport *msnetworkfeaturesupport, uint8_t iei, uint8_t *buffer, uint32_t len) { - uint8_t *lenPtr; + //uint8_t *lenPtr; uint32_t encoded = 0; - int encode_result; + //int encode_result; /* Checking IEI and pointer */ CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, MS_NETWORK_FEATURE_SUPPORT_MINIMUM_LENGTH, len); #if defined (NAS_DEBUG) diff --git a/openair3/NAS/UE/EMM/EmmStatusHdl.c b/openair3/NAS/UE/EMM/EmmStatusHdl.c index 85d423fd23..126b2a94f6 100755 --- a/openair3/NAS/UE/EMM/EmmStatusHdl.c +++ b/openair3/NAS/UE/EMM/EmmStatusHdl.c @@ -130,7 +130,7 @@ int emm_proc_status(unsigned int ueid, int emm_cause) emm_sap_t emm_sap; emm_security_context_t *sctx = NULL; - struct emm_data_context_s *ctx = NULL; + //struct emm_data_context_s *ctx = NULL; LOG_TRACE(INFO,"EMM-PROC - EMM status procedure requested"); diff --git a/openair3/NAS/UE/EMM/LowerLayer.c b/openair3/NAS/UE/EMM/LowerLayer.c index 130fe1bb5d..6e264d2a54 100755 --- a/openair3/NAS/UE/EMM/LowerLayer.c +++ b/openair3/NAS/UE/EMM/LowerLayer.c @@ -261,7 +261,7 @@ int lowerlayer_data_req(unsigned int ueid, const OctetString *data) int rc; emm_sap_t emm_sap; emm_security_context_t *sctx = NULL; - struct emm_data_context_s *ctx = NULL; + //struct emm_data_context_s *ctx = NULL; emm_sap.primitive = EMMAS_DATA_REQ; emm_sap.u.emm_as.u.data.guti = _emm_data.guti; diff --git a/openair3/NAS/UE/EMM/SAP/emm_fsm.c b/openair3/NAS/UE/EMM/SAP/emm_fsm.c index 83c5e5f1db..dc0e1efa28 100755 --- a/openair3/NAS/UE/EMM/SAP/emm_fsm.c +++ b/openair3/NAS/UE/EMM/SAP/emm_fsm.c @@ -215,7 +215,7 @@ emm_fsm_state_t _emm_fsm_status[EMM_FSM_NB_UE_MAX]; ***************************************************************************/ void emm_fsm_initialize(void) { - int ueid; + //int ueid; LOG_FUNC_IN; _emm_fsm_status[0] = EMM_NULL; diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c index fcf278a2e4..f56a19b876 100755 --- a/openair3/NAS/UE/ESM/esm_ebr_context.c +++ b/openair3/NAS/UE/ESM/esm_ebr_context.c @@ -114,7 +114,7 @@ int esm_ebr_context_create( int bid = 0; esm_data_context_t *esm_ctx = NULL; esm_pdn_t *pdn = NULL; - unsigned int ueid = 0; + //unsigned int ueid = 0; LOG_FUNC_IN; @@ -212,7 +212,7 @@ int esm_ebr_context_create( { char *tmp = NULL; char ipv4_addr[INET_ADDRSTRLEN]; - char ipv6_addr[INET6_ADDRSTRLEN]; + //char ipv6_addr[INET6_ADDRSTRLEN]; char *netmask = NULL; char broadcast[INET_ADDRSTRLEN]; struct in_addr in_addr; @@ -221,7 +221,8 @@ int esm_ebr_context_create( switch (pdn->type) { case NET_PDN_TYPE_IPV4V6: - ipv6_addr[0] = pdn->ip_addr[4]; + //ipv6_addr[0] = pdn->ip_addr[4]; + /* TODO? */ // etc case NET_PDN_TYPE_IPV4: @@ -283,11 +284,12 @@ int esm_ebr_context_create( res = sprintf(command_line, "ifconfig oip1 %s netmask %s broadcast %s up", ipv4_addr, netmask, broadcast); + (void)res; /* avoid gcc warning "set but not used" */ // AssertFatal((res > 0) && (res < 128), // "error in system command line"); LOG_TRACE(INFO, "ESM-PROC - executing %s ", command_line); - system(command_line); + if (system(command_line)) ; /* TODO: what to do? */ break; case NET_PDN_TYPE_IPV6: @@ -341,7 +343,7 @@ int esm_ebr_context_release( esm_pdn_t *pdn = NULL; esm_data_context_t *esm_ctx; - unsigned int ueid = 0; + //unsigned int ueid = 0; LOG_FUNC_IN; diff --git a/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 b/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 index 3986a6a83b..b3517fd2d4 100644 --- a/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 +++ b/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 @@ -392,14 +392,13 @@ } --- skeletons/constr_SEQUENCE.c 2015-12-08 14:39:33.346543533 +0100 +++ skeletons/constr_SEQUENCE.c 2015-12-08 10:39:52.442558000 +0100 -@@ -1761,3 +1761,66 @@ +@@ -1761,3 +1761,65 @@ _ASN_ENCODED_OK(er); } + +asn_comp_rval_t * SEQUENCE_compare(asn_TYPE_descriptor_t *td1, void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) { + int edx; -+ int ret; + asn_comp_rval_t *res = NULL; + asn_comp_rval_t *res2 = NULL; + @@ -563,7 +562,7 @@ * Some handy helpers. * --- skeletons/constr_SET_OF.c 2015-12-08 14:39:33.338543533 +0100 +++ skeletons/constr_SET_OF.c 2015-12-08 10:45:54.466557000 +0100 -@@ -1039,3 +1039,55 @@ +@@ -1039,3 +1039,54 @@ rv.consumed = 0; return rv; } @@ -575,7 +574,6 @@ + asn_TYPE_member_t *elm2 = td2->elements; + const asn_anonymous_set_ *list1 = _A_CSET_FROM_VOID(sptr1); + const asn_anonymous_set_ *list2 = _A_CSET_FROM_VOID(sptr2); -+ int ret; + int i; + asn_comp_rval_t *res = NULL; + asn_comp_rval_t *res2 = NULL; diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 6f0d4128c7..3e6b2ebe7c 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -864,6 +864,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, case S1ap_UE_S1AP_IDs_PR_mME_UE_S1AP_ID: mme_ue_s1ap_id = ueContextReleaseCommand_p->uE_S1AP_IDs.choice.mME_UE_S1AP_ID; S1AP_ERROR("TO DO mapping mme_ue_s1ap_id enb_ue_s1ap_id"); + (void)mme_ue_s1ap_id; /* TODO: remove - it's to remove gcc warning about unused var */ case S1ap_UE_S1AP_IDs_PR_NOTHING: default: diff --git a/openair3/SECU/nas_stream_eea1.c b/openair3/SECU/nas_stream_eea1.c index 4b69ae8231..142df9e0dc 100755 --- a/openair3/SECU/nas_stream_eea1.c +++ b/openair3/SECU/nas_stream_eea1.c @@ -49,7 +49,7 @@ int nas_stream_encrypt_eea1(nas_stream_cipher_t *stream_cipher, uint8_t *out) int n ; int i = 0; uint32_t zero_bit = 0; - uint32_t byte_length; + //uint32_t byte_length; uint32_t *KS; uint32_t K[4],IV[4]; @@ -60,7 +60,7 @@ int nas_stream_encrypt_eea1(nas_stream_cipher_t *stream_cipher, uint8_t *out) n = ( stream_cipher->blength + 31 ) / 32; zero_bit = stream_cipher->blength & 0x7; - byte_length = stream_cipher->blength >> 3; + //byte_length = stream_cipher->blength >> 3; memset(&snow_3g_context, 0, sizeof(snow_3g_context)); /*Initialisation*/ diff --git a/openair3/SECU/nas_stream_eia2.c b/openair3/SECU/nas_stream_eia2.c index f1f64dd90a..4841dfc90b 100644 --- a/openair3/SECU/nas_stream_eia2.c +++ b/openair3/SECU/nas_stream_eia2.c @@ -112,6 +112,7 @@ int nas_stream_encrypt_eia2(nas_stream_cipher_t *stream_cipher, uint8_t out[4]) cmac_ctx = CMAC_CTX_new(); ret = CMAC_Init(cmac_ctx, stream_cipher->key, stream_cipher->key_length, cipher, NULL); ret = CMAC_Update(cmac_ctx, m, m_length + 8); + (void)ret; /* avoid gcc warning "set but not used" */ CMAC_Final(cmac_ctx, data, &size); CMAC_CTX_free(cmac_ctx); diff --git a/openair3/UDP/udp_eNB_task.c b/openair3/UDP/udp_eNB_task.c index 3e53f9f62f..d2a73d9b95 100644 --- a/openair3/UDP/udp_eNB_task.c +++ b/openair3/UDP/udp_eNB_task.c @@ -300,8 +300,8 @@ void *udp_eNB_task(void *args_p) int nb_events; struct epoll_event *events; MessageDef *received_message_p = NULL; - const char *msg_name = NULL; - instance_t instance = 0; + //const char *msg_name = NULL; + //instance_t instance = 0; udp_enb_init(NULL); itti_mark_task_ready(TASK_UDP); @@ -316,8 +316,8 @@ void *udp_eNB_task(void *args_p) if (received_message_p != NULL) { - msg_name = ITTI_MSG_NAME (received_message_p); - instance = ITTI_MSG_INSTANCE (received_message_p); + //msg_name = ITTI_MSG_NAME (received_message_p); + //instance = ITTI_MSG_INSTANCE (received_message_p); switch (ITTI_MSG_ID(received_message_p)) { case UDP_INIT: { diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 7df20f05c8..c111e76879 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1276,7 +1276,7 @@ static void* eNB_thread_rx( void* param ) FILE *rx_time_file; char rx_time_name[101]; - int i; + //int i; if (opp_enabled == 1){ snprintf(rx_time_name, 100,"/tmp/%s_rx_time_thread_sf_%d", "eNB", proc->subframe); @@ -3225,10 +3225,11 @@ int main( int argc, char **argv ) if (input_fd) { printf("Reading in from file to antenna buffer %d\n",0); - fread(UE[0]->lte_ue_common_vars.rxdata[0], - sizeof(int32_t), - frame_parms[0]->samples_per_tti*10, - input_fd); + if (fread(UE[0]->lte_ue_common_vars.rxdata[0], + sizeof(int32_t), + frame_parms[0]->samples_per_tti*10, + input_fd) != frame_parms[0]->samples_per_tti*10) + printf("error reading from file\n"); } //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; } else { diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index e72b4ec80a..4acb7e7a5f 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -607,7 +607,7 @@ static void *UE_thread_synch(void *arg) static void *UE_thread_tx(void *arg) { static int UE_thread_tx_retval; - int ret; + //int ret; PHY_VARS_UE *UE = (PHY_VARS_UE*)arg; From 77363df00bd7874f3182b6df417bea58e0523db0 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sat, 26 Mar 2016 22:52:19 +0100 Subject: [PATCH 12/21] remove #warning lines (comment them out) --- openair1/PHY/INIT/lte_init.c | 2 +- openair1/SCHED/pusch_pc.c | 2 +- openair2/LAYER2/MAC/config.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_mch.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 +- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c | 4 ++-- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c | 2 +- openair2/LAYER2/RLC/rlc_rrc.c | 2 +- openair2/RRC/LITE/rrc_eNB.c | 10 +++++----- openair2/RRC/LITE/rrc_eNB_S1AP.c | 2 +- openair2/UTIL/OTG/otg_rx.c | 2 +- openair3/GTPV1-U/gtpv1u.h | 2 +- openair3/GTPV1-U/gtpv1u_eNB.c | 4 ++-- openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c | 2 +- openair3/NAS/COMMON/API/NETWORK/nas_message.c | 2 +- openair3/NAS/COMMON/EMM/MSG/AttachAccept.c | 4 ++-- openair3/NAS/COMMON/IES/UeNetworkCapability.c | 4 ++-- openair3/NAS/UE/API/USIM/usim_api.c | 2 +- openair3/S1AP/s1ap_eNB_handlers.c | 2 +- openair3/S1AP/s1ap_eNB_nas_procedures.c | 4 ++-- openair3/SCTP/sctp_eNB_task.c | 2 +- 22 files changed, 31 insertions(+), 31 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 8fcc33a6d2..1f98a0eecc 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -733,7 +733,7 @@ void phy_config_dedicated_scell_eNB(uint8_t Mod_id, } if (physicalConfigDedicatedSCell_r10) { -#warning " phy_vars_eNB->physicalConfigDedicatedSCell_r10 does not exist in phy_vars_eNB" +//#warning " phy_vars_eNB->physicalConfigDedicatedSCell_r10 does not exist in phy_vars_eNB" // phy_vars_eNB->physicalConfigDedicatedSCell_r10[UE_id] = physicalConfigDedicatedSCell_r10; LOG_I(PHY,"[eNB %d] Frame %d: Configured phyConfigDedicatedSCell with CC_id %d for UE %d\n",Mod_id,/*phy_vars_eNB->frame*/0,CC_id,UE_id); } else { diff --git a/openair1/SCHED/pusch_pc.c b/openair1/SCHED/pusch_pc.c index 2af8771afe..5fb1f7449c 100644 --- a/openair1/SCHED/pusch_pc.c +++ b/openair1/SCHED/pusch_pc.c @@ -81,7 +81,7 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *phy_vars_eNB,uint8_t UE_id, //(phy_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->control_only == 1) ? phy_vars_eNB->ulsch_eNB[UE_id]->beta_offset_cqi_times8:8; DevAssert( UE_id < NUMBER_OF_UE_MAX ); -#warning "This condition happens sometimes. Need more investigation" // navid +//#warning "This condition happens sometimes. Need more investigation" // navid //DevAssert( MPR_x100/6 < 100 ); if (phy_vars_eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index e3f6d8e78c..608a67c18a 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -275,7 +275,7 @@ rrc_mac_config_req( if (eNB_flagP==1) { mac_xface->phy_config_dedicated_scell_eNB(Mod_id,UE_RNTI(Mod_id,UE_id),sCellToAddMod_r10,1); } else { -#warning "phy_config_dedicated_scell_ue is empty" +//#warning "phy_config_dedicated_scell_ue is empty" mac_xface->phy_config_dedicated_scell_ue(Mod_id,eNB_index,sCellToAddMod_r10,1); UE_mac_inst[Mod_id].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0 } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index f7d109aa31..4d8e32b63c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -1125,7 +1125,7 @@ schedule_ue_spec( if (frame_parms[CC_id]->frame_type == TDD) { UE_list->UE_template[CC_id][UE_id].DAI++; // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,UE_id,UE_list->UE_template[CC_id][UE_id].DAI); -#warning only for 5MHz channel +//#warning only for 5MHz channel update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index e894f3a662..a6926e15ad 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -666,7 +666,7 @@ MCH_PDU *get_mch_sdu(module_id_t module_idP, int CC_id, frame_t frameP, sub_fram { // eNB_mac_inst[module_idP].MCH_pdu.mcs=0; //LOG_D(MAC," MCH_pdu.mcs is %d\n", eNB_mac_inst[module_idP].MCH_pdu.mcs); -#warning "MCH pdu should take the CC_id index" +//#warning "MCH pdu should take the CC_id index" return(&eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu); } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index a2dbf9d9b8..638c8051b0 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1488,7 +1488,7 @@ pdcp_config_req_asn1 ( case CONFIG_ACTION_REMOVE: DevAssert(pdcp_pP != NULL); -#warning "TODO pdcp_module_id_to_rnti" +//#warning "TODO pdcp_module_id_to_rnti" //pdcp_module_id_to_rnti[ctxt_pP.module_id ][dst_id] = NOT_A_RNTI; LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_REMOVE LCID %d RBID %d configured\n", PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index eb2d0c5aca..81645f06fe 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -57,7 +57,7 @@ rlc_am_init( pthread_mutex_init(&rlc_pP->lock_input_sdus, NULL); rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); -#warning "cast the rlc retrans buffer to uint32" +//#warning "cast the rlc retrans buffer to uint32" // rlc_pP->pdu_retrans_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); rlc_pP->pdu_retrans_buffer = calloc(1, (uint32_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof( rlc_am_tx_data_pdu_management_t))); @@ -114,7 +114,7 @@ rlc_am_reestablish( LOG_D(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[AM REESTABLISH] RE-INIT STATE VARIABLES, BUFFERS, LISTS\n", PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP)); -#warning TODO when possible reassemble RLC SDUs from any byte segments of AMD PDUs with SN inf VR(MR) +//#warning TODO when possible reassemble RLC SDUs from any byte segments of AMD PDUs with SN inf VR(MR) list2_free(&rlc_pP->receiver_buffer); list_free(&rlc_pP->pdus_to_mac_layer); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index e2dda28f95..18ff9a8ad4 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -516,7 +516,7 @@ void rlc_am_segment_10 ( pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; -#warning "why 3000: changed to RLC_SDU_MAX_SIZE " +//#warning "why 3000: changed to RLC_SDU_MAX_SIZE " assert(pdu_tb_req_p->tb_size < RLC_SDU_MAX_SIZE ); rlc_am_pdu_polling(ctxt_pP, rlc_pP, pdu_p, pdu_mngt_p->payload_size); diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index 50f4e4b9bd..f78cf90631 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -196,7 +196,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP break; case SRB_ToAddMod__rlc_Config_PR_defaultValue: -#warning TO DO SRB_ToAddMod__rlc_Config_PR_defaultValue +//#warning TO DO SRB_ToAddMod__rlc_Config_PR_defaultValue if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) { config_req_rlc_um_asn1( ctxt_pP, diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index deab2d04a3..5d7c99a586 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -2945,7 +2945,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.buf = buffer; handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.size = size; */ -#warning "COMPILATION PROBLEM" +//#warning "COMPILATION PROBLEM" #ifdef PROBLEM_COMPILATION_RESOLVED if (sourceModId != 0xFF) { @@ -3700,7 +3700,7 @@ rrc_eNB_decode_ccch( * the current one must be removed from MAC/PHY (zombie UE) */ if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { -#warning "TODO: random_exist: remove UE from MAC/PHY (how?)" +//#warning "TODO: random_exist: remove UE from MAC/PHY (how?)" // AssertFatal(0 == 1, "TODO: remove UE from MAC/PHY (how?)"); ue_context_p = NULL; } else { @@ -3713,7 +3713,7 @@ rrc_eNB_decode_ccch( m_tmsi_t m_tmsi = BIT_STRING_to_uint32(&s_TMSI.m_TMSI); random_value = (((uint64_t)mme_code) << 32) | m_tmsi; if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) { -#warning "TODO: stmsi_exist: remove UE from MAC/PHY (how?)" +//#warning "TODO: stmsi_exist: remove UE from MAC/PHY (how?)" // AssertFatal(0 == 1, "TODO: remove UE from MAC/PHY (how?)"); ue_context_p = NULL; } else { @@ -4175,7 +4175,7 @@ rrc_eNB_decode_dcch( // cancel the security mode in PDCP // followup with the remaining procedure -#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure" +//#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure" rrc_eNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); break; @@ -4443,7 +4443,7 @@ rrc_enb_task( //SPECTRA: Add the RRC connection reconfiguration with Second cell configuration case RRC_RAL_CONNECTION_RECONFIGURATION_REQ: // ue_mod_id = 0; /* TODO force ue_mod_id to first UE, NAS UE not virtualized yet */ -#warning "TODO GET RIGHT RNTI" +//#warning "TODO GET RIGHT RNTI" PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index b8b5aba4ae..679e629f16 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -233,7 +233,7 @@ rrc_eNB_get_ue_context_from_s1ap_ids( static e_SecurityAlgorithmConfig__cipheringAlgorithm rrc_eNB_select_ciphering(uint16_t algorithms) { -#warning "Forced return SecurityAlgorithmConfig__cipheringAlgorithm_eea0, to be deleted in future" +//#warning "Forced return SecurityAlgorithmConfig__cipheringAlgorithm_eea0, to be deleted in future" return SecurityAlgorithmConfig__cipheringAlgorithm_eea0; if (algorithms & S1AP_ENCRYPTION_EEA2_MASK) { diff --git a/openair2/UTIL/OTG/otg_rx.c b/openair2/UTIL/OTG/otg_rx.c index 8331dd8477..3f0d35d223 100644 --- a/openair2/UTIL/OTG/otg_rx.c +++ b/openair2/UTIL/OTG/otg_rx.c @@ -113,7 +113,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff dst_instance = otg_hdr_rx->dst_instance; if (dst_instance != dst_instanceP) { -#warning "LG: TODO think about multicast traffic" +//#warning "LG: TODO think about multicast traffic" LOG_W(OTG,"[SRC %d][DST %d] [FLOW_idx %d][APP TYPE %d] RX INFO pkt at time %d: flag 0x %x, seq number %d, tx time %d, size (hdr %d, pdcp %d) not for dest instance %u\n", dst_instanceP); } diff --git a/openair3/GTPV1-U/gtpv1u.h b/openair3/GTPV1-U/gtpv1u.h index 264fedfe77..e2af712f7b 100644 --- a/openair3/GTPV1-U/gtpv1u.h +++ b/openair3/GTPV1-U/gtpv1u.h @@ -54,7 +54,7 @@ # define GTPU_ERROR(x, args...) fprintf(stderr, "[GTPU][E]"x, ##args) #endif -#warning "TO BE REFINED" +//#warning "TO BE REFINED" # define GTPU_HEADER_OVERHEAD_MAX 64 uint32_t gtpv1u_new_teid(void); diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index ff049ba1b4..9f2475ef37 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -333,7 +333,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( gtpv1u_teid_data_p->eps_bearer_id); #endif -#warning "LG eps bearer mapping to DRB id to do (offset -4)" +//#warning "LG eps bearer mapping to DRB id to do (offset -4)" PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gtpv1u_teid_data_p->enb_id, ENB_FLAG_YES, gtpv1u_teid_data_p->ue_id, 0, 0,gtpv1u_teid_data_p->enb_id); MSC_LOG_TX_MESSAGE( @@ -611,7 +611,7 @@ gtpv1u_new_data_req( if (bearer_p->state != BEARER_UP) { LOG_W(GTPU, "Trying to send data over bearer with state(%u) != BEARER_UP\n", bearer_p->state); -#warning LG: HACK WHILE WAITING FOR NAS, normally return -1 +//#warning LG: HACK WHILE WAITING FOR NAS, normally return -1 if (bearer_p->state != BEARER_IN_CONFIG) return -1; diff --git a/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c b/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c index 5308c0c86c..f00441dfa2 100644 --- a/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c +++ b/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c @@ -630,7 +630,7 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, bufLen = sizeof(NwGtpv1uIeTv1T)+ ((NwGtpv1uMsgT*)hMsg)->msgLen; -#warning CROUX DIRTY +16, TO BE FIXED!!! +//#warning CROUX DIRTY +16, TO BE FIXED!!! /* the +16 is there because by analyzing memory allocation with some external * tool, I saw that there were 6 bytes accessed after bufLen in nwGtpv1uCreateAndSendMsg * the value "16" has been chosen arbitrarily, just bigger than 6 diff --git a/openair3/NAS/COMMON/API/NETWORK/nas_message.c b/openair3/NAS/COMMON/API/NETWORK/nas_message.c index a7e5802765..ece3ced5a3 100644 --- a/openair3/NAS/COMMON/API/NETWORK/nas_message.c +++ b/openair3/NAS/COMMON/API/NETWORK/nas_message.c @@ -323,7 +323,7 @@ int nas_message_decrypt( #if defined(NAS_MME) LOG_FUNC_RETURN (TLV_DECODE_MAC_MISMATCH); #else -#warning "added test on integrity algorithm because of SECURITY_MODE_COMMAND not correctly handled in UE (check integrity)" +//#warning "added test on integrity algorithm because of SECURITY_MODE_COMMAND not correctly handled in UE (check integrity)" if (emm_security_context->selected_algorithms.integrity != NAS_SECURITY_ALGORITHMS_EIA0) { diff --git a/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c b/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c index 3d800d5c19..c7e4c36614 100644 --- a/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c +++ b/openair3/NAS/COMMON/EMM/MSG/AttachAccept.c @@ -214,7 +214,7 @@ int encode_attach_accept(attach_accept_msg *attach_accept, uint8_t *buffer, uint *(buffer + encoded) = (encode_u8_eps_attach_result(&attach_accept->epsattachresult) & 0x0f); encoded++; -#warning "LG TEST override t3412value" +//#warning "LG TEST override t3412value" attach_accept->t3412value.unit = GPRS_TIMER_UNIT_360S; attach_accept->t3412value.timervalue = 10; @@ -288,7 +288,7 @@ int encode_attach_accept(attach_accept_msg *attach_accept, uint8_t *buffer, uint encoded += encode_result; } -#warning "LG TEST override t3402value" +//#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; diff --git a/openair3/NAS/COMMON/IES/UeNetworkCapability.c b/openair3/NAS/COMMON/IES/UeNetworkCapability.c index 41393e7689..902bd1c79c 100644 --- a/openair3/NAS/COMMON/IES/UeNetworkCapability.c +++ b/openair3/NAS/COMMON/IES/UeNetworkCapability.c @@ -81,7 +81,7 @@ int decode_ue_network_capability(UeNetworkCapability *uenetworkcapability, uint8 LOG_TRACE(INFO, "uenetworkcapability decoded GPRS\n"); } -#warning "Force GPRS present if UMTS present" +//#warning "Force GPRS present if UMTS present" uenetworkcapability->gprs_present =1; } } @@ -131,7 +131,7 @@ int encode_ue_network_capability(UeNetworkCapability *uenetworkcapability, uint8 } if (uenetworkcapability->gprs_present) { -#warning "Force gea to 0x60" +//#warning "Force gea to 0x60" *(buffer + encoded) = 0x00 | 0x60; ////((uenetworkcapability->spare & 0x7) << 5) | // spare coded as zero //((uenetworkcapability->csfb & 0x1) << 4) | diff --git a/openair3/NAS/UE/API/USIM/usim_api.c b/openair3/NAS/UE/API/USIM/usim_api.c index 64bc05d0c3..8a7a26de0d 100644 --- a/openair3/NAS/UE/API/USIM/usim_api.c +++ b/openair3/NAS/UE/API/USIM/usim_api.c @@ -289,7 +289,7 @@ int usim_api_authenticate(const OctetString* rand_pP, const OctetString* autn_pP #define USIM_API_SQN_MS_SIZE 3 for (i = 0; i < USIM_API_SQN_MS_SIZE; i++) { -#warning "LG:BUG HERE TODO" +//#warning "LG:BUG HERE TODO" sqn_ms[USIM_API_SQNMS_SIZE - i] = ((uint8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQN_MS_SIZE - i]; } diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 3e6b2ebe7c..fb9722dbc8 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -859,7 +859,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, break; -#warning "TODO mapping mme_ue_s1ap_id enb_ue_s1ap_id?" +//#warning "TODO mapping mme_ue_s1ap_id enb_ue_s1ap_id?" case S1ap_UE_S1AP_IDs_PR_mME_UE_S1AP_ID: mme_ue_s1ap_id = ueContextReleaseCommand_p->uE_S1AP_IDs.choice.mME_UE_S1AP_ID; diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index 0cd4c08cb1..dbe0fef091 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -191,7 +191,7 @@ int s1ap_eNB_handle_nas_first_req( * The cell identity is defined on 28 bits but as we use macro enb id, * we have to pad. */ -#warning "TODO get cell id from RRC" +//#warning "TODO get cell id from RRC" MACRO_ENB_ID_TO_CELL_IDENTITY(instance_p->eNB_id, 0, // Cell ID &initial_ue_message_p->eutran_cgi.cell_ID); @@ -400,7 +400,7 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ s1ap_eNB_instance_p->mnc_digit_length, &uplink_NAS_transport_p->eutran_cgi.pLMNidentity); -#warning "TODO get cell id from RRC" +//#warning "TODO get cell id from RRC" MACRO_ENB_ID_TO_CELL_IDENTITY(s1ap_eNB_instance_p->eNB_id, 0, &uplink_NAS_transport_p->eutran_cgi.cell_ID); diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index 357803ac4f..6812c6bce3 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -148,7 +148,7 @@ sctp_handle_new_association_req( DevAssert(sctp_new_association_req_p != NULL); /* Create new socket with IPv6 affinity */ -#warning "SCTP may Force IPv4 only, here" +//#warning "SCTP may Force IPv4 only, here" #ifdef NO_VIRTUAL_MACHINE // in init chunk appears a list of host addresses, IPv4 and IPv4 in an arbitrary (unsorted) order From 544da9f598b5af0b4471bf5c949368fe14c77c22 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sat, 26 Mar 2016 22:57:45 +0100 Subject: [PATCH 13/21] remove warnings from rt_wrapper.c --- targets/RT/USER/rt_wrapper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index 0242dab3d8..a011cf8dfe 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -38,6 +38,10 @@ * \warning */ +#include +#include +#include + #include "rt_wrapper.h" static int latency_target_fd = -1; static int32_t latency_target_value = 0; @@ -154,6 +158,7 @@ int fill_modeled_runtime_table(uint16_t runtime_phy_rx[29][6], runtime_phy_tx[i][j] = cell_processing_dl[j] + platform_processing_dl + user_processing_dl_err[j] + user_processing_dl_a[j]*i+ user_processing_dl_b[j]; } } + return 0; } // int runtime_upper_layers[6]; // values for different RBs From ce0adf779b2fe1caa68ad9eb40a144c2b07de670 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sat, 26 Mar 2016 23:14:55 +0100 Subject: [PATCH 14/21] declare struct rrc_rnti_tree_s before RB_PROTOTYPE --- openair2/RRC/LITE/rrc_eNB_S1AP.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.h b/openair2/RRC/LITE/rrc_eNB_S1AP.h index ea797e8c20..93a213c06f 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.h +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.h @@ -63,6 +63,8 @@ rrc_eNB_S1AP_compare_ue_ids( struct rrc_ue_s1ap_ids_s* c2_pP ); +struct rrc_rnti_tree_s; + RB_PROTOTYPE(rrc_rnti_tree_s, rrc_ue_s1ap_ids_s, entries, rrc_eNB_S1AP_compare_ue_ids); struct rrc_ue_s1ap_ids_s* From 2cea2dbed9d66cc5002bf8971b54cefb5f53a726 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sat, 26 Mar 2016 23:25:30 +0100 Subject: [PATCH 15/21] get rid of "const" warnings in nas_message.c --- openair3/NAS/COMMON/API/NETWORK/nas_message.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openair3/NAS/COMMON/API/NETWORK/nas_message.c b/openair3/NAS/COMMON/API/NETWORK/nas_message.c index ece3ced5a3..e0face9576 100644 --- a/openair3/NAS/COMMON/API/NETWORK/nas_message.c +++ b/openair3/NAS/COMMON/API/NETWORK/nas_message.c @@ -1016,10 +1016,10 @@ static int _nas_message_decrypt( stream_cipher.count = count; stream_cipher.bearer = 0x00; //33.401 section 8.1.1 stream_cipher.direction = direction; - stream_cipher.message = src; + stream_cipher.message = (unsigned char *)src; /* length in bits */ stream_cipher.blength = length << 3; - nas_stream_encrypt_eea1(&stream_cipher, dest); + nas_stream_encrypt_eea1(&stream_cipher, (unsigned char *)dest); /* Decode the first octet (security header type or EPS bearer identity, * and protocol discriminator) */ DECODE_U8(dest, *(uint8_t*)(&header), size); @@ -1050,10 +1050,10 @@ static int _nas_message_decrypt( stream_cipher.count = count; stream_cipher.bearer = 0x00; //33.401 section 8.1.1 stream_cipher.direction = direction; - stream_cipher.message = src; + stream_cipher.message = (unsigned char *)src; /* length in bits */ stream_cipher.blength = length << 3; - nas_stream_encrypt_eea1(&stream_cipher, dest); + nas_stream_encrypt_eea1(&stream_cipher, (unsigned char *)dest); /* Decode the first octet (security header type or EPS bearer identity, * and protocol discriminator) */ DECODE_U8(dest, *(uint8_t*)(&header), size); @@ -1178,10 +1178,10 @@ static int _nas_message_encrypt( stream_cipher.count = count; stream_cipher.bearer = 0x00; //33.401 section 8.1.1 stream_cipher.direction = direction; - stream_cipher.message = src; + stream_cipher.message = (unsigned char *)src; /* length in bits */ stream_cipher.blength = length << 3; - nas_stream_encrypt_eea1(&stream_cipher, dest); + nas_stream_encrypt_eea1(&stream_cipher, (unsigned char *)dest); LOG_FUNC_RETURN (length); @@ -1209,10 +1209,10 @@ static int _nas_message_encrypt( stream_cipher.count = count; stream_cipher.bearer = 0x00; //33.401 section 8.1.1 stream_cipher.direction = direction; - stream_cipher.message = src; + stream_cipher.message = (unsigned char *)src; /* length in bits */ stream_cipher.blength = length << 3; - nas_stream_encrypt_eea2(&stream_cipher, dest); + nas_stream_encrypt_eea2(&stream_cipher, (unsigned char *)dest); LOG_FUNC_RETURN (length); @@ -1344,7 +1344,7 @@ static uint32_t _nas_message_get_mac( stream_cipher.count = count; stream_cipher.bearer = 0x00; //33.401 section 8.1.1 stream_cipher.direction = direction; - stream_cipher.message = buffer; + stream_cipher.message = (unsigned char *)buffer; /* length in bits */ stream_cipher.blength = length << 3; @@ -1390,7 +1390,7 @@ static uint32_t _nas_message_get_mac( stream_cipher.count = count; stream_cipher.bearer = 0x00; //33.401 section 8.1.1 stream_cipher.direction = direction; - stream_cipher.message = buffer; + stream_cipher.message = (unsigned char *)buffer; /* length in bits */ stream_cipher.blength = length << 3; From 20b6fee6327365d2eb346c4480eab480521f1686 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sun, 27 Mar 2016 13:36:37 +0200 Subject: [PATCH 16/21] remove more warnings --- openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c | 2 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 1 + openair1/SCHED/phy_procedures_lte_eNb.c | 1 + openair1/SCHED/phy_procedures_lte_ue.c | 2 ++ openair2/LAYER2/MAC/eNB_scheduler_bch.c | 4 ++-- openair2/LAYER2/MAC/pre_processor.c | 2 +- openair2/LAYER2/MAC/proto.h | 1 + openair2/LAYER2/MAC/ra_procedures.c | 7 ++++++- openair2/LAYER2/openair2_proc.c | 4 ++-- openair2/PHY_INTERFACE/defs.h | 11 ++++++++--- openair2/RRC/LITE/rrc_UE.c | 8 ++++++-- openair2/RRC/LITE/rrc_eNB_S1AP.c | 3 +++ openair2/RRC/LITE/vars.h | 14 ++++++++++---- openair2/UTIL/OTG/otg_kpi.c | 4 ++-- openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c | 2 +- openair3/NAS/UE/API/USIM/usim_api.c | 2 +- targets/RT/USER/lte-softmodem.c | 8 ++++---- targets/RT/USER/lte-ue.c | 2 +- targets/SIMU/USER/init_lte.c | 4 ++-- 19 files changed, 55 insertions(+), 27 deletions(-) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c index 378832ccf7..d5bfee81ed 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c @@ -48,7 +48,7 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *phy_vars_eNB, LTE_eNB_COMMON *eNB_common_vars = &phy_vars_eNB->lte_eNB_common_vars; LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->lte_frame_parms; PHY_MEASUREMENTS_eNB *phy_measurements = &phy_vars_eNB->PHY_measurements_eNB[eNB_id]; - int32_t *rb_mask = phy_vars_eNB->rb_mask_ul; + uint32_t *rb_mask = phy_vars_eNB->rb_mask_ul; uint32_t aarx /* ,rx_power_correction */; uint32_t rb; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 95af038ab0..bf422fc37a 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -44,6 +44,7 @@ #include "PHY/CODING/extern.h" #include "PHY/CODING/lte_interleaver_inline.h" #include "PHY/LTE_TRANSPORT/defs.h" +#include "SCHED/defs.h" #include "defs.h" #include "UTIL/LOG/vcd_signal_dumper.h" diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 4042cb511c..e8c9ac670b 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -612,6 +612,7 @@ void phy_eNB_lte_check_measurement_thresholds(instance_t instanceP, ral_threshol #endif +unsigned int taus(void); void phy_procedures_eNB_TX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_eNB,uint8_t abstraction_flag, relaying_type_t r_type,PHY_VARS_RN *phy_vars_rn) diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index b29c229f27..e7b4980ac3 100755 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -902,6 +902,8 @@ void phy_procedures_UE_TX(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t abstra } */ + unsigned int taus(void); + for (i=0; ischedule_si); diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 39c4aedb4d..c744d1d90a 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -748,7 +748,7 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; UE_sched_ctrl *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; rnti_t rnti = UE_RNTI(module_idP,UE_id); - uint8_t *vrb_map = &eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; + uint8_t *vrb_map = eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map; int RBGsize = PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.N_RB_DL/N_RBG; #ifdef SF05_LIMIT //int subframe05_limit=0; diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 9afe098d77..26656878f6 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -777,6 +777,7 @@ rrc_get_estimated_ue_distance( const int CC_idP, const uint8_t loc_typeP); +void fill_dci(DCI_PDU *DCI_pdu, uint8_t sched_subframe, PHY_VARS_eNB *phy_vars_eNB); #endif /** @}*/ diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 43ec8b05ec..669077bf4f 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -152,6 +152,9 @@ void get_prach_resources(module_id_t module_idP, } } + /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */ + messageSizeGroupA = -1; + if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { noGroupB = 1; } else { @@ -171,6 +174,8 @@ void get_prach_resources(module_id_t module_idP, break; } + /* TODO: what value to use as default? */ + messagePowerOffsetGroupB = -9999; switch (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->messagePowerOffsetGroupB) { case 0: messagePowerOffsetGroupB = -9999; @@ -495,7 +500,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition - int preambleTransMax; + int preambleTransMax = -1; switch (rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { case RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3: preambleTransMax = 3; diff --git a/openair2/LAYER2/openair2_proc.c b/openair2/LAYER2/openair2_proc.c index 284f91a7f8..e09adaea8c 100644 --- a/openair2/LAYER2/openair2_proc.c +++ b/openair2/LAYER2/openair2_proc.c @@ -150,7 +150,7 @@ int dump_eNB_l2_stats(char *buffer, int length) eNB->eNB_stats[CC_id].dlsch_pdus_tx, eNB->eNB_stats[CC_id].total_dlsch_pdus_tx); - len += sprintf(&buffer[len],"ULSCH bitrate (TTI %u, avg %u) kbps, Received bytes (TTI %u, total %u), Received PDU (TTI %u, total %lu) \n", + len += sprintf(&buffer[len],"ULSCH bitrate (TTI %u, avg %u) kbps, Received bytes (TTI %u, total %u), Received PDU (TTI %lu, total %u) \n", eNB->eNB_stats[CC_id].ulsch_bitrate, eNB->eNB_stats[CC_id].total_ulsch_bitrate, eNB->eNB_stats[CC_id].ulsch_bytes_rx, @@ -201,7 +201,7 @@ int dump_eNB_l2_stats(char *buffer, int length) UE_list->eNB_UE_stats[CC_id][UE_id].avg_overhead_bytes ); - len += sprintf(&buffer[len],"[MAC] UE %d (ULSCH), Status %d, RNTI %x : rx power (normalized %d, target %d), MCS (pre %d, post %d), RB (rx %d, retx %d, total %d), Current TBS %d \n", + len += sprintf(&buffer[len],"[MAC] UE %d (ULSCH), Status %s, RNTI %x : rx power (normalized %d, target %d), MCS (pre %d, post %d), RB (rx %d, retx %d, total %d), Current TBS %d \n", UE_id, map_int_to_str(rrc_status_names, UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status), UE_list->eNB_UE_stats[CC_id][UE_id].crnti, diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h index 7b0367f537..c34bec28d7 100755 --- a/openair2/PHY_INTERFACE/defs.h +++ b/openair2/PHY_INTERFACE/defs.h @@ -241,19 +241,24 @@ typedef struct { uint16_t (*get_nCCE_max)(module_id_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe); - int (*get_nCCE_offset)(unsigned char L, int nCCE, int common_dci, unsigned short rnti, unsigned char subframe); + int (*get_nCCE_offset)(int *CCE_table, + const unsigned char L, + const int nCCE, + const int common_dci, + const unsigned short rnti, + const unsigned char subframe); /// Function to retrieve number of PRB in an rb_alloc uint32_t (*get_nb_rb)(uint8_t ra_header, uint32_t rb_alloc, int n_rb_dl); /// Function to convert VRB to PRB for distributed allocation - int (*get_prb)(int N_RB_DL,int odd_slot,int vrb,int Ngap); + uint32_t (*get_prb)(int N_RB_DL,int odd_slot,int vrb,int Ngap); /// Function to retrieve transmission mode for UE uint8_t (*get_transmission_mode)(module_id_t Mod_id,uint8_t CC_id,rnti_t rnti); /// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type - uint32_t (*get_rballoc)(uint8_t vrb_type, uint16_t rb_alloc_dci); + uint32_t (*get_rballoc)(vrb_t vrb_type, uint16_t rb_alloc_dci); /// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH) UE_MODE_t (*get_ue_mode)(module_id_t Mod_id, uint8_t CC_id,uint8_t eNB_index); diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index ee35f317cd..25e24a864a 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -2268,6 +2268,9 @@ static const char* SIB2preambleTransMax( long value ) case 10: return "n200"; } + + /* unreachable but gcc warns... */ + return "ERR"; } static const char* SIB2ra_ResponseWindowSize( long value ) { @@ -3063,9 +3066,10 @@ uint64_t arfcn_to_freq(long arfcn) { return((uint64_t)3400000000 + ((arfcn-41590)*100000)); else if (arfcn <45590) // Band 43 return((uint64_t)3600000000 + ((arfcn-43950)*100000)); - else + else { LOG_E(RRC,"Unknown EARFCN %d\n",arfcn); - + exit(1); + } } static void dump_sib5( SystemInformationBlockType5_t *sib5 ) { diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 679e629f16..e5738472c8 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -60,6 +60,9 @@ #endif #include "msc.h" +#include "gtpv1u_eNB_task.h" +#include "RRC/LITE/rrc_eNB_GTPV1U.h" + /* Value to indicate an invalid UE initial id */ static const uint16_t UE_INITIAL_ID_INVALID = 0; diff --git a/openair2/RRC/LITE/vars.h b/openair2/RRC/LITE/vars.h index 122dea1df2..cb6e8c5238 100644 --- a/openair2/RRC/LITE/vars.h +++ b/openair2/RRC/LITE/vars.h @@ -88,18 +88,24 @@ struct LogicalChannelConfig__ul_SpecificParameters LCSRB2 = {3, }; +#ifdef Rel10 +struct LogicalChannelConfig__ext1 logicalChannelSR_Mask_r9_ext1 = { + logicalChannelSR_Mask_r9: &logicalChannelSR_Mask_r9 +}; +#endif + // These are the default SRB configurations from 36.331 (Chapter 9, p. 176-179 in v8.6) -LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue = {&LCSRB1 +LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue = {ul_SpecificParameters: &LCSRB1 #ifdef Rel10 , - &logicalChannelSR_Mask_r9 + ext1: &logicalChannelSR_Mask_r9_ext1 #endif }; -LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue = {&LCSRB2 +LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue = {ul_SpecificParameters: &LCSRB2 #ifdef Rel10 , - &logicalChannelSR_Mask_r9 + ext1: &logicalChannelSR_Mask_r9_ext1 #endif }; diff --git a/openair2/UTIL/OTG/otg_kpi.c b/openair2/UTIL/OTG/otg_kpi.c index 3aa55df05f..877150d892 100644 --- a/openair2/UTIL/OTG/otg_kpi.c +++ b/openair2/UTIL/OTG/otg_kpi.c @@ -61,7 +61,7 @@ void tx_throughput(int src, int dst, int application) else if (g_otg->flow_start[src][dst][application] < get_ctime() ) otg_info->tx_throughput[src][dst][application]=((double)otg_info->tx_num_bytes[src][dst][application] *1000*8)/ ((get_ctime() - g_otg->flow_start[src][dst][application])*1024); else - LOG_W("[src %d][dst %d][app %d] flow start time less than the simu time (start %d, duration %d, ctime %d)\n", + LOG_W(OTG, "[src %d][dst %d][app %d] flow start time less than the simu time (start %d, duration %d, ctime %d)\n", src, dst, application, g_otg->flow_start[src][dst][application], g_otg->flow_duration[src][dst][application], @@ -94,7 +94,7 @@ if ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][app else if (g_otg->flow_start[src][dst][application] < get_ctime() ) otg_info->rx_goodput[src][dst][application]=((double)otg_info->rx_num_bytes[src][dst][application] *1000*8)/ ((get_ctime() - g_otg->flow_start[src][dst][application])*1024); else - LOG_W("[src %d][dst %d][app %d] flow start time less than the simu time (start %d, duration %d, ctime %d)\n", + LOG_W(OTG, "[src %d][dst %d][app %d] flow start time less than the simu time (start %d, duration %d, ctime %d)\n", src, dst, application, g_otg->flow_start[src][dst][application], g_otg->flow_duration[src][dst][application], diff --git a/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c b/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c index f00441dfa2..2301cfe5dc 100644 --- a/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c +++ b/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c @@ -694,7 +694,7 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st if(thiz) { thiz->id = (NwPtrT)thiz; thiz->stackType = stackType; - thiz->seq = (uint16_t) ((uint32_t)thiz) ; // FIXME interesting casts... don't know what this is good for... + thiz->seq = (uint16_t) ((uintptr_t)thiz) ; // FIXME interesting casts... don't know what this is good for... RB_INIT(&(thiz->outstandingTxSeqNumMap)); RB_INIT(&(thiz->outstandingRxSeqNumMap)); RB_INIT(&(thiz->sessionMap)); diff --git a/openair3/NAS/UE/API/USIM/usim_api.c b/openair3/NAS/UE/API/USIM/usim_api.c index 8a7a26de0d..51b99033bc 100644 --- a/openair3/NAS/UE/API/USIM/usim_api.c +++ b/openair3/NAS/UE/API/USIM/usim_api.c @@ -291,7 +291,7 @@ int usim_api_authenticate(const OctetString* rand_pP, const OctetString* autn_pP for (i = 0; i < USIM_API_SQN_MS_SIZE; i++) { //#warning "LG:BUG HERE TODO" sqn_ms[USIM_API_SQNMS_SIZE - i] = - ((uint8_t*)(_usim_api_data.sqn_ms))[USIM_API_SQN_MS_SIZE - i]; + ((uint8_t*)(&_usim_api_data.sqn_ms))[USIM_API_SQN_MS_SIZE - i]; } u8 sqnms[USIM_API_SQNMS_SIZE]; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index c111e76879..1887e5a8bc 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -394,7 +394,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) return temp; } -void print_difftimes() +void print_difftimes(void) { #ifdef DEBUG printf("difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec); @@ -1055,7 +1055,7 @@ static void* eNB_thread_tx( void* param ) static int eNB_thread_tx_status[NUM_ENB_THREADS]; eNB_proc_t *proc = (eNB_proc_t*)param; - FILE *tx_time_file; + FILE *tx_time_file = NULL; char tx_time_name[101]; if (opp_enabled == 1) { @@ -1274,7 +1274,7 @@ static void* eNB_thread_rx( void* param ) eNB_proc_t *proc = (eNB_proc_t*)param; - FILE *rx_time_file; + FILE *rx_time_file = NULL; char rx_time_name[101]; //int i; @@ -1681,7 +1681,7 @@ static void* eNB_thread( void* arg ) #ifdef RTAI printf( "[SCHED][eNB] Started eNB main thread (id %p)\n", task ); #else - printf( "[SCHED][eNB] Started eNB main thread on CPU %d TID %d\n", sched_getcpu(), gettid()); + printf( "[SCHED][eNB] Started eNB main thread on CPU %d TID %ld\n", sched_getcpu(), gettid()); #endif #ifdef HARD_RT diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 4acb7e7a5f..f64d8d36f1 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -463,7 +463,7 @@ static void *UE_thread_synch(void *arg) if( UE->mode == rx_dump_frame ){ FILE *fd; if ((UE->frame_rx&1) == 0) { // this guarantees SIB1 is present - if (fd = fopen("rxsig_frame0.dat","w")) { + if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) { fwrite((void*)&UE->lte_ue_common_vars.rxdata[0][0], sizeof(int32_t), 10*UE->lte_frame_parms.samples_per_tti, diff --git a/targets/SIMU/USER/init_lte.c b/targets/SIMU/USER/init_lte.c index bbb99260eb..85900387eb 100644 --- a/targets/SIMU/USER/init_lte.c +++ b/targets/SIMU/USER/init_lte.c @@ -211,11 +211,11 @@ PHY_VARS_RN* init_lte_RN(LTE_DL_FRAME_PARMS *frame_parms, if (eMBMS_active_state == multicast_relay) { for (i=0; i < 10 ; i++) { // num SF in a frame - PHY_vars_RN->dlsch_rn_MCH[i] = new_ue_dlsch(1,1,MAX_TURBO_ITERATIONS_MBSFN,NSOFT,frame_parms->N_RB_DL, 0); + PHY_vars_RN->dlsch_rn_MCH[i] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,frame_parms->N_RB_DL, 0); LOG_D(PHY,"eNB %d : MCH[%d] %p\n",RN_id,i,PHY_vars_RN->dlsch_rn_MCH[i]); } } else { - PHY_vars_RN->dlsch_rn_MCH[0] = new_ue_dlsch(1,1,MAX_TURBO_ITERATIONS,NSOFT,frame_parms->N_RB_DL, 0); + PHY_vars_RN->dlsch_rn_MCH[0] = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,frame_parms->N_RB_DL, 0); LOG_D(PHY,"eNB %d : MCH[0] %p\n",RN_id,PHY_vars_RN->dlsch_rn_MCH[0]); } From f514c0656d53cabf6cb484e7dfc5e3a5271706e6 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Sun, 27 Mar 2016 16:51:16 +0200 Subject: [PATCH 17/21] more warning removals: add const to asn1cpatch_3.p0 and update fix_asn1 --- cmake_targets/tools/fix_asn1 | 8 +-- openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 | 74 ++++++++++----------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/cmake_targets/tools/fix_asn1 b/cmake_targets/tools/fix_asn1 index 5f182c8f7e..0661d7878d 100755 --- a/cmake_targets/tools/fix_asn1 +++ b/cmake_targets/tools/fix_asn1 @@ -9,13 +9,13 @@ RRC_Rel10=( X2AP_Rel11_2=( "X2ap-CriticalityDiagnostics-IE-List.h" ae96308b37fcbcbf39da5012e42968135fc5f27b "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff" - "NativeInteger.c" 9f173e87daa1e7378618dbb060a10aae752d74be "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" - "constr_SET_OF.c" 5352abd70c1784a0a2ef3c2e287b30ea3cdcf760 "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" + "NativeInteger.c" 1a55f5402fd363318cf5444ffe1f67530dcf66ff "fix_asn1.data/X2AP.rel11.2/NativeInteger.c.diff" + "constr_SET_OF.c" 808cbbdf19b118c0bdb04e3acf2cbe6e4133be2b "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c.diff" ) S1AP_Rel10_5=( - "NativeInteger.c" 9f173e87daa1e7378618dbb060a10aae752d74be "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" - "constr_SET_OF.c" 5352abd70c1784a0a2ef3c2e287b30ea3cdcf760 "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" + "NativeInteger.c" 1a55f5402fd363318cf5444ffe1f67530dcf66ff "fix_asn1.data/S1AP.rel10.5/NativeInteger.c.diff" + "constr_SET_OF.c" 808cbbdf19b118c0bdb04e3acf2cbe6e4133be2b "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c.diff" ) red_color="$(tput setaf 1)" diff --git a/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 b/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 index b3517fd2d4..d5a936c101 100644 --- a/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 +++ b/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0 @@ -4,7 +4,7 @@ asn_enc_rval_t OCTET_STRING_encode_aper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void *sptr, asn_per_outp_t *po) { asn_enc_rval_t er = { 0, 0, 0 }; (void)td; (void)cts; (void)sptr; (void)po; return er; } -+asn_comp_rval_t * OCTET_STRING_compare(asn_TYPE_descriptor_t *td1, void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) { (void)td1; (void)sptr1; (void)td2; (void)sptr2; return 0; } ++asn_comp_rval_t * OCTET_STRING_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) { (void)td1; (void)sptr1; (void)td2; (void)sptr2; return 0; } + size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size) { (void)chunk_buf; (void)chunk_size; return 0; } --- libasn1compiler/asn1c_C.c 2015-12-08 14:39:33.366543533 +0100 @@ -51,9 +51,9 @@ + if(HIDE_INNER_DEFS) OUT("_%d", expr->_type_unique_index); + OUT("_compare(asn_TYPE_descriptor_t *td1,\n"); + INDENTED( -+ OUT("\tvoid *structure1,\n"); ++ OUT("\tconst void *structure1,\n"); + OUT("\tasn_TYPE_descriptor_t *td2,\n"); -+ OUT("\tvoid *structure2) {\n"); ++ OUT("\tconst void *structure2) {\n"); + OUT("asn_comp_rval_t * res = NULL;\n"); + OUT("%s_%d_inherit_TYPE_descriptor(td1);\n", + p, expr->_type_unique_index); @@ -142,8 +142,8 @@ +typedef struct asn_comp_rval_s { + enum COMPARE_ERR_CODE_e err_code; + char *name; // e_S1ap_ProtocolIE_ID not available for all ASN1 use (RRC vs S1AP, X2AP) -+ void *structure1; -+ void *structure2; ++ const void *structure1; ++ const void *structure2; + struct asn_comp_rval_s *next; +} asn_comp_rval_t; + @@ -234,7 +234,7 @@ + +asn_comp_rval_t * +BOOLEAN_compare(asn_TYPE_descriptor_t *td1, -+ void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) { ++ const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) { + const BOOLEAN_t *st1 = (const BOOLEAN_t *)sptr1; + const BOOLEAN_t *st2 = (const BOOLEAN_t *)sptr2; + asn_comp_rval_t *res = NULL; @@ -279,9 +279,9 @@ + +typedef asn_comp_rval_t * (type_compare_f)( + struct asn_TYPE_descriptor_s *type_descriptor1, -+ void *struct_ptr1, ++ const void *struct_ptr1, + struct asn_TYPE_descriptor_s *type_descriptor2, -+ void *struct_ptr2 ++ const void *struct_ptr2 +); + + @@ -299,7 +299,7 @@ } + +asn_comp_rval_t * -+CHOICE_compare(asn_TYPE_descriptor_t *td1, void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) ++CHOICE_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) +{ + asn_CHOICE_specifics_t *specs1 = (asn_CHOICE_specifics_t *)td1->specifics; + asn_CHOICE_specifics_t *specs2 = (asn_CHOICE_specifics_t *)td2->specifics; @@ -397,7 +397,7 @@ _ASN_ENCODED_OK(er); } + -+asn_comp_rval_t * SEQUENCE_compare(asn_TYPE_descriptor_t *td1, void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) { ++asn_comp_rval_t * SEQUENCE_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) { + int edx; + asn_comp_rval_t *res = NULL; + asn_comp_rval_t *res2 = NULL; @@ -497,7 +497,7 @@ } + +asn_comp_rval_t * -+SET_compare(asn_TYPE_descriptor_t *td1, void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) ++SET_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) +{ + int edx; + asn_comp_rval_t *res = NULL; @@ -568,7 +568,7 @@ } + +asn_comp_rval_t * -+SET_OF_compare(asn_TYPE_descriptor_t *td1, void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) ++SET_OF_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) +{ + asn_TYPE_member_t *elm1 = td1->elements; + asn_TYPE_member_t *elm2 = td2->elements; @@ -665,10 +665,10 @@ } + +asn_comp_rval_t * -+ENUMERATED_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { -+ ENUMERATED_t *st1 = (ENUMERATED_t *)sptr1; -+ ENUMERATED_t *st2 = (ENUMERATED_t *)sptr2; ++ENUMERATED_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { ++ const ENUMERATED_t *st1 = (const ENUMERATED_t *)sptr1; ++ const ENUMERATED_t *st2 = (const ENUMERATED_t *)sptr2; + asn_comp_rval_t *res = NULL; + + COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res) @@ -772,10 +772,10 @@ +asn_comp_rval_t * -+INTEGER_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { -+ INTEGER_t *st1 = (INTEGER_t *)sptr1; -+ INTEGER_t *st2 = (INTEGER_t *)sptr2; ++INTEGER_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { ++ const INTEGER_t *st1 = (const INTEGER_t *)sptr1; ++ const INTEGER_t *st2 = (const INTEGER_t *)sptr2; + asn_comp_rval_t *res = NULL; + + COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res) @@ -855,8 +855,8 @@ } + +asn_comp_rval_t * -+NativeEnumerated_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { ++NativeEnumerated_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { + const asn_INTEGER_enum_map_t *a = sptr1; + const asn_INTEGER_enum_map_t *b = sptr2; + asn_comp_rval_t *res = NULL; @@ -900,8 +900,8 @@ + +asn_comp_rval_t * -+NativeInteger_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { ++NativeInteger_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { + const long *native1 = (const long *)sptr1; + const long *native2 = (const long *)sptr2; + asn_comp_rval_t *res = NULL; @@ -943,10 +943,10 @@ } +asn_comp_rval_t * -+NativeReal_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { -+ REAL_t *st1 = (REAL_t *)sptr1; -+ REAL_t *st2 = (REAL_t *)sptr2; ++NativeReal_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { ++ const REAL_t *st1 = (const REAL_t *)sptr1; ++ const REAL_t *st2 = (const REAL_t *)sptr2; + asn_comp_rval_t *res = NULL; + + COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res) @@ -997,8 +997,8 @@ } + +asn_comp_rval_t * -+NULL_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { ++NULL_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { + + return NULL; +} @@ -1066,9 +1066,9 @@ +asn_comp_rval_t * +OCTET_STRING_compare(asn_TYPE_descriptor_t *td1, -+ void *sptr1, asn_TYPE_descriptor_t *td2, void *sptr2) { -+ OCTET_STRING_t *st1 = (OCTET_STRING_t *)sptr1; -+ OCTET_STRING_t *st2 = (OCTET_STRING_t *)sptr2; ++ const void *sptr1, asn_TYPE_descriptor_t *td2, const void *sptr2) { ++ const OCTET_STRING_t *st1 = (const OCTET_STRING_t *)sptr1; ++ const OCTET_STRING_t *st2 = (const OCTET_STRING_t *)sptr2; + asn_comp_rval_t *res = NULL; + + COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res) @@ -1132,10 +1132,10 @@ + + +asn_comp_rval_t * -+REAL_compare(asn_TYPE_descriptor_t *td1, void *sptr1, -+ asn_TYPE_descriptor_t *td2, void *sptr2) { -+ REAL_t *st1 = (REAL_t *)sptr1; -+ REAL_t *st2 = (REAL_t *)sptr2; ++REAL_compare(asn_TYPE_descriptor_t *td1, const void *sptr1, ++ asn_TYPE_descriptor_t *td2, const void *sptr2) { ++ const REAL_t *st1 = (const REAL_t *)sptr1; ++ const REAL_t *st2 = (const REAL_t *)sptr2; + asn_comp_rval_t *res = NULL; + + COMPARE_CHECK_ARGS(td1, td2, sptr1, sptr2, res) From 5f823b401a9834149510587f919d2f4f69848898 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 28 Mar 2016 22:45:20 +0200 Subject: [PATCH 18/21] some more warning removals --- .../ETH_TRANSPORT/bypass_session_layer.c | 2 +- .../SIMULATION/ETH_TRANSPORT/emu_transport.c | 1 - openair1/SIMULATION/LTE_PHY/dlsim.c | 4 +++- openair1/SIMULATION/LTE_PHY/mbmssim.c | 8 +++---- openair1/SIMULATION/LTE_PHY/pbchsim.c | 17 +++++++------ openair1/SIMULATION/LTE_PHY/pdcchsim.c | 11 ++++++--- openair1/SIMULATION/LTE_PHY/prachsim.c | 24 ++++++++++++------- openair2/ENB_APP/enb_app.c | 6 +++++ openair2/ENB_APP/enb_config.c | 4 ++++ openair2/LAYER2/MAC/eNB_scheduler.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 4 +++- openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c | 12 ++++++++++ openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c | 2 +- openair2/LAYER2/RLC/rlc.c | 3 +++ openair2/LAYER2/RLC/rlc_rrc.c | 8 +++++++ openair2/RRC/LITE/L2_interface.c | 8 +++++-- openair2/RRC/LITE/rrc_UE.c | 7 +++++- openair2/RRC/LITE/rrc_common.c | 3 +++ openair2/RRC/LITE/rrc_eNB.c | 4 ++++ openair2/UTIL/LOG/log.c | 8 +++++++ openair2/UTIL/OMG/sumo.c | 2 +- targets/ARCH/COMMON/common_lib.c | 3 ++- .../ARCH/EXMIMO/USERSPACE/LIB/gain_control.h | 2 ++ .../ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.h | 2 ++ targets/RT/USER/lte-softmodem.c | 5 ++++ targets/RT/USER/lte-ue.c | 10 ++++---- targets/SIMU/USER/channel_sim.c | 4 ++-- targets/SIMU/USER/event_handler.c | 9 ++++--- targets/SIMU/USER/oaisim.c | 22 ++++++++++------- targets/SIMU/USER/oaisim_functions.c | 14 +++++------ 31 files changed, 151 insertions(+), 62 deletions(-) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c b/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c index 765952133a..0ced6e0ceb 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c @@ -288,7 +288,7 @@ int emu_transport_handle_ue_info(bypass_msg_header_t *messg, n_ue, total_header+total_tbs,total_header,total_tbs); } -#warning "CC id should be adjusted, set to zero for the moment" +//#warning "CC id should be adjusted, set to zero for the moment" memcpy(&UE_transport_info[n_ue][CC_id], UE_info, total_header + total_tbs); /* Go to the next UE info */ diff --git a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c index 8c5516eabd..ec15e7c668 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/emu_transport.c @@ -291,7 +291,6 @@ void fill_phy_enb_vars(unsigned int enb_id, uint8_t CC_id,unsigned int next_slot LTE_eNB_DLSCH_t *dlsch_eNB; unsigned short ue_id; uint8_t nb_total_dci; - int i; // eNB // PBCH : copy payload diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index d67024810a..6f2c1f1d22 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -220,7 +220,7 @@ int main(int argc, char **argv) uint8_t N_RB_DL=25,osf=1; frame_t frame_type = FDD; int xforms=0; - FD_lte_phy_scope_ue *form_ue; + FD_lte_phy_scope_ue *form_ue = NULL; char title[255]; uint32_t DLSCH_RB_ALLOC = 0x1fff; int numCCE=0; @@ -2624,6 +2624,8 @@ PMI_FEEDBACK: num_pdcch_symbols, PHY_vars_eNB->dlsch_eNB[k][0], PHY_vars_eNB->dlsch_eNB[k][1]); + /* avoid gcc warnings */ + (void)re_allocated; stop_meas(&PHY_vars_eNB->dlsch_modulation_stats); /* diff --git a/openair1/SIMULATION/LTE_PHY/mbmssim.c b/openair1/SIMULATION/LTE_PHY/mbmssim.c index 0044b2ff51..8522b7be9a 100644 --- a/openair1/SIMULATION/LTE_PHY/mbmssim.c +++ b/openair1/SIMULATION/LTE_PHY/mbmssim.c @@ -583,10 +583,10 @@ int main(int argc, char **argv) mcs,N_RB_DL,mcs,N_RB_DL,errs[0], mcs,N_RB_DL,mcs,N_RB_DL,trials); else - fprintf(fd,"SNR_awgn_%d = [SNR_awgn_%d %d]; errs_mch_awgn_%d =[errs_mch_awgn_%f %d]; mch_trials_awgn_%d =[mch_trials_awgn_%d %d];\n", - mcs,N_RB_DL,mcs,N_RB_DL,SNR, - mcs,N_RB_DL,mcs,N_RB_DL,errs[0], - mcs,N_RB_DL,mcs,N_RB_DL,trials); + fprintf(fd,"SNR_awgn_%d = [SNR_awgn_%d %f]; errs_mch_awgn_%d =[errs_mch_awgn_%d %d]; mch_trials_awgn_%d =[mch_trials_awgn_%d %d];\n", + N_RB_DL,N_RB_DL,SNR, + N_RB_DL,N_RB_DL,errs[0], + N_RB_DL,N_RB_DL,trials); fflush(fd); diff --git a/openair1/SIMULATION/LTE_PHY/pbchsim.c b/openair1/SIMULATION/LTE_PHY/pbchsim.c index 319c2ed008..739c7e121f 100644 --- a/openair1/SIMULATION/LTE_PHY/pbchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pbchsim.c @@ -80,9 +80,9 @@ int main(int argc, char **argv) unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; - FILE *output_fd; + FILE *output_fd = NULL; uint8_t write_output_file=0; - int result; + //int result; int freq_offset; // int subframe_offset; // char fname[40], vname[40]; @@ -91,8 +91,8 @@ int main(int argc, char **argv) uint16_t Nid_cell=0; int n_frames=1; - channel_desc_t *eNB2UE,*eNB2UE1,*eNB2UE2; - uint32_t nsymb,tx_lev,tx_lev1,tx_lev2; + channel_desc_t *eNB2UE,*eNB2UE1 = NULL,*eNB2UE2 = NULL; + uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; uint8_t extended_prefix_flag=0; int8_t interf1=-21,interf2=-21; LTE_DL_FRAME_PARMS *frame_parms; @@ -104,12 +104,12 @@ int main(int argc, char **argv) char input_val_str[50],input_val_str2[50]; // double input_val1,input_val2; // uint16_t amask=0; - uint8_t frame_mod4,num_pdcch_symbols; + uint8_t frame_mod4,num_pdcch_symbols = 0; uint16_t NB_RB=25; SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - DCI_ALLOC_t dci_alloc[8]; + //DCI_ALLOC_t dci_alloc[8]; uint8_t abstraction_flag=0;//,calibration_flag=0; double pbch_sinr; int pbch_tx_ant; @@ -782,7 +782,10 @@ int main(int argc, char **argv) i=0; while (!feof(input_fd)) { - fscanf(input_fd,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2); + if (fscanf(input_fd,"%s %s",input_val_str,input_val_str2) != 2) { //&input_val1,&input_val2); + printf("%s:%d:%s: error with fscanf, exiting\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } if ((i%4)==0) { ((short*)txdata[0])[i/2] = (short)((1<<15)*strtod(input_val_str,NULL)); diff --git a/openair1/SIMULATION/LTE_PHY/pdcchsim.c b/openair1/SIMULATION/LTE_PHY/pdcchsim.c index 3c717d2625..0c51959f14 100644 --- a/openair1/SIMULATION/LTE_PHY/pdcchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pdcchsim.c @@ -67,9 +67,9 @@ DCI_PDU *get_dci(LTE_DL_FRAME_PARMS *lte_frame_parms,uint8_t log2L, uint8_t log2 uint32_t UL_alloc_pdu[2]; int i; - int dci_length_bytes,dci_length; - int BCCH_pdu_size_bits, BCCH_pdu_size_bytes; - int UL_pdu_size_bits, UL_pdu_size_bytes; + int dci_length_bytes=0,dci_length=0; + int BCCH_pdu_size_bits=0, BCCH_pdu_size_bytes=0; + int UL_pdu_size_bits=0, UL_pdu_size_bytes=0; int mcs = 3; DCI_pdu.Num_ue_spec_dci = 0; @@ -789,6 +789,11 @@ int main(int argc, char **argv) while (!feof(input_fd)) { ret=fscanf(input_fd,"%s %s",input_val_str,input_val_str2);//&input_val1,&input_val2); + if (ret != 2) { + printf("%s:%d:%s: fscanf error, exiting\n", __FILE__, __LINE__, __FUNCTION__); + exit(1); + } + if ((i%4)==0) { ((short*)txdata[0])[i/2] = (short)((1<<15)*strtod(input_val_str,NULL)); ((short*)txdata[0])[(i/2)+1] = (short)((1<<15)*strtod(input_val_str2,NULL)); diff --git a/openair1/SIMULATION/LTE_PHY/prachsim.c b/openair1/SIMULATION/LTE_PHY/prachsim.c index 187a521e07..0fab08a3d1 100644 --- a/openair1/SIMULATION/LTE_PHY/prachsim.c +++ b/openair1/SIMULATION/LTE_PHY/prachsim.c @@ -58,6 +58,8 @@ PHY_VARS_UE *PHY_vars_UE; extern uint16_t prach_root_sequence_map0_3[838]; +void dump_prach_config(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); + int main(int argc, char **argv) { @@ -74,7 +76,7 @@ int main(int argc, char **argv) int **txdata; double **s_re,**s_im,**r_re,**r_im; double iqim=0.0; - int trial, ntrials=1; + int trial; //, ntrials=1; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; @@ -82,7 +84,7 @@ int main(int argc, char **argv) uint8_t hs_flag=0; int n_frames=1; channel_desc_t *UE2eNB; - uint32_t nsymb,tx_lev,tx_lev_dB; + uint32_t nsymb,tx_lev; //,tx_lev_dB; uint8_t extended_prefix_flag=0; // int8_t interf1=-19,interf2=-19; LTE_DL_FRAME_PARMS *frame_parms; @@ -101,8 +103,8 @@ int main(int argc, char **argv) uint16_t preamble_energy_list[64],preamble_tx=99,preamble_delay_list[64]; uint16_t preamble_max,preamble_energy_max; PRACH_RESOURCES_t prach_resources; - uint8_t prach_fmt; - int N_ZC; + //uint8_t prach_fmt; + //int N_ZC; int delay = 0; double delay_avg=0; double ue_speed = 0; @@ -126,7 +128,8 @@ int main(int argc, char **argv) case 'a': printf("Running AWGN simulation\n"); awgn_flag = 1; - ntrials=1; + /* ntrials not used later, no need to set */ + //ntrials=1; break; case 'd': @@ -404,9 +407,11 @@ int main(int argc, char **argv) PHY_vars_eNB->lte_frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag=hs_flag; PHY_vars_eNB->lte_frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; - prach_fmt = get_prach_fmt(PHY_vars_eNB->lte_frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - PHY_vars_eNB->lte_frame_parms.frame_type); - N_ZC = (prach_fmt <4)?839:139; + /* N_ZC not used later, so prach_fmt is also useless, don't set */ + //prach_fmt = get_prach_fmt(PHY_vars_eNB->lte_frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + // PHY_vars_eNB->lte_frame_parms.frame_type); + /* N_ZC not used later, no need to set */ + //N_ZC = (prach_fmt <4)?839:139; compute_prach_seq(&PHY_vars_eNB->lte_frame_parms.prach_config_common,PHY_vars_eNB->lte_frame_parms.frame_type,PHY_vars_eNB->X_u); @@ -430,7 +435,8 @@ int main(int argc, char **argv) subframe, 0); //Nf - tx_lev_dB = (unsigned int) dB_fixed(tx_lev); + /* tx_lev_dB not used later, no need to set */ + //tx_lev_dB = (unsigned int) dB_fixed(tx_lev); write_output("txsig0_new.m","txs0", &txdata[0][subframe*frame_parms->samples_per_tti],frame_parms->samples_per_tti,1,1); //write_output("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1); diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 70fb5ad61f..6d95c215db 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -285,6 +285,9 @@ void *eNB_app_task(void *args_p) instance_t instance; int result; + /* for no gcc warnings */ + (void)instance; + itti_mark_task_ready (TASK_ENB_APP); # if defined(ENABLE_USE_MME) @@ -420,5 +423,8 @@ void *eNB_app_task(void *args_p) #endif + /* for no gcc warnings */ + (void)enb_properties_p; + return NULL; } diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index e96ef91326..51d5f3805f 100755 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -649,6 +649,10 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP) char* osa_log_level = NULL; char* osa_log_verbosity = NULL; + /* for no gcc warnings */ + (void)astring; + (void)my_int; + memset((char*) (enb_properties.properties), 0 , MAX_ENB * sizeof(Enb_properties_t *)); memset((char*)active_enb, 0 , MAX_ENB * sizeof(char*)); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 21e9337dbb..df867693a6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -86,7 +86,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, int mbsfn_status[MAX_NUM_CCs]; protocol_ctxt_t ctxt; #ifdef EXMIMO - int ret; + //int ret; #endif #if defined(ENABLE_ITTI) MessageDef *msg_p; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 638c8051b0..d210b98f6a 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -692,7 +692,7 @@ pdcp_data_ind( #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled == 1) { - unsigned int dst_instance; + //unsigned int dst_instance; int ctime; if ((pdcp_p->rlc_mode == RLC_MODE_AM)&&(MBMS_flagP==0) ) { diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 787d463b32..d7e1fe3551 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -313,6 +313,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; struct pdcp_netlink_element_s* data_p = NULL; + /* avoid gcc warnings */ + (void)data_p; module_id_t ue_id = 0; pdcp_t* pdcp_p = NULL; # if defined(PDCP_USE_NETLINK_QUEUES) @@ -565,7 +567,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) } } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs -#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES +//#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index b92340348a..0b8abf3838 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -682,6 +682,12 @@ rlc_am_mac_data_request ( MessageDef *msg_p; # endif int octet_index, index; + /* for no gcc warnings */ + (void)num_nack; + (void)message_string; + (void)message_string_size; + (void)octet_index; + (void)index; #endif list_init (&data_req.data, NULL); @@ -916,6 +922,12 @@ rlc_am_mac_data_indication ( MessageDef *msg_p; # endif int octet_index, index; + /* for no gcc warnings */ + (void)num_nack; + (void)message_string; + (void)message_string_size; + (void)octet_index; + (void)index; #endif (void)l_rlc_p; /* avoid gcc warning "unused variable" */ diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 8aab33f54c..7b0c9890ed 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -745,7 +745,7 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t /* * Print every single octet in hexadecimal form */ - message_string_size += sprintf(&message_string[message_string_size], " %02x", (uint8_t*)(&sdu_pP->data[data_offset])[octet_index]); + message_string_size += sprintf(&message_string[message_string_size], " %02x", ((uint8_t*)(&sdu_pP->data[data_offset]))[octet_index]); /* * Align newline and pipes according to the octets in groups of 2 */ diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index e19c6b0b0a..1397387f22 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -602,6 +602,9 @@ rlc_module_init (void) int k; module_id_t module_id1; + /* for no gcc warnings */ + (void)k; + LOG_D(RLC, "MODULE INIT\n"); rlc_rrc_data_ind = NULL; rlc_rrc_data_conf = NULL; diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index f78cf90631..eccea461ab 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -87,6 +87,11 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP #endif + /* for no gcc warnings */ + (void)rlc_union_p; + (void)key; + (void)h_rc; + LOG_D(RLC, PROTOCOL_CTXT_FMT" CONFIG REQ ASN1 \n", PROTOCOL_CTXT_ARGS(ctxt_pP)); @@ -463,6 +468,9 @@ rlc_op_status_t rrc_rlc_remove_rlc ( #endif + /* for no gcc warnings */ + (void)lcid; + #ifdef Rel10 if (MBMS_flagP == TRUE) { diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index 6a64095e92..70d0a20c08 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -355,6 +355,10 @@ mac_rrc_lite_data_ind( SRB_INFO *Srb_info; protocol_ctxt_t ctxt; sdu_size_t sdu_size = 0; + + /* for no gcc warnings */ + (void)sdu_size; + /* int si_window; */ @@ -389,7 +393,7 @@ mac_rrc_lite_data_ind( itti_send_msg_to_task (TASK_RRC_UE, ctxt.instance, message_p); } #else - decode_BCCH_DLSCH_Message(&ctxt,eNB_indexP,sduP,sdu_lenP, 0, 0); + decode_BCCH_DLSCH_Message(&ctxt,eNB_indexP,(uint8_t*)sduP,sdu_lenP, 0, 0); #endif } @@ -634,7 +638,7 @@ rrc_lite_data_ind( buffer_pP, sdu_sizeP); } else { -#warning "LG put 0 to arg4 that is eNB index" +//#warning "LG put 0 to arg4 that is eNB index" rrc_ue_decode_dcch( ctxt_pP, DCCH_index, diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 25e24a864a..ef4bbbeb1a 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -141,7 +141,9 @@ static uint8_t check_trigger_meas_event( Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt); +#ifdef Rel10 static void decode_MBSFNAreaConfiguration(module_id_t module_idP, uint8_t eNB_index, frame_t frameP,uint8_t mbsfn_sync_area); +#endif @@ -151,10 +153,13 @@ static void decode_MBSFNAreaConfiguration(module_id_t module_idP, uint8_t eNB_in /*------------------------------------------------------------------------------*/ +/* to avoid gcc warnings when compiling with certain options */ +#if defined(ENABLE_USE_MME) || ENABLE_RAL static Rrc_State_t rrc_get_state (module_id_t ue_mod_idP) { return UE_rrc_inst[ue_mod_idP].RrcState; } +#endif static Rrc_Sub_State_t rrc_get_sub_state (module_id_t ue_mod_idP) { @@ -1298,7 +1303,7 @@ rrc_ue_process_radioResourceConfigDedicated( UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[1], UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[2], UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->cellAccessRelatedInfo.cellIdentity.buf[3]); -# endif OAI_EMU +# endif /* OAI_EMU */ #endif } diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index 2a37ccde00..86a3197d1e 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -253,6 +253,9 @@ openair_rrc_top_init( OAI_UECapability_t *UECap = NULL; int CC_id; + /* for no gcc warnings */ + (void)CC_id; + LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST); if (NB_UE_INST > 0) { diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 5d7c99a586..657b8cba02 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -796,6 +796,8 @@ rrc_eNB_free_UE( protocol_ctxt_t ctxt; #if !defined(ENABLE_USE_MME) module_id_t ue_module_id; + /* avoid gcc warnings */ + (void)ue_module_id; #endif AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %x!", enb_mod_idP, NB_eNB_INST, rntiP); ue_context_p = rrc_eNB_get_ue_context( @@ -1176,6 +1178,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( CellsToAddModList_t *CellsToAddModList = NULL; struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; DedicatedInfoNAS_t *dedicatedInfoNas = NULL; + /* for no gcc warnings */ + (void)dedicatedInfoNas; C_RNTI_t *cba_RNTI = NULL; #ifdef CBA diff --git a/openair2/UTIL/LOG/log.c b/openair2/UTIL/LOG/log.c index abbdbc01ab..0ef8f99d71 100755 --- a/openair2/UTIL/LOG/log.c +++ b/openair2/UTIL/LOG/log.c @@ -698,6 +698,10 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, char *log_start; char *log_end; + /* for no gcc warnings */ + (void)log_start; + (void)log_end; + c = &g_log->log_component[comp]; // do not apply filtering for LOG_F @@ -971,6 +975,10 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, */ char log_buffer[MAX_LOG_TOTAL]; + /* for no gcc warnings */ + (void)log_start; + (void)log_end; + c = &g_log->log_component[comp]; // do not apply filtering for LOG_F diff --git a/openair2/UTIL/OMG/sumo.c b/openair2/UTIL/OMG/sumo.c index f709a73e2a..4af34d0bc1 100644 --- a/openair2/UTIL/OMG/sumo.c +++ b/openair2/UTIL/OMG/sumo.c @@ -70,7 +70,7 @@ start_sumo_generator (omg_global_param omg_param_list) if ((pid = fork ()) == 0) { // Start SUMO in the child process - system (sumo_line); + if (system (sumo_line)) ; /* this if for no gcc warnings */ //childs addresss space } diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c index dea02f2bba..de78cb80a6 100644 --- a/targets/ARCH/COMMON/common_lib.c +++ b/targets/ARCH/COMMON/common_lib.c @@ -147,7 +147,8 @@ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cf int rc; //ToDo: EXMIMO harmonization is not complete. That is the reason for this ifdef #ifdef EXMIMO - device_init(device, openair0_cfg); + int device_init(openair0_device *device, openair0_config_t *openair0_cfg); + rc = device_init(device, openair0_cfg); #else rc=load_lib(device, openair0_cfg, NULL,BBU_LOCAL_RADIO_HEAD ); if ( rc >= 0) { diff --git a/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.h b/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.h index dd48683ad0..c71b51550e 100644 --- a/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.h +++ b/targets/ARCH/EXMIMO/USERSPACE/LIB/gain_control.h @@ -30,8 +30,10 @@ #define TARGET_RX_POWER 50 // Target digital power for the AGC #define TARGET_RX_POWER_MAX 53 // Maximum digital power for AGC #define TARGET_RX_POWER_MIN 48 // Minimum digital power for AGC +#ifndef min #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) +#endif void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card); void gain_control (unsigned int rx_power_fil_dB, unsigned int ant, unsigned int card); diff --git a/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.h b/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.h index ae2ff8a36b..0abb27dee2 100644 --- a/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.h +++ b/targets/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.h @@ -98,4 +98,6 @@ unsigned int *openair0_daq_cnt(void); // set the TX and RX frequencies (card 0 only for now, to retain USRP compatibility) int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config); +int openair0_set_gains(openair0_device* device, openair0_config_t *openair0_cfg); + #endif diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 1887e5a8bc..5271ca5d4a 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1638,6 +1638,11 @@ static void* eNB_thread( void* arg ) int CC_id=0; struct timespec trx_time0, trx_time1, trx_time2; + /* avoid gcc warnings */ + (void)trx_time0; + (void)trx_time1; + (void)trx_time2; + #ifdef RTAI RT_TASK* task = rt_task_init_schmod(nam2num("eNBmain"), 0, 0, 0, SCHED_FIFO, 0xF); #else diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index f64d8d36f1..6ab133e5d6 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -1401,14 +1401,14 @@ void *UE_thread(void *arg) RT_TASK *task; #endif // RTIME in, out, diff; - int slot=0,frame=0,hw_slot,last_slot,next_slot; + int slot=0,frame=0,hw_slot; // unsigned int aa; int delay_cnt; RTIME time_in; - int hw_slot_offset=0,rx_offset_mbox=0,mbox_target=0,mbox_current=0; + int /* hw_slot_offset=0, */ rx_offset_mbox=0,mbox_target=0,mbox_current=0; int diff2; - int i, ret; - int CC_id,card; + int /* i, */ ret; + int /* CC_id, */ card; volatile unsigned int *DAQ_MBOX = openair0_daq_cnt(); int wait_sync_cnt = 0; @@ -1688,7 +1688,7 @@ void *UE_thread(void *arg) frame++; } } else if (UE->is_synchronized == 0) { // we are not yet synchronized - hw_slot_offset = 0; + //hw_slot_offset = 0; first_synch = 1; slot = 0; diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index e26129bca6..adb1fb92e7 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -97,7 +97,7 @@ void do_DL_sig(double **r_re0,double **r_im0, double rx_pwr; int32_t rx_pwr2; uint32_t i,aa; - uint32_t slot_offset,slot_offset_meas; + uint32_t slot_offset,slot_offset_meas = 0; double min_path_loss=-200; uint8_t hold_channel=0; @@ -105,7 +105,7 @@ void do_DL_sig(double **r_re0,double **r_im0, uint8_t nb_antennas_rx = eNB2UE[0][0][CC_id]->nb_rx; // number of rx antennas at UE uint8_t nb_antennas_tx = eNB2UE[0][0][CC_id]->nb_tx; // number of tx antennas at eNB - LTE_DL_FRAME_PARMS *fp; + //LTE_DL_FRAME_PARMS *fp; // int subframe_sched = ((next_slot>>1) == 0) ? 9 : ((next_slot>>1)-1); diff --git a/targets/SIMU/USER/event_handler.c b/targets/SIMU/USER/event_handler.c index 4072c6bfe7..1f7ecde72e 100644 --- a/targets/SIMU/USER/event_handler.c +++ b/targets/SIMU/USER/event_handler.c @@ -208,15 +208,15 @@ void schedule_events() a = 5; - uint16_t *priority[11];//={1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2}; + //uint16_t *priority[11];//={1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2}; - int tab[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; + //int tab[NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX]; Application_Config* application_config; application_config = malloc(sizeof(Application_Config)); for(i=0; icustomized_traffic.aggregation_level[i]=i; } @@ -249,7 +249,7 @@ void schedule_events() //schedule(READ, MAC_ET, 500, NULL, ""); //schedule(WRITE, MAC_ET, 100, NULL, ""); //schedule(READ, TOPO_ET,110,NULL,"",0,0); - double b = (double) 45; + //double b = (double) 45; //schedule(READ, APP_ET,111,NULL,"",0,0); //schedule(READ, SYS_ET,112,NULL,"",0,0); //schedule(READ, EMU_ET,113,NULL,"",-1,-1); @@ -1844,7 +1844,6 @@ void update_emu_model(Event_t event) printf("\n\n\nA NEW EMU MODEL\n\n\n"); OAI_Emulation *oai_emulation; oai_emulation = get_OAI_emulation(); - int i=0; if(event.optype == READ) { if(event.key == NULL) { diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 9e4880906d..a0dcb7baaf 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -530,19 +530,23 @@ l2l1_task (void *args_p) if(abstraction_flag==0) { for (UE_inst=0; UE_instFK: OAI EMU channel abstraction does not work for MCS higher than" +//#warning "NN->FK: OAI EMU channel abstraction does not work for MCS higher than" openair_daq_vars.target_ue_dl_mcs = cmin(target_dl_mcs,16); openair_daq_vars.target_ue_ul_mcs = target_ul_mcs; openair_daq_vars.ue_dl_rb_alloc=0x1fff; @@ -1049,7 +1049,7 @@ void init_openair2(void) module_id_t enb_id; module_id_t UE_id; int CC_id; -#warning "eNB index is hard coded to zero" +//#warning "eNB index is hard coded to zero" for (CC_id=0; CC_idlte_frame_parms, @@ -1270,10 +1270,10 @@ void update_ocm() LOG_I(OCM,"Path loss (CCid %d) between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n", CC_id,eNB_id,enb_data[eNB_id]->x,enb_data[eNB_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y, eNB2UE[eNB_id][UE_id][CC_id]->path_loss_dB, eNB2UE[eNB_id][UE_id][CC_id]->aoa); - double dx, dy, distance; - dx = enb_data[eNB_id]->x - ue_data[UE_id]->x; - dy = enb_data[eNB_id]->y - ue_data[UE_id]->y; - distance = sqrt(dx * dx + dy * dy); + //double dx, dy, distance; + //dx = enb_data[eNB_id]->x - ue_data[UE_id]->x; + //dy = enb_data[eNB_id]->y - ue_data[UE_id]->y; + //distance = sqrt(dx * dx + dy * dy); /*LOG_D(LOCALIZE, " OCM distance between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f \n", eNB_id, enb_data[eNB_id]->x,enb_data[eNB_id]->y, UE_id, ue_data[UE_id]->x,ue_data[UE_id]->y, @@ -1313,7 +1313,7 @@ void update_otg_eNB(module_id_t enb_module_idP, unsigned int ctime) #if defined(USER_MODE) && defined(OAI_EMU) - int rrc_state=0; + //int rrc_state=0; if (oai_emulation.info.otg_enabled ==1 ) { From 87d1424762b590adadda5f5db2dc7479421020e6 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 29 Mar 2016 11:50:29 +0200 Subject: [PATCH 19/21] more warning removals --- openair2/RRC/LITE/rrc_UE.c | 4 ++++ openair2/RRC/LITE/rrc_eNB.c | 9 ++++++++- targets/SIMU/USER/oaisim.c | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index ef4bbbeb1a..7da26897e8 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -704,6 +704,10 @@ rrc_ue_establish_drb( // add descriptor from RRC PDU #ifdef PDCP_USE_NETLINK int oip_ifup=0,ip_addr_offset3=0,ip_addr_offset4=0; + /* avoid gcc warnings */ + (void)oip_ifup; + (void)ip_addr_offset3; + (void)ip_addr_offset4; #endif LOG_I(RRC,"[UE %d] Frame %d: processing RRCConnectionReconfiguration: reconfiguring DRB %ld/LCID %d\n", diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 657b8cba02..4c8e3d9d63 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -1147,7 +1147,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( struct DRB_ToAddMod *DRB_config = NULL; struct RLC_Config *DRB_rlc_config = NULL; struct PDCP_Config *DRB_pdcp_config = NULL; - //struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; + struct PDCP_Config__rlc_AM *PDCP_rlc_AM = NULL; struct PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; struct LogicalChannelConfig *DRB_lchan_config = NULL; struct LogicalChannelConfig__ul_SpecificParameters @@ -1292,6 +1292,9 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( DRB_pdcp_config->rlc_AM = NULL; DRB_pdcp_config->rlc_UM = NULL; + /* avoid gcc warnings */ + (void)PDCP_rlc_AM; + #ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; @@ -3007,6 +3010,10 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( int oip_ifup = 0; int dest_ip_offset = 0; module_id_t ue_module_id = -1; + /* avoid gcc warnings */ + (void)oip_ifup; + (void)dest_ip_offset; + (void)ue_module_id; #endif uint8_t *kRRCenc = NULL; diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index a0dcb7baaf..d09f61f06a 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -458,6 +458,7 @@ l2l1_task (void *args_p) char *xargv[1]; //#endif +#undef PRINT_STATS /* this undef is to avoid gcc warnings */ #define PRINT_STATS #ifdef PRINT_STATS int len; From 600cce17c72ede912cbcf8991b925cfcd7312875 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 29 Mar 2016 12:00:57 +0200 Subject: [PATCH 20/21] more warning removals --- openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 2 +- openair2/RRC/LITE/rrc_eNB.c | 1 + openair3/NAS/TOOLS/ue_data.c | 2 +- openair3/NAS/UE/EMM/SAP/emm_reg.c | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index d7e1fe3551..8ac79a61b9 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -494,7 +494,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/ #else // OAI_EMU pdcp_read_header_g.inst = 0; -#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" +//#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" ctxt.frame = ctxt_cpy.frame; ctxt.enb_flag = ctxt_cpy.enb_flag; diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 4c8e3d9d63..42e28f752f 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -1294,6 +1294,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration( /* avoid gcc warnings */ (void)PDCP_rlc_AM; + (void)PDCP_rlc_UM; #ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); diff --git a/openair3/NAS/TOOLS/ue_data.c b/openair3/NAS/TOOLS/ue_data.c index 478119acda..5a463ad094 100644 --- a/openair3/NAS/TOOLS/ue_data.c +++ b/openair3/NAS/TOOLS/ue_data.c @@ -481,7 +481,7 @@ static void _display_emm_data(const emm_nvdata_t* data) data->imsi.u.num.digit13, data->imsi.u.num.digit14); } else { - printf("%u%u%u.%u%u%u.%u%u%u%u%u%u%u%u\n", + printf("%u%u%u.%u%u%u.%u%u%u%u%u%u%u%u%u\n", data->imsi.u.num.digit1, data->imsi.u.num.digit2, data->imsi.u.num.digit3, diff --git a/openair3/NAS/UE/EMM/SAP/emm_reg.c b/openair3/NAS/UE/EMM/SAP/emm_reg.c index 7f20b25151..b73f75975a 100755 --- a/openair3/NAS/UE/EMM/SAP/emm_reg.c +++ b/openair3/NAS/UE/EMM/SAP/emm_reg.c @@ -114,6 +114,9 @@ int emm_reg_send(const emm_reg_t *msg) emm_reg_primitive_t primitive = msg->primitive; assert( (primitive > _EMMREG_START) && (primitive < _EMMREG_END)); + /* avoid gcc warnings */ + (void)primitive; + /* Execute the EMM procedure */ rc = emm_fsm_process(msg); From 3d0ad079b1b4ce73f99da260016c5fee0b3cf680 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Wed, 30 Mar 2016 08:07:54 -0400 Subject: [PATCH 21/21] fix for kernel 4.2 --- targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c b/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c index 4ef187b073..ce699a1b4f 100755 --- a/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c +++ b/targets/ARCH/EXMIMO/DRIVER/eurecom/module_main.c @@ -190,15 +190,13 @@ static int __init openair_init_module( void ) mmio_length[card] = pci_resource_len (pdev[card], 0); mmio_flags[card] = pci_resource_flags(pdev[card], 0); - if (check_mem_region(mmio_start[card],256) < 0) { + if (request_mem_region(mmio_start[card],256,"openair_rf") == NULL) { printk("[openair][INIT_MODULE][FATAL] : Cannot get memory region 0, aborting\n"); mmio_start[card] = 0; openair_cleanup(); return -EBUSY; } else - printk("[openair][INIT_MODULE][INFO] : Reserving memory region 0 : mmio_start = 0x%x\n",(unsigned int)mmio_start[card]); - - request_mem_region(mmio_start[card], 256, "openair_rf"); + printk("[openair][INIT_MODULE][INFO] : Reserved memory region 0 : mmio_start = 0x%x\n",(unsigned int)mmio_start[card]); bar[card] = pci_iomap( pdev[card], 0, mmio_length[card] ); // get virtual kernel address for BAR0