From a6137e7cfdcbfa02e1ae31488337221e21adf9c2 Mon Sep 17 00:00:00 2001
From: navid <navid@mycompany.com>
Date: Wed, 30 Sep 2015 10:55:40 +0000
Subject: [PATCH] * add X2AP messages and generate libx2ap_LIB (currently
 enabled for oaisim)

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7854 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 cmake_targets/CMakeLists.txt                  |  62 +-
 cmake_targets/tools/asn1tostruct.py           | 706 ++++++++++++++++++
 openair2/UTIL/LOG/log.h                       |   1 +
 .../ASN1/R11.2/X2AP-CommonDataTypes.asn       | 108 ++-
 .../X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn     | 171 ++++-
 .../MESSAGES/ASN1/R11.2/X2AP-PDU-Contents.asn | 169 +----
 .../X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU.asn     |  54 +-
 openair2/X2AP/MESSAGES/ASN1/asn1tostruct.py   | 102 ++-
 openair2/X2AP/x2ap_common.h                   |  53 +-
 9 files changed, 1208 insertions(+), 218 deletions(-)
 create mode 100644 cmake_targets/tools/asn1tostruct.py

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index d300c6702..d398459d0 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -296,7 +296,7 @@ set(S1AP_ASN_FILES
   ${S1AP_ASN_DIR}/S1AP-PDU.asn
   )
 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})
 file(GLOB S1AP_source ${S1AP_C_DIR}/*.c)
 
@@ -351,6 +351,58 @@ add_library(S1AP_EPC
   ${S1AP_DIR}/s1ap_mme_retransmission.c
   ${S1AP_DIR}/s1ap_mme_ta.c
   )
+
+#X2AP
+# Same limitation as described in RRC/S1AP: unknown generated file list
+# so we generate it at cmake time
+##############
+add_list1_option(X2AP_VERSION R11 "X2AP Asn.1 grammar version" R10 R11)
+set(X2AP_DIR ${OPENAIR2_DIR}/X2AP)
+if (${X2AP_VERSION} STREQUAL "R11")
+  set (ASN1RELDIR R11.2)
+elseif (${X2AP_VERSION} STREQUAL "R10")
+  set (ASN1RELDIR R.UNKNOWN)
+endif(${X2AP_VERSION} STREQUAL "R11")
+set(X2AP_ASN_DIR ${X2AP_DIR}/MESSAGES/ASN1/${ASN1RELDIR})
+set(X2AP_ASN_FILES
+  ${X2AP_ASN_DIR}/X2AP-CommonDataTypes.asn
+  ${X2AP_ASN_DIR}/X2AP-Constants.asn
+  ${X2AP_ASN_DIR}/X2AP-IEs.asn
+  ${X2AP_ASN_DIR}/X2AP-PDU.asn
+  ${X2AP_ASN_DIR}/X2AP-Containers.asn
+  )
+
+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})
+file(GLOB X2AP_source ${X2AP_C_DIR}/*.c)
+
+set(X2AP_OAI_generated
+  ${X2AP_C_DIR}/x2ap_decoder.c
+  ${X2AP_C_DIR}/x2ap_encoder.c
+  ${X2AP_C_DIR}/x2ap_xer_print.c
+  ${X2AP_C_DIR}/x2ap_ies_defs.h
+  )
+file(GLOB x2ap_h ${X2AP_C_DIR}/*.h)
+set(x2ap_h ${x2ap_h} )
+
+#message("calling ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR}")
+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}
+  DEPENDS ${X2AP_ASN_FILES}
+  )
+
+add_library(X2AP_LIB
+  ${X2AP_OAI_generated}
+  ${X2AP_source}
+  ${X2AP_DIR}/x2ap_common.c
+  )
+
+include_directories ("${X2AP_C_DIR}")
+include_directories ("${X2AP_DIR}")
+
 # Hardware dependant options
 ###################################
 add_list1_option(NB_ANTENNAS_RX "2" "Number of antennas in reception" "1" "2" "4")
@@ -614,8 +666,8 @@ include_directories("${OPENAIRCN_DIR}/NAS/COMMON/IES")
 include_directories("${OPENAIRCN_DIR}/NAS/COMMON/UTIL")
 include_directories("${OPENAIRCN_DIR}/SECU")
 include_directories("${OPENAIRCN_DIR}/SCTP")
-include_directories("${OPENAIR2_DIR}/X2AP")
 include_directories("${OPENAIRCN_DIR}/S1AP")
+include_directories("${OPENAIR2_DIR}/X2AP")
 include_directories("${OPENAIRCN_DIR}/UDP")
 include_directories("${OPENAIRCN_DIR}/GTPV1-U")
 include_directories("${OPENAIR_DIR}/targets/COMMON")
@@ -1781,6 +1833,7 @@ Message("-- HW_SOURCE=${HW_SOURCE}")
 add_executable(oaisim
   ${rrc_h}
   ${s1ap_h}
+  ${x2ap_h}
   ${OPENAIR_BIN_DIR}/messages_xml.h
   ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c
@@ -1804,7 +1857,7 @@ add_executable(oaisim
 target_include_directories(oaisim PUBLIC  ${OPENAIR_TARGETS}/SIMU/USER)
 target_link_libraries (oaisim
   -Wl,--start-group
-  RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB}  ${MIH_LIB}
+  RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB}  ${MIH_LIB}
   -Wl,--end-group )
 
 target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
@@ -1820,6 +1873,7 @@ target_link_libraries (oaisim forms)
 add_executable(oaisim_nos1
   ${rrc_h}
   ${s1ap_h}
+  ${x2ap_h}
   ${OPENAIR_BIN_DIR}/messages_xml.h
   ${OPENAIR_TARGETS}/SIMU/USER/channel_sim.c
   ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c
@@ -1839,7 +1893,7 @@ add_executable(oaisim_nos1
 target_include_directories(oaisim_nos1 PUBLIC  ${OPENAIR_TARGETS}/SIMU/USER)
 target_link_libraries (oaisim_nos1
   -Wl,--start-group
-  RRC_LIB    SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} SIMU SIMU_ETH SECU_OSA ${ITTI_LIB}  ${MIH_LIB}
+  RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} SIMU SIMU_ETH SECU_OSA ${ITTI_LIB}  ${MIH_LIB}
   -Wl,--end-group )
 
 target_link_libraries (oaisim_nos1 ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
diff --git a/cmake_targets/tools/asn1tostruct.py b/cmake_targets/tools/asn1tostruct.py
new file mode 100644
index 000000000..c298e8ae8
--- /dev/null
+++ b/cmake_targets/tools/asn1tostruct.py
@@ -0,0 +1,706 @@
+import re, os, sys, string
+import datetime
+import getopt
+import getpass
+
+version = "1.0.2"
+
+lines = ""
+iesDefs = {}
+ieofielist = {}
+outdir = './'
+
+filenames = []
+verbosity = 0
+prefix = ""
+
+FAIL = '\033[91m'
+WARN = '\033[93m'
+ENDC = '\033[0m'
+
+fileprefix = ""
+fileprefix_first_upper = ""
+
+def printFail(string):
+    sys.stderr.write(FAIL + string + ENDC + "\n")
+
+def printWarning(string):
+    print WARN + string + ENDC
+
+def printDebug(string):
+    if verbosity > 0:
+        print string
+
+def outputHeaderToFile(f, filename):
+    now = datetime.datetime.now()
+    f.write("""/*******************************************************************************
+
+  Eurecom OpenAirInterface
+  Copyright(c) 1999 - 2013 Eurecom
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information
+  Openair Admin: openair_admin@eurecom.fr
+  Openair Tech : openair_tech@eurecom.fr
+  Forums       : http://forums.eurecom.fr/openairinterface
+  Address      : EURECOM, Campus SophiaTech, 450 Route des Chappes
+                 06410 Biot FRANCE
+
+*******************************************************************************/
+
+""")
+    f.write("/*******************************************************************************\n")
+    f.write(" * This file had been created by asn1tostruct.py script v%s\n" % (version))
+    f.write(" * Please do not modify this file but regenerate it via script.\n")
+    f.write(" * Created on: %s by %s\n * from %s\n" % (str(now), getpass.getuser(), filenames))
+    f.write(" ******************************************************************************/\n")
+
+def lowerFirstCamelWord(word):
+    """ puts the first word in a CamelCase Word in lowercase.
+
+    I.e. CustomerID becomes customerID, XMLInfoTest becomes xmlInfoTest
+    """
+    newstr = ''
+    swapped = word.swapcase()
+    idx = 0
+
+    # if it's all-caps, return an all-lowered version
+    lowered = word.lower()
+
+    if swapped == lowered:
+        return lowered
+
+    for c in swapped:
+        if c in string.lowercase:
+            newstr += c
+            idx    += 1
+        else:
+            break
+    if idx < 2:
+        newstr += word[idx:]
+    else:
+        newstr = newstr[:-1]+ word[idx-1:]
+
+    return newstr
+
+def usage():
+    print "Python parser for asn1 v%s" % (version)
+    print "Usage: python asn1tostruct.py [options]"
+    print "Available options:"
+    print "-d        Enable script debug"
+    print "-f [file] Input file to parse"
+    print "-o [dir]  Output files to given directory"
+    print "-h        Print this help and return"
+
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "df:ho:", ["debug", "file", "help", "outdir"])
+except getopt.GetoptError as err:
+    # print help information and exit:
+    usage()
+    sys.exit(2)
+
+for o, a in opts:
+    if o in ("-f", "--file"):
+        filenames.append(a)
+    if o in ("-d", "--debug"):
+        verbosity = 1
+    if o in ("-o", "--outdir"):
+        outdir = a
+        if outdir.rfind('/') != len(outdir):
+            outdir += '/'
+    if o in ("-h", "--help"):
+        usage()
+        sys.exit(2)
+
+for filename in filenames:
+    file = open(filename, 'r')
+    for line in file:
+        # Removing any comment
+        if line.find('--') >= 0:
+            line = line[:line.find('--')]
+        # Removing any carriage return
+        lines += re.sub('\r', '', line)
+
+    for m in re.findall(r'([a-zA-Z0-9-]+)\s*::=\s+SEQUENCE\s+\(\s*SIZE\s*\(\s*\d+\s*\.\.\s*[0-9a-zA-Z-]+\s*\)\s*\)\s*OF\s+[a-zA-Z-]+\s*\{\s*\{\s*([0-9a-zA-Z-]+)\s*\}\s*\}', lines, re.MULTILINE):
+        ieofielist[m[0]] = m[1]
+    for m in re.findall(r'([a-zA-Z0-9-]+)\s*::=\s+E-RAB-IE-ContainerList\s*\{\s*\{\s*([a-zA-Z0-9-]+)\s*\}\s*\}', lines, re.MULTILINE):
+        ieofielist[m[0]] = m[1]
+
+    for i in re.findall(r'([a-zA-Z0-9-]+)\s+([A-Z0-9-]+)\s*::=\s*\{\s+([\,\|\{\}\t\n\.{3}\ \-a-zA-Z0-9]+)\s+}\n', lines, re.MULTILINE):
+        ies = []
+        maxLength = 0
+        # TODO: handle extensions
+        if i[1].find('EXTENSION') >= 0:
+            continue
+        if fileprefix == "":
+            fileprefix = i[1][:i[1].find('-')].lower()
+        for j in re.findall(r'\s*\{\s*([a-zA-Z0-9-\ \t]+)\s*\}\s*[\|,]*', i[2], re.MULTILINE):
+            for k in re.findall(r'ID\s*([a-zA-Z0-9\-]+)\s*CRITICALITY\s*([a-zA-Z0-9\-]+)\s+[A-Z]+\s+([a-zA-Z0-9\-]+)\s*PRESENCE\s*([a-zA-Z0-9\-]+)', j, re.MULTILINE):
+                printDebug("Got new ie for message " + i[0] + ": " + str(k))
+                if len(k[2]) > maxLength:
+                    maxLength = len(k[2])
+                ies.append(k)
+
+        if len(ies) > 0:
+            iesDefs[i[0]] = { "length": maxLength, "ies": ies }
+        else:
+            printWarning("Didn't find any information element for message: " + i[0])
+
+if len(iesDefs) == 0:
+    printFail("No Information Element parsed, exiting")
+    sys.exit(0)
+
+fileprefix_first_upper = fileprefix[0].upper() + fileprefix[1:]
+
+f = open(outdir + fileprefix + '_ies_defs.h', 'w')
+outputHeaderToFile(f, filename)
+f.write("#include \"%s_common.h\"\n\n" % (fileprefix))
+f.write("#ifndef %s_IES_DEFS_H_\n#define %s_IES_DEFS_H_\n\n" % (fileprefix.upper(), fileprefix.upper()))
+f.write("/* Define the version of script used to generate this file */\n")
+f.write("#define %s_SCRIPT_VERSION (%s)\n\n" % (fileprefix.upper(), re.sub('\.', '', version)))
+
+for key in iesDefs:
+
+    if key not in ieofielist.values():
+        continue
+
+    for (i, j) in ieofielist.items():
+        if j == key:
+            break
+
+    f.write("typedef struct %sIEs_s {\n" % (re.sub('-', '_', i)))
+    f.write("    A_SEQUENCE_OF(struct %s_s) %s;\n" % (re.sub('IEs', '', re.sub('-', '_', ieofielist[i])), lowerFirstCamelWord(re.sub('IEs', '', re.sub('-', '_', ieofielist[i])))))
+    f.write("} %sIEs_t;\n\n" % (re.sub('-', '_', i)))
+
+for key in iesDefs:
+    keyupperunderscore = re.sub('-', '_', key.upper())
+    keylowerunderscore = re.sub('-', '_', key.lower())
+    shift = 0
+
+    if len(iesDefs[key]["ies"]) == 0:
+        continue
+
+    # Presence mask
+    for ie in iesDefs[key]["ies"]:
+        ieupperunderscore = re.sub('-', '_', re.sub('id-', '', ie[0])).upper()
+
+        if ie[3] == "optional" or ie[3] == "conditional":
+            f.write("#define {0:<{pad}} {1}\n".format("%s_%s_PRESENT" % (keyupperunderscore, ieupperunderscore), "(1 << %d)" % shift,
+            pad=iesDefs[key]["length"] + len(keyupperunderscore) + 9))
+            shift += 1
+    if (shift > 0):
+        f.write("\n")
+
+    f.write("typedef struct %s_s {\n" % (re.sub('-', '_', key)))
+    if (shift > 0):
+        f.write("    {0:<{pad}} {1};\n".format("uint16_t", "presenceMask", pad=iesDefs[key]["length"] + 2))
+    for ie in iesDefs[key]["ies"]:
+        ieunderscore = re.sub('-', '_', ie[2])
+        iename = re.sub('id-', '', ie[0])
+        ienameunderscore = lowerFirstCamelWord(re.sub('-', '_', iename))
+        if ie[2] in ieofielist:
+            f.write("    %sIEs_t %s;" % (re.sub('-', '_', ie[2]), ienameunderscore))
+        else:
+            f.write("    {0:<{pad}} {1};".format("%s_t" % ieunderscore, ienameunderscore, pad=iesDefs[key]["length"] + 2))
+        if ie[3] == "optional":
+            f.write(" ///< Optional field")
+        elif ie[3] == "conditional":
+            f.write(" ///< Conditional field")
+        f.write("\n")
+
+    f.write("} %s_t;\n\n" % (re.sub('-', '_', key)))
+
+f.write("typedef struct %s_message_s {\n" % (fileprefix))
+f.write("    %s_ProcedureCode_t procedureCode;\n" % (fileprefix_first_upper))
+f.write("    %s_Criticality_t   criticality;\n" % (fileprefix_first_upper))
+f.write("    uint8_t            direction;\n")
+f.write("    union {\n")
+
+messageList = iesDefs.keys()
+messageList.sort()
+for message in messageList:
+    if message in ieofielist.values():
+        continue
+    if len(iesDefs[message]["ies"]) == 0:
+        continue
+    f.write("        %s_t %s;\n" % (re.sub('-', '_', message), lowerFirstCamelWord(re.sub('-', '_', message))))
+f.write("    } msg;\n")
+f.write("} %s_message;\n\n" % (fileprefix))
+
+for key in iesDefs:
+    if key in ieofielist.values():
+        continue
+    structName = re.sub('ies', '', key)
+    asn1cStruct = re.sub('-', '_', re.sub('IEs', '', re.sub('-IEs', '', key)))
+    asn1cStruct = re.sub('Item', 'List', asn1cStruct)
+    keylowerunderscore = re.sub('-', '_', key.lower())
+    firstlower = re.sub('Item', 'List', re.sub('enb', 'eNB', lowerFirstCamelWord(asn1cStruct)))
+    f.write("/** \\brief Decode function for %s ies.\n" % (key))
+    if len(iesDefs[key]["ies"]) != 0:
+        f.write(" * \\param %s Pointer to ASN1 structure in which data will be stored\n" % (lowerFirstCamelWord(re.sub('-', '_', key))))
+    f.write(" *  \\param any_p Pointer to the ANY value to decode.\n")
+    f.write(" **/\n")
+    f.write("int %s_decode_%s(\n" % (fileprefix, keylowerunderscore))
+
+    if len(iesDefs[key]["ies"]) != 0:
+        f.write("    %s_t *%s,\n" % (re.sub('-', '_', key), lowerFirstCamelWord(re.sub('-', '_', key))))
+    f.write("    ANY_t *any_p);\n\n")
+
+    if len(iesDefs[key]["ies"]) == 0:
+        continue
+
+    f.write("/** \\brief Encode function for %s ies.\n" % (key))
+    f.write(" *  \\param %s Pointer to the ASN1 structure.\n" % (firstlower))
+    f.write(" *  \\param %s Pointer to the IES structure.\n" % (lowerFirstCamelWord(re.sub('-', '_', key))))
+    f.write(" **/\n")
+    f.write("int %s_encode_%s(\n" % (fileprefix, re.sub('-', '_', structName.lower())))
+    f.write("    %s_t *%s,\n" % (asn1cStruct, firstlower))
+    f.write("    %s_t *%s);\n\n" % (re.sub('-', '_', key), lowerFirstCamelWord(re.sub('-', '_', key))))
+
+for key in iesDefs:
+    if key not in ieofielist.values():
+        continue
+    asn1cStruct = re.sub('-', '_', re.sub('IEs', '', key))
+    asn1cStruct = re.sub('Item', 'List', asn1cStruct)
+    firstlower = re.sub('Item', 'List', re.sub('enb', 'eNB', lowerFirstCamelWord(asn1cStruct)))
+    f.write("/** \\brief Encode function for %s ies.\n" % (key))
+    f.write(" *  \\param %s Pointer to the ASN1 structure.\n" % (firstlower))
+    f.write(" *  \\param %s Pointer to the IES structure.\n" % (lowerFirstCamelWord(re.sub('-', '_', key))))
+    f.write(" **/\n")
+    f.write("int %s_encode_%s(\n" % (fileprefix, firstlower.lower()))
+    f.write("    %s_t *%s,\n" % (asn1cStruct, firstlower))
+    f.write("    %sIEs_t *%sIEs);\n\n" % (asn1cStruct, firstlower))
+    f.write("/** \\brief Decode function for %s ies.\n" % (key))
+    f.write(" *  \\param any_p Pointer to the ANY value to decode.\n")
+    f.write(" *  \\param callback Callback function called when any_p is successfully decoded.\n")
+    f.write(" **/\n")
+    f.write("int %s_decode_%s(\n" % (fileprefix, firstlower.lower()))
+    f.write("    %sIEs_t *%sIEs,\n" % (asn1cStruct, firstlower))
+    f.write("    %s_t *%s);\n\n" % (asn1cStruct, lowerFirstCamelWord(asn1cStruct)))
+
+for key in iesDefs:
+    asn1cStruct = re.sub('-', '_', re.sub('IEs', '', key))
+    asn1cStruct = re.sub('Item', 'List', asn1cStruct)
+    firstlower = re.sub('Item', 'List', re.sub('enb', 'eNB', lowerFirstCamelWord(asn1cStruct)))
+
+    if key in ieofielist.values():
+        f.write("/** \\brief Display %s encapsulated IE using XER encoding.\n" % (asn1cStruct))
+        f.write(" *  \\param %s Pointer to the IES structure.\n" % (lowerFirstCamelWord(re.sub('-', '_', key))))
+        f.write(" *  \\param file File descriptor to write output.\n")
+        f.write(" **/\n")
+        f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('item', 'list', firstlower.lower())))
+        f.write("    asn_app_consume_bytes_f *cb,\n")
+        f.write("    void *app_key,\n")
+        f.write("    %sIEs_t *%sIEs);\n\n" % (re.sub('item', 'list', asn1cStruct), firstlower))
+    else:
+        f.write("/** \\brief Display %s message using XER encoding.\n" % (asn1cStruct))
+        f.write(" *  \\param message_p Pointer to root message.\n")
+        f.write(" *  \\param file File descriptor to write output.\n")
+        f.write(" **/\n")
+        f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, firstlower.lower()))
+        f.write("    asn_app_consume_bytes_f *cb,\n")
+        f.write("    void *app_key,\n")
+        f.write("    %s_message *message_p);\n\n" % (fileprefix))
+
+f.write("int %s_xer__print2sp(const void *buffer, size_t size, void *app_key);\n\n" % (fileprefix.lower()))
+f.write("int %s_xer__print2fp(const void *buffer, size_t size, void *app_key);\n\n" % (fileprefix.lower()))
+f.write("extern size_t %s_string_total_size;\n\n" % (fileprefix.lower()))
+f.write("#endif /* %s_IES_DEFS_H_ */\n\n" % (fileprefix.upper()))
+
+#Generate Decode functions
+f = open(outdir + fileprefix + '_decoder.c', 'w')
+outputHeaderToFile(f, filename)
+f.write("#include \"%s_common.h\"\n#include \"%s_ies_defs.h\"\n\n" % (fileprefix, fileprefix))
+for key in iesDefs:
+    if key in ieofielist.values():
+        continue
+    structName = re.sub('ies', '', key)
+    asn1cStruct = re.sub('-', '_', re.sub('IEs', '', key))
+    if asn1cStruct.rfind('_') == len(asn1cStruct) - 1:
+        asn1cStruct = asn1cStruct[:-1]
+    asn1cStruct = re.sub('Item', 'List', asn1cStruct)
+    ielistname = re.sub('UE', 'ue', asn1cStruct)
+    ielistnamefirstlower = ielistname[:1].lower() + ielistname[1:]
+    asn1cStructfirstlower = asn1cStruct[:1].lower() + asn1cStruct[1:]
+    keyName = re.sub('-', '_', key)
+    keyupperunderscore = keyName.upper()
+    firstlower = re.sub('Item', 'List', re.sub('enb', 'eNB', lowerFirstCamelWord(asn1cStruct)))
+
+    iesaccess = ""
+    if key not in ieofielist.values():
+        iesaccess = "%s_ies." % (firstlower)
+
+    f.write("int %s_decode_%s(\n" % (fileprefix, re.sub('-', '_', structName.lower())))
+    if len(iesDefs[key]["ies"]) != 0:
+        f.write("    %s_t *%s,\n" % (re.sub('-', '_', key), lowerFirstCamelWord(re.sub('-', '_', key))))
+    f.write("    ANY_t *any_p) {\n\n")
+
+    f.write("    %s_t  %s;\n    %s_t *%s_p = &%s;\n" % (asn1cStruct, asn1cStructfirstlower, asn1cStruct, asn1cStructfirstlower, asn1cStructfirstlower))
+    f.write("    int i, decoded = 0;\n")
+    if len(iesDefs[key]["ies"]) != 0:
+        f.write("    int tempDecoded = 0;\n")
+
+    f.write("    assert(any_p != NULL);\n")
+    if len(iesDefs[key]["ies"]) != 0:
+        f.write("    assert(%s != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', key))))
+
+    f.write("    %s_DEBUG(\"Decoding message %s (%%s:%%d)\\n\", __FILE__, __LINE__);\n\n" % (fileprefix.upper(), re.sub('-', '_', keyName)))
+    f.write("    ANY_to_type_aper(any_p, &asn_DEF_%s, (void**)&%s_p);\n\n" % (asn1cStruct, asn1cStructfirstlower))
+    f.write("    for (i = 0; i < %s_p->%slist.count; i++) {\n" % (asn1cStructfirstlower, iesaccess))
+    f.write("        %s_IE_t *ie_p;\n" % (fileprefix[0].upper() + fileprefix[1:]))
+    f.write("        ie_p = %s_p->%slist.array[i];\n" % (asn1cStructfirstlower, iesaccess))
+    f.write("        switch(ie_p->id) {\n")
+    for ie in iesDefs[key]["ies"]:
+        iename = re.sub('id-', '', ie[0])
+        ienameunderscore = lowerFirstCamelWord(re.sub('-', '_', iename))
+        ienameunderscorefirstlower = lowerFirstCamelWord(ienameunderscore)
+        ietypesubst = re.sub('-', '', ie[2])
+        ietypeunderscore = re.sub('-', '_', ie[2])
+        ieupperunderscore = re.sub('-', '_', re.sub('id-', '', ie[0])).upper()
+
+        if ie[3] == "optional":
+            f.write("            /* Optional field */\n")
+        elif ie[3] == "conditional":
+            f.write("            /* Conditional field */\n")
+        f.write("            case %s_ProtocolIE_ID_%s:\n" % (fileprefix_first_upper, re.sub('-', '_', ie[0])))
+        f.write("            {\n")
+        f.write("                %s_t *%s_p = NULL;\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
+        if ie[3] != "mandatory":
+            f.write("                %s->presenceMask |= %s_%s_PRESENT;\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), keyupperunderscore, ieupperunderscore))
+        f.write("                tempDecoded = ANY_to_type_aper(&ie_p->value, &asn_DEF_%s, (void**)&%s_p);\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
+        f.write("                if (tempDecoded < 0 || %s_p == NULL) {\n" % (lowerFirstCamelWord(ietypesubst)))
+        f.write("                    %s_ERROR(\"Decoding of IE %s failed\\n\");\n" % (fileprefix.upper(), ienameunderscore))
+        f.write("                    if (%s_p)\n" % (lowerFirstCamelWord(ietypesubst)))
+        f.write("                        ASN_STRUCT_FREE(asn_DEF_%s, %s_p);\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
+        f.write("                    return -1;\n")
+        f.write("                }\n")
+        f.write("                decoded += tempDecoded;\n")
+        f.write("                if (asn1_xer_print)\n")
+        f.write("                    xer_fprint(stdout, &asn_DEF_%s, %s_p);\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
+        if ie[2] in ieofielist.keys():
+            f.write("                if (%s_decode_%s(&%s->%s, %s_p) < 0) {\n" % (fileprefix, ietypeunderscore.lower(), lowerFirstCamelWord(re.sub('-', '_', key)), ienameunderscore, lowerFirstCamelWord(ietypesubst)))
+            f.write("                    %s_ERROR(\"Decoding of encapsulated IE %s failed\\n\");\n" % (fileprefix.upper(), lowerFirstCamelWord(ietypesubst)))
+            f.write("                    ASN_STRUCT_FREE(asn_DEF_%s, %s_p);\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
+            f.write("                }\n")
+        else:
+            f.write("                memcpy(&%s->%s, %s_p, sizeof(%s_t));\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), ienameunderscore, lowerFirstCamelWord(ietypesubst), ietypeunderscore))
+            #f.write("                ASN_STRUCT_FREE(asn_DEF_%s, %s_p);\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
+        f.write("            } break;\n")
+    f.write("            default:\n")
+    f.write("                %s_ERROR(\"Unknown protocol IE id (%%d) for message %s\\n\", (int)ie_p->id);\n" % (fileprefix.upper(), re.sub('-', '_', structName.lower())))
+    f.write("                return -1;\n")
+    f.write("        }\n")
+    f.write("    }\n")
+    f.write("    return decoded;\n")
+    f.write("}\n\n")
+
+for key in iesDefs:
+    if key not in ieofielist.values():
+        continue
+
+    keyname = re.sub('IEs', '', re.sub('Item', 'List', key))
+
+    f.write("int %s_decode_%s(\n" % (fileprefix, re.sub('-', '_', keyname).lower()))
+    f.write("    %sIEs_t *%sIEs,\n" % (re.sub('-', '_', keyname), lowerFirstCamelWord(re.sub('-', '_', keyname))))
+    f.write("    %s_t *%s) {\n\n" % (re.sub('-', '_', keyname), lowerFirstCamelWord(re.sub('-', '_', keyname))))
+    f.write("    int i, decoded = 0;\n")
+    f.write("    int tempDecoded = 0;\n\n")
+
+    f.write("    assert(%s != NULL);\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname))));
+    f.write("    assert(%sIEs != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname))));
+
+    f.write("    for (i = 0; i < %s->list.count; i++) {\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname))))
+    f.write("        %s_IE_t *ie_p = %s->list.array[i];\n" % (fileprefix[0].upper() + fileprefix[1:], lowerFirstCamelWord(re.sub('-', '_', keyname))))
+    f.write("        switch (ie_p->id) {\n")
+    for ie in iesDefs[key]["ies"]:
+        iename = re.sub('id-', '', ie[0])
+        ienameunderscore = lowerFirstCamelWord(re.sub('-', '_', iename))
+        f.write("            case %s_ProtocolIE_ID_%s:\n" % (fileprefix_first_upper, re.sub('-', '_', ie[0])))
+        f.write("            {\n")
+        f.write("                %s_t *%s_p = NULL;\n" % (re.sub('-', '_', ie[2]), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("                tempDecoded = ANY_to_type_aper(&ie_p->value, &asn_DEF_%s, (void**)&%s_p);\n" % (re.sub('-', '_', ie[2]), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("                if (tempDecoded < 0 || %s_p == NULL) {\n" % (lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("                    %s_ERROR(\"Decoding of IE %s for message %s failed\\n\");\n" % (fileprefix.upper(), ienameunderscore, re.sub('-', '_', keyname)))
+        f.write("                    if (%s_p)\n" % (lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        #f.write("                        free(%s_p);\n" % (lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("                        ASN_STRUCT_FREE(asn_DEF_%s, %s_p);\n" % (re.sub('-', '_', ie[2]), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("                    return -1;\n")
+        f.write("                }\n")
+        f.write("                decoded += tempDecoded;\n")
+        f.write("                if (asn1_xer_print)\n")
+        f.write("                    xer_fprint(stdout, &asn_DEF_%s, %s_p);\n" % (re.sub('-', '_', ie[2]), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("                ASN_SEQUENCE_ADD(&%sIEs->%s, %s_p);\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname)),
+        re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key))), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
+        f.write("            } break;\n")
+    f.write("            default:\n")
+    f.write("                %s_ERROR(\"Unknown protocol IE id (%%d) for message %s\\n\", (int)ie_p->id);\n" % (fileprefix.upper(), re.sub('-', '_', structName.lower())))
+    f.write("                return -1;\n")
+    f.write("        }\n")
+    f.write("    }\n")
+    f.write("    return decoded;\n")
+    f.write("}\n\n")
+
+
+#Generate IES Encode functions
+f = open(outdir + fileprefix + '_encoder.c', 'w')
+outputHeaderToFile(f,filename)
+f.write("#include \"%s_common.h\"\n" % (fileprefix))
+f.write("#include \"%s_ies_defs.h\"\n\n" % (fileprefix))
+for key in iesDefs:
+    if key in ieofielist.values():
+        continue
+
+    structName = re.sub('ies', '', key)
+    asn1cStruct = re.sub('-', '_', re.sub('IEs', '', key))
+    asn1cStruct = re.sub('Item', 'List', asn1cStruct)
+    if asn1cStruct.rfind('_') == len(asn1cStruct) - 1:
+        asn1cStruct = asn1cStruct[:-1]
+    asn1cStructfirstlower = asn1cStruct[:1].lower() + asn1cStruct[1:]
+    firstwordlower = re.sub('Item', 'List', re.sub('enb', 'eNB', lowerFirstCamelWord(asn1cStruct)))
+
+    iesaccess = ""
+    if key not in ieofielist.values():
+        iesaccess = "%s_ies." % (firstwordlower)
+
+    keyName = re.sub('-', '_', key)
+    keyupperunderscore = keyName.upper()
+    # No IE to encode...
+    if len(iesDefs[key]["ies"]) == 0:
+        continue
+
+    f.write("int %s_encode_%s(\n" % (fileprefix, re.sub('-', '_', structName.lower())))
+    f.write("    %s_t *%s,\n" % (asn1cStruct, firstwordlower))
+    f.write("    %s_t *%s) {\n\n" % (re.sub('-', '_', key), lowerFirstCamelWord(re.sub('-', '_', key))))
+
+    f.write("    %s_IE_t *ie;\n\n" % (fileprefix_first_upper))
+
+    f.write("    assert(%s != NULL);\n" % (firstwordlower));
+    f.write("    assert(%s != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', key))));
+
+    for ie in iesDefs[key]["ies"]:
+        iename = re.sub('-', '_', re.sub('id-', '', ie[0]))
+        ienameunderscore = re.sub('-', '_', iename)
+        ienamefirstwordlower = lowerFirstCamelWord(iename)
+        ieupperunderscore = re.sub('-', '_', re.sub('id-', '', ie[0])).upper()
+        ietypeunderscore = re.sub('-', '_', ie[2])
+
+        if ie[3] != "mandatory":
+            if ie[3] == "optional":
+                f.write("    /* Optional field */\n")
+            elif ie[3] == "conditional":
+                f.write("    /* Conditional field */\n")
+            f.write("    if (%s->presenceMask & %s_%s_PRESENT) {\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), keyupperunderscore, ieupperunderscore))
+            #f.write("        == %s_%s_PRESENT) {\n" % (keyupperunderscore, ieupperunderscore))
+            f.write("        if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,\n" % (fileprefix, fileprefix_first_upper, re.sub('-', '_', ie[0])))
+            f.write("                            %s_Criticality_%s,\n" % (fileprefix_first_upper, ie[1]))
+            f.write("                            &asn_DEF_%s,\n" % (ietypeunderscore))
+            f.write("                            &%s->%s)) == NULL) {\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), ienamefirstwordlower))
+            f.write("            return -1;\n")
+            f.write("        }\n")
+            f.write("        ASN_SEQUENCE_ADD(&%s->%slist, ie);\n" % (firstwordlower, iesaccess))
+            f.write("    }\n\n")
+        else:
+            if ie[2] in ieofielist.keys():
+                f.write("    %s_t %s;\n\n" % (ietypeunderscore, ienamefirstwordlower))
+                f.write("    memset(&%s, 0, sizeof(%s_t));\n" % (ienamefirstwordlower, ietypeunderscore))
+                f.write("\n")
+                f.write("    if (%s_encode_%s(&%s, &%s->%s) < 0) return -1;\n" % (fileprefix, ietypeunderscore.lower(), ienamefirstwordlower, lowerFirstCamelWord(re.sub('-', '_', key)), ienamefirstwordlower))
+            f.write("    if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,\n" % (fileprefix, fileprefix_first_upper, re.sub('-', '_', ie[0])))
+            f.write("                        %s_Criticality_%s,\n" % (fileprefix_first_upper, ie[1]))
+            f.write("                        &asn_DEF_%s,\n" % (ietypeunderscore))
+            if ie[2] in ieofielist.keys():
+                f.write("                          &%s)) == NULL) {\n" % (ienamefirstwordlower))
+            else:
+                f.write("                          &%s->%s)) == NULL) {\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), ienamefirstwordlower))
+            f.write("        return -1;\n")
+            f.write("    }\n")
+            f.write("    ASN_SEQUENCE_ADD(&%s->%slist, ie);\n\n" % (firstwordlower, iesaccess))
+            if ie[2] in ieofielist.keys():
+                f.write("    /* Free any dynamic allocation that is no more used */\n")
+                f.write("    ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_%s, &%s);\n\n" % (ietypeunderscore, ienamefirstwordlower))
+
+    f.write("    return 0;\n")
+    f.write("}\n\n")
+
+for (key, value) in iesDefs.items():
+    if key not in ieofielist.values():
+        continue
+
+    ie = value["ies"][0]
+    ietypeunderscore = re.sub('-', '_', ie[2])
+    asn1cStruct = re.sub('-', '_', re.sub('IEs', '', re.sub('-IEs', '', key)))
+    asn1cStruct = re.sub('Item', 'List', asn1cStruct)
+    firstwordlower = re.sub('Item', 'List', re.sub('enb', 'eNB', lowerFirstCamelWord(asn1cStruct)))
+
+    for (i, j) in ieofielist.items():
+        if j == key:
+            break
+    f.write("int %s_encode_%s(\n" % (fileprefix, re.sub('-', '_', i).lower()))
+    f.write("    %s_t *%s,\n" % (asn1cStruct, firstwordlower))
+    f.write("    %sIEs_t *%sIEs) {\n\n" % (re.sub('-', '_', i), lowerFirstCamelWord(re.sub('-', '_', i))))
+    f.write("    int i;\n")
+
+    f.write("    %s_IE_t *ie;\n\n" % (fileprefix_first_upper))
+
+    f.write("    assert(%s != NULL);\n" % (firstwordlower));
+    f.write("    assert(%sIEs != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', i))));
+
+    f.write("    for (i = 0; i < %sIEs->%s.count; i++) {\n" % (firstwordlower, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+    f.write("        if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,\n" % (fileprefix, fileprefix_first_upper, re.sub('-', '_', ie[0])))
+    f.write("                            %s_Criticality_%s,\n" % (fileprefix_first_upper, ie[1]))
+    f.write("                            &asn_DEF_%s,\n" % (ietypeunderscore))
+    f.write("                            %sIEs->%s.array[i])) == NULL) {\n" % (firstwordlower, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+    f.write("            return -1;\n")
+    f.write("        }\n")
+    f.write("        ASN_SEQUENCE_ADD(&%s->list, ie);\n" % (firstwordlower))
+    f.write("    }\n")
+    f.write("    return 0;\n")
+    f.write("}\n\n")
+
+#Generate xer print functions
+f = open(outdir + fileprefix + '_xer_print.c', 'w')
+outputHeaderToFile(f, filename)
+f.write("#include <stdlib.h>\n")
+f.write("#include <stdio.h>\n\n")
+f.write("#include <asn_application.h>\n#include <asn_internal.h>\n\n")
+f.write("#include \"%s_common.h\"\n#include \"%s_ies_defs.h\"\n\n" % (fileprefix, fileprefix))
+
+f.write("size_t %s_string_total_size = 0;\n\n" % (fileprefix.lower()))
+f.write("""int
+%s_xer__print2fp(const void *buffer, size_t size, void *app_key) {
+    FILE *stream = (FILE *)app_key;
+
+    if(fwrite(buffer, 1, size, stream) != size)
+        return -1;
+
+    return 0;
+}
+
+""" % (fileprefix.lower()))
+
+f.write("""int %s_xer__print2sp(const void *buffer, size_t size, void *app_key) {
+    char *string = (char *)app_key;
+
+    /* Copy buffer to the formatted string */
+    memcpy(&string[%s_string_total_size], buffer, size);
+
+    %s_string_total_size += size;
+
+    return 0;
+}
+
+""" % (fileprefix.lower(), fileprefix.lower(), fileprefix.lower()))
+
+f.write("""static asn_enc_rval_t
+xer_encode_local(asn_TYPE_descriptor_t *td, void *sptr,
+        asn_app_consume_bytes_f *cb, void *app_key, int indent) {
+    asn_enc_rval_t er, tmper;
+    const char *mname;
+    size_t mlen;
+    int xcan = 2;
+
+    if(!td || !sptr) goto cb_failed;
+
+    mname = td->xml_tag;
+    mlen = strlen(mname);
+
+    _i_ASN_TEXT_INDENT(0, indent);
+    _ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
+
+    tmper = td->xer_encoder(td, sptr, indent + 1, XER_F_BASIC, cb, app_key);
+    if(tmper.encoded == -1) return tmper;
+
+    _ASN_CALLBACK3("</", 2, mname, mlen, ">\\n", xcan);
+
+    er.encoded = 4 + xcan + (2 * mlen) + tmper.encoded;
+
+    _ASN_ENCODED_OK(er);
+cb_failed:
+    _ASN_ENCODE_FAILED;
+}
+""")
+
+for (key, value) in iesDefs.items():
+    keyName = re.sub('-', '_', key)
+    keyupperunderscore = keyName.upper()
+    iesStructName = lowerFirstCamelWord(re.sub('-', '_', key))
+
+    ie = value["ies"][0]
+    ietypeunderscore = re.sub('-', '_', ie[2])
+
+    if key in ieofielist.values():
+        f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('ies', '', re.sub('item', 'list', re.sub('-', '_', key).lower()))))
+    else:
+        f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', key).lower())))
+    #f.write("    FILE *file,\n")
+    f.write("    asn_app_consume_bytes_f *cb,\n")
+    f.write("    void *app_key,\n")
+    if key in ieofielist.values():
+        iesStructName = lowerFirstCamelWord(re.sub('Item', 'List', re.sub('-', '_', key)))
+        f.write("    %sIEs_t *%s) {\n\n" % (re.sub('IEs', '', re.sub('Item', 'List', re.sub('-', '_', key))), iesStructName))
+        f.write("    int i;\n")
+        f.write("    asn_enc_rval_t er;\n")
+    else:
+        f.write("    %s_message *message_p)\n{\n" % (fileprefix))
+        f.write("    %s_t *%s;\n" % (re.sub('-', '_', key), iesStructName))
+        f.write("    asn_enc_rval_t er;\n")
+        #f.write("    void *app_key = (void *)file;\n")
+        #f.write("    asn_app_consume_bytes_f *cb = %s_xer__print2fp;\n\n" % (fileprefix.lower()))
+
+        f.write("    %s = &message_p->msg.%s;\n\n" % (iesStructName, iesStructName))
+
+    if key in ieofielist.values():
+        # Increase indentation level
+        f.write("    for (i = 0; i < %s->%s.count; i++) {\n" % (iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+        #f.write("        xer_fprint(file, &asn_DEF_%s, %s->%s.array[i]);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+        f.write("        er = xer_encode(&asn_DEF_%s, %s->%s.array[i], XER_F_BASIC, cb, app_key);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+        f.write("    }\n")
+    else:
+        f.write("    cb(\"<%s-PDU>\\n\", %d, app_key);\n" % (key, len("<%s-PDU>\n" % (key))))
+        f.write("    xer_encode_local(&asn_DEF_%s_Criticality, &message_p->criticality, cb, app_key, 1);\n" % fileprefix_first_upper)
+        f.write("    xer_encode_local(&asn_DEF_%s_ProcedureCode, &message_p->procedureCode, cb, app_key, 1);\n" % fileprefix_first_upper)
+
+        f.write("    cb(\"    <%s>\\n\", %d, app_key);\n" % (key, len("    <%s>\n" % (key))))
+
+        for ie in iesDefs[key]["ies"]:
+            iename = re.sub('-', '_', re.sub('id-', '', ie[0]))
+            ienameunderscore = re.sub('-', '_', iename)
+            ienamefirstwordlower = lowerFirstCamelWord(iename)
+            ietypeunderscore = re.sub('-', '_', ie[2])
+            ieupperunderscore = re.sub('-', '_', re.sub('id-', '', ie[0])).upper()
+
+            if ie[3] != "mandatory":
+                if ie[3] == "optional":
+                    f.write("    /* Optional field */\n")
+                elif ie[3] == "conditional":
+                    f.write("    /* Conditional field */\n")
+                f.write("    if (%s->presenceMask & %s_%s_PRESENT)\n    " % (iesStructName, keyupperunderscore, ieupperunderscore))
+
+            # Is it an encapsulated IE ?
+            if ie[2] in ieofielist.keys():
+                f.write("    %s_xer_print_%s(cb, app_key, &%s->%s);\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', ie[2]).lower()), iesStructName, ienamefirstwordlower))
+            else:
+                f.write("    xer_encode_local(&asn_DEF_%s, &%s->%s, cb, app_key, 2);\n" % (ietypeunderscore, iesStructName, ienamefirstwordlower))
+        f.write("    cb(\"    </%s>\\n\", %d, app_key);\n" % (key, len("    </%s>\n" % (key))))
+        f.write("    cb(\"</%s-PDU>\\n\", %d, app_key);\n" % (key, len("</%s-PDU>\n" % (key))))
+
+    f.write("    _ASN_ENCODED_OK(er);\n")
+    #if key not in ieofielist.values():
+        #f.write("cb_failed:\n")
+        #f.write("    return er;\n")
+    f.write("}\n\n")
diff --git a/openair2/UTIL/LOG/log.h b/openair2/UTIL/LOG/log.h
index 724504656..c5d84689b 100755
--- a/openair2/UTIL/LOG/log.h
+++ b/openair2/UTIL/LOG/log.h
@@ -268,6 +268,7 @@ typedef enum {
   USIM,
   LOCALIZE,
   RRH,
+  X2AP,
   MAX_LOG_COMPONENTS,
 }
 comp_name_t;
diff --git a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-CommonDataTypes.asn b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-CommonDataTypes.asn
index ba88cef35..410a7d19d 100755
--- a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-CommonDataTypes.asn
+++ b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-CommonDataTypes.asn
@@ -31,12 +31,112 @@ X2ap-PrivateIE-ID	::= CHOICE {
 	global				OBJECT IDENTIFIER
 }
 
-X2ap-ProcedureCode		::= INTEGER (0..255)
+--X2ap-ProcedureCode		::= INTEGER (0..255)
+X2ap-ProcedureCode       ::= INTEGER {
+    id-handoverPreparation                                          (0),
+    id-handoverCancel                                               (1),
+    id-loadIndication                                               (2),
+    id-errorIndication                                              (3),
+    id-snStatusTransfer                                             (4),
+    id-uEContextRelease                                             (5),
+    id-x2Setup                                                      (6),
+    id-reset                                                        (7),
+    id-eNBConfigurationUpdate                                       (8),
+    id-resourceStatusReportingInitiation                            (9),
+    id-resourceStatusReporting                                      (10),
+    id-privateMessage                                               (11),
+    id-mobilitySettingsChange                                       (12),
+    id-rLFIndication                                                (13),
+    id-handoverReport                                               (14),
+    id-cellActivation                                               (15)
+} (0..255)
 
-
-X2ap-ProtocolIE-ID		::= INTEGER (0..x2ap-maxProtocolIEs)
+--X2ap-ProtocolIE-ID		::= INTEGER (0..x2ap-maxProtocolIEs)
+X2ap-ProtocolIE-ID       ::= INTEGER {
+    id-E-RABs-Admitted-Item                                                     (0),
+    id-E-RABs-Admitted-List                                                     (1),
+    id-E-RAB-Item                                                               (2),
+    id-E-RABs-NotAdmitted-List                                                  (3),
+    id-E-RABs-ToBeSetup-Item                                                    (4),
+    id-Cause                                                                    (5),
+    id-CellInformation                                                          (6),
+    id-CellInformation-Item                                                     (7),
+    id-New-eNB-UE-X2AP-ID                                                       (9),
+    id-Old-eNB-UE-X2AP-ID                                                       (10),
+    id-TargetCell-ID                                                            (11),
+    id-TargeteNBtoSource-eNBTransparentContainer                                (12),
+    id-TraceActivation                                                          (13),
+    id-UE-ContextInformation                                                    (14),
+    id-UE-HistoryInformation                                                    (15),
+    id-UE-X2AP-ID                                                               (16),
+    id-CriticalityDiagnostics                                                   (17),
+    id-E-RABs-SubjectToStatusTransfer-List                                      (18),
+    id-E-RABs-SubjectToStatusTransfer-Item                                      (19),
+    id-ServedCells                                                              (20),
+    id-GlobalENB-ID                                                             (21),
+    id-TimeToWait                                                               (22),
+    id-GUMMEI-ID                                                                (23),
+    id-GUGroupIDList                                                            (24),
+    id-ServedCellsToAdd                                                         (25),
+    id-ServedCellsToModify                                                      (26),
+    id-ServedCellsToDelete                                                      (27),
+    id-Registration-Request                                                     (28),
+    id-CellToReport                                                             (29),
+    id-ReportingPeriodicity                                                     (30),
+    id-CellToReport-Item                                                        (31),
+    id-CellMeasurementResult                                                    (32),
+    id-CellMeasurementResult-Item                                               (33),
+    id-GUGroupIDToAddList                                                       (34),
+    id-GUGroupIDToDeleteList                                                    (35),
+    id-SRVCCOperationPossible                                                   (36),
+    id-Measurement-ID                                                           (37),
+    id-ReportCharacteristics                                                    (38),
+    id-ENB1-Measurement-ID                                                      (39),
+    id-ENB2-Measurement-ID                                                      (40),
+    id-Number-of-Antennaports                                                   (41),
+    id-CompositeAvailableCapacityGroup                                          (42),
+    id-ENB1-Cell-ID                                                             (43),
+    id-ENB2-Cell-ID                                                             (44),
+    id-ENB2-Proposed-Mobility-Parameters                                        (45),
+    id-ENB1-Mobility-Parameters                                                 (46),
+    id-ENB2-Mobility-Parameters-Modification-Range                              (47),
+    id-FailureCellPCI                                                           (48),
+    id-Re-establishmentCellECGI                                                 (49),
+    id-FailureCellCRNTI                                                         (50),
+    id-ShortMAC-I                                                               (51),
+    id-SourceCellECGI                                                           (52),
+    id-FailureCellECGI                                                          (53),
+    id-HandoverReportType                                                       (54),
+    id-PRACH-Configuration                                                      (55),
+    id-MBSFN-Subframe-Info                                                      (56),
+    id-ServedCellsToActivate                                                    (57),
+    id-ActivatedCellList                                                        (58),
+    id-DeactivationIndication                                                   (59),
+    id-UE-RLF-Report-Container                                                  (60),
+    id-ABSInformation								(61),
+    id-InvokeIndication								(62),
+    id-ABS-Status								(63),
+    id-PartialSuccessIndicator							(64),
+    id-MeasurementInitiationResult-List						(65),
+    id-MeasurementInitiationResult-Item						(66),
+    id-MeasurementFailureCause-Item						(67),
+    id-CompleteFailureCauseInformation-List					(68),
+    id-CompleteFailureCauseInformation-Item					(69),
+    id-CSG-Id									(70),
+    id-CSGMembershipStatus							(71),
+    id-MDTConfiguration								(72),
+    id-ManagementBasedMDTallowed						(74),
+    id-RRCConnSetupIndicator							(75),	
+    id-NeighbourTAC								(76),
+    id-Time-UE-StayedInCell-EnhancedGranularity					(77),	
+    id-RRCConnReestabIndicator							(78),	
+    id-MBMS-Service-Area-List							(79),
+    id-HO-cause									(80),
+    id-TargetCellInUTRAN							(81),
+    id-MultibandInfoList							(84)
+} (0..x2ap-maxProtocolIEs)
 
 
 X2ap-TriggeringMessage	::= ENUMERATED { initiating-message, successful-outcome, unsuccessful-outcome}
 
-END
\ No newline at end of file
+END
diff --git a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn
index f410853d3..c76319bb7 100755
--- a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn
+++ b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn
@@ -24,11 +24,12 @@ IMPORTS
 	id-Time-UE-StayedInCell-EnhancedGranularity,
 	id-MBMS-Service-Area-List,
 	id-HO-cause,
-	x2ap-maxnoofBearers,
 	x2ap-maxCellineNB,
 	x2ap-maxEARFCN,
 	x2ap-maxInterfaces,
+	x2ap-maxFailedMeasObjects,
 	x2ap-maxnoofBands,
+	x2ap-maxnoofBearers,
 	x2ap-maxnoofBPLMNs,
 	x2ap-maxnoofCells,
 	x2ap-maxnoofEPLMNs,
@@ -54,9 +55,9 @@ FROM X2AP-CommonDataTypes
 
 --	ProtocolExtensionContainer{},
 --	ProtocolIE-Single-Container{},
---	X2AP-PROTOCOL-EXTENSION,
+	X2AP-PROTOCOL-EXTENSION
 --	X2AP-PROTOCOL-IES		
---FROM X2AP-Containers
+FROM X2AP-Containers
 
 	X2ap-IE
 FROM X2AP-PDU;
@@ -65,6 +66,13 @@ FROM X2AP-PDU;
 X2ap-IE-Extensions ::= SEQUENCE (SIZE (1..x2ap-maxProtocolExtensions)) OF X2ap-IE
 
 -- A
+X2ap-ActivatedCellList ::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ActivatedCellList-Item
+X2ap-ActivatedCellList-Item ::= SEQUENCE {
+	ecgi								X2ap-ECGI,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions						ProtocolExtensionContainer { { X2ap-ActivatedCellList-Item-ExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
 
 X2ap-ABSInformation ::= CHOICE {
 	fdd					X2ap-ABSInformationFDD,
@@ -254,6 +262,38 @@ X2ap-CellType ::= SEQUENCE {
 X2ap-CellType-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
+X2ap-CellToReport-List 		::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-IE
+--ProtocolIE-Single-Container { {X2ap-CellToReport-ItemIEs} }
+
+X2ap-CellToReport-Item ::= SEQUENCE {
+	cell-ID									X2ap-ECGI,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions							X2ap-ProtocolExtensionContainer { {CellToReport-Item-ExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
+X2ap-MeasurementFailureCause-List	::= SEQUENCE (SIZE (1..x2ap-maxFailedMeasObjects)) OF X2ap-IE
+
+X2ap-MeasurementFailureCause-Item ::= SEQUENCE {
+	measurementFailedReportCharacteristics			X2ap-ReportCharacteristics,
+	cause											X2ap-Cause,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions									ProtocolExtensionContainer { { X2ap-MeasurementFailureCause-Item-ExtIEs} }	OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
+X2ap-CellInformation-List 		::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-IE
+--ProtocolIE-Single-Container { {X2ap-CellInformation-ItemIEs} }
+
+X2ap-CellInformation-Item ::= SEQUENCE {
+	cell-ID							X2ap-ECGI,
+	ul-InterferenceOverloadIndication		X2ap-UL-InterferenceOverloadIndication		OPTIONAL,
+	ul-HighInterferenceIndicationInfo		X2ap-UL-HighInterferenceIndicationInfo		OPTIONAL,
+	relativeNarrowbandTxPower				X2ap-RelativeNarrowbandTxPower				OPTIONAL,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions							ProtocolExtensionContainer { {X2ap-CellInformation-Item-ExtIEs} }	OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
 
 X2ap-CompositeAvailableCapacityGroup	::= SEQUENCE {
 	dL-CompositeAvailableCapacity					X2ap-CompositeAvailableCapacity,
@@ -291,6 +331,29 @@ X2ap-COUNTvalue-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
 
+X2ap-CompleteFailureCauseInformation-List	::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-IE
+--ProtocolIE-Single-Container { {X2ap-CompleteFailureCauseInformation-ItemIEs} }
+
+X2ap-CompleteFailureCauseInformation-Item ::= SEQUENCE {
+	cell-ID											X2ap-ECGI,
+	measurementFailureCause-List					X2ap-MeasurementFailureCause-List,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions									ProtocolExtensionContainer { { X2ap-CompleteFailureCauseInformation-Item-ExtIEs} }	OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
+X2ap-CellMeasurementResult-List 		::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-IE
+--ProtocolIE-Single-Container { {X2ap-CellMeasurementResult-ItemIEs} }
+
+X2ap-CellMeasurementResult-Item ::= SEQUENCE {
+	cell-ID						X2ap-ECGI,
+	hWLoadIndicator				X2ap-HWLoadIndicator		OPTIONAL,
+	s1TNLLoadIndicator			X2ap-S1TNLLoadIndicator	OPTIONAL,
+	radioResourceStatus			X2ap-RadioResourceStatus	OPTIONAL,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions				X2ap-ProtocolExtensionContainer { {X2ap-CellMeasurementResult-Item-ExtIEs} }	OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
 
 X2ap-CriticalityDiagnostics ::= SEQUENCE {
 	procedureCode					X2ap-ProcedureCode					OPTIONAL,
@@ -455,6 +518,44 @@ X2ap-E-RAB-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
 
+X2ap-E-RABs-ToBeSetup-List ::= SEQUENCE (SIZE(1..x2ap-maxnoofBearers)) OF X2ap-IE
+
+X2ap-E-RABs-ToBeSetup-Item ::= SEQUENCE {
+	e-RAB-ID					X2ap-E-RAB-ID,
+	e-RAB-Level-QoS-Parameters		X2ap-E-RAB-Level-QoS-Parameters,
+	dL-Forwarding					X2ap-DL-Forwarding													OPTIONAL,
+	uL-GTPtunnelEndpoint			X2ap-GTPtunnelEndpoint,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { {X2ap-E-RABs-ToBeSetup-ItemExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
+X2ap-E-RABs-Admitted-List 		::= SEQUENCE (SIZE (1..x2ap-maxnoofBearers)) OF X2ap-IE
+--ProtocolIE-Single-Container { {X2ap-E-RABs-Admitted-ItemIEs} }
+
+X2ap-E-RABs-Admitted-Item ::= SEQUENCE {
+	e-RAB-ID					X2ap-E-RAB-ID,
+	uL-GTP-TunnelEndpoint			X2ap-GTPtunnelEndpoint	OPTIONAL,
+	dL-GTP-TunnelEndpoint			X2ap-GTPtunnelEndpoint	OPTIONAL,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { {X2ap-E-RABs-Admitted-Item-ExtIEs} }	OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
+X2ap-E-RABs-SubjectToStatusTransfer-List	::= SEQUENCE (SIZE (1..x2ap-maxnoofBearers)) OF X2ap-IE
+--ProtocolIE-Single-Container { { X2ap-E-RABs-SubjectToStatusTransfer-ItemIEs} }
+
+X2ap-E-RABs-SubjectToStatusTransfer-Item ::= SEQUENCE {
+	e-RAB-ID						X2ap-E-RAB-ID,
+	
+	receiveStatusofULPDCPSDUs		X2ap-ReceiveStatusofULPDCPSDUs			OPTIONAL,
+	uL-COUNTvalue					X2ap-COUNTvalue,
+	dL-COUNTvalue					X2ap-COUNTvalue,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions							ProtocolExtensionContainer { {X2ap-E-RABs-SubjectToStatusTransfer-ItemExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
 X2ap-EUTRANCellIdentifier ::= BIT STRING (SIZE (28))
 
 X2ap-EUTRANTraceID		::= OCTET STRING (SIZE (8))
@@ -709,6 +810,18 @@ X2ap-MDT-Activation		::= ENUMERATED {
 	...
 }
 
+
+X2ap-MeasurementInitiationResult-List	::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-IE
+--ProtocolIE-Single-Container { { X2ap-MeasurementInitiationResult-ItemIEs} }
+
+X2ap-MeasurementInitiationResult-Item ::= SEQUENCE {
+	cell-ID											X2ap-ECGI,
+	measurementFailureCause-List					X2ap-MeasurementFailureCause-List	OPTIONAL,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions									ProtocolExtensionContainer { { X2ap-MeasurementInitiationResult-Item-ExtIEs} }	OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
 X2ap-MDT-Configuration ::= SEQUENCE {
 	mdt-Activation				X2ap-MDT-Activation,
 	areaScopeOfMDT				X2ap-AreaScopeOfMDT,
@@ -816,9 +929,15 @@ X2ap-Number-of-Antennaports ::= ENUMERATED {
 
 -- O
 
+X2ap-Old-ECGIs::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ECGI
+
 X2ap-Oneframe ::= BIT STRING (SIZE (6))
 
 -- P
+X2ap-PartialSuccessIndicator ::= ENUMERATED {
+	partial-success-allowed,
+...
+}
 
 X2ap-PDCP-SN ::= INTEGER (0..4095)  
 
@@ -871,6 +990,14 @@ X2ap-QCI ::= INTEGER (0..255)
 
 -- R
 
+X2ap-ReportingPeriodicity ::= ENUMERATED {
+	one-thousand-ms,
+	two-thousand-ms,
+	five-thousand-ms,
+	ten-thousand-ms,
+...
+}
+
 X2ap-RadioframeAllocationOffset ::= INTEGER (0..7, ...)
 
 X2ap-RadioframeAllocationPeriod ::= ENUMERATED{
@@ -975,6 +1102,14 @@ X2ap-RRCConnSetupIndicator::= ENUMERATED {
 }
 
 -- S
+X2ap-ServedCellsToActivate::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ServedCellsToActivate-Item
+
+X2ap-ServedCellsToActivate-Item ::= SEQUENCE {
+	ecgi						X2ap-ECGI,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { { X2ap-ServedCellsToActivate-Item-ExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
 
 X2ap-S1TNLLoadIndicator ::= SEQUENCE {
 	dLS1TNLLoadIndicator			X2ap-LoadIndicator,
@@ -991,10 +1126,10 @@ X2ap-S1TNLLoadIndicator-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 
 
 
-X2ap-ServedCells ::= SEQUENCE (SIZE (1.. x2ap-maxCellineNB)) OF ServedCellItem
+X2ap-ServedCells ::= SEQUENCE (SIZE (1.. x2ap-maxCellineNB)) OF X2ap-ServedCellItem
 
 
-ServedCellItem ::= SEQUENCE {
+X2ap-ServedCellItem ::= SEQUENCE {
 	servedCellInfo					X2ap-ServedCell-Information,
 	neighbour-Info					X2ap-Neighbour-Information			OPTIONAL,
 --EURECOM COMMENT, ADDED NEXT LINE 	iE-Extensions					ProtocolExtensionContainer { {ServedCell-ExtIEs} } OPTIONAL,
@@ -1006,6 +1141,17 @@ X2ap-ServedCell-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
 
+X2ap-ServedCellsToModify::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ServedCellsToModify-Item
+
+X2ap-ServedCellsToModify-Item ::= SEQUENCE {
+	old-ecgi						X2ap-ECGI,
+	servedCellInfo					X2ap-ServedCell-Information,
+	neighbour-Info					X2ap-Neighbour-Information			OPTIONAL,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { { X2ap-ServedCellsToModify-Item-ExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
 X2ap-ServedCell-Information ::= SEQUENCE {
 	pCI					X2ap-PCI,
 	cellId				X2ap-ECGI,
@@ -1214,6 +1360,21 @@ X2ap-UESecurityCapabilities-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
 
+X2ap-UE-ContextInformation ::= SEQUENCE {
+	mME-UE-S1AP-ID						X2ap-UE-S1AP-ID,
+	uESecurityCapabilities				X2ap-UESecurityCapabilities,
+	aS-SecurityInformation				X2ap-AS-SecurityInformation,
+	uEaggregateMaximumBitRate			X2ap-UEAggregateMaximumBitRate,
+	subscriberProfileIDforRFP			X2ap-SubscriberProfileIDforRFP		OPTIONAL,
+	e-RABs-ToBeSetup-List				X2ap-E-RABs-ToBeSetup-List,
+	rRC-Context							X2ap-RRC-Context,
+	handoverRestrictionList				X2ap-HandoverRestrictionList		OPTIONAL,
+	locationReportingInformation		X2ap-LocationReportingInformation	OPTIONAL,
+--EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions						ProtocolExtensionContainer { {X2ap-UE-ContextInformation-ExtIEs} } OPTIONAL,
+	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	...
+}
+
 X2ap-UL-GBR-PRB-usage::= INTEGER (0..100)
 
 X2ap-UL-non-GBR-PRB-usage::= INTEGER (0..100)
diff --git a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU-Contents.asn b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU-Contents.asn
index 3a055d9ef..d0a3546a1 100755
--- a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU-Contents.asn
+++ b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU-Contents.asn
@@ -196,32 +196,18 @@ X2ap-HandoverRequest ::= SEQUENCE {
 }
 
 X2ap-HandoverRequest-IEs X2AP-PROTOCOL-IES ::= {
-	{ ID id-Old-eNB-UE-X2AP-ID				CRITICALITY reject	TYPE X2ap-X2ap-UE-X2AP-ID					PRESENCE mandatory }|
-	{ ID id-Cause							CRITICALITY ignore	TYPE X2ap-X2ap-Cause						PRESENCE mandatory }|
-	{ ID id-TargetCell-ID					CRITICALITY reject	TYPE X2ap-X2ap-ECGI						PRESENCE mandatory }|
-	{ ID id-GUMMEI-ID						CRITICALITY reject	TYPE X2ap-X2ap-GUMMEI						PRESENCE mandatory }|
-	{ ID id-UE-ContextInformation			CRITICALITY reject	TYPE X2ap-X2ap-UE-ContextInformation		PRESENCE mandatory }|
-	{ ID id-UE-HistoryInformation			CRITICALITY ignore	TYPE X2ap-X2ap-UE-HistoryInformation		PRESENCE mandatory }|
-	{ ID id-TraceActivation					CRITICALITY ignore	TYPE X2ap-X2ap-TraceActivation			PRESENCE optional}|
-	{ ID id-SRVCCOperationPossible			CRITICALITY ignore	TYPE X2ap-X2ap-SRVCCOperationPossible		PRESENCE optional}|
-	{ ID id-CSGMembershipStatus				CRITICALITY reject	TYPE X2ap-X2ap-CSGMembershipStatus		PRESENCE optional},
+	{ ID id-Old-eNB-UE-X2AP-ID				CRITICALITY reject	TYPE X2ap-UE-X2AP-ID					PRESENCE mandatory }|
+	{ ID id-Cause							CRITICALITY ignore	TYPE X2ap-Cause						PRESENCE mandatory }|
+	{ ID id-TargetCell-ID					CRITICALITY reject	TYPE X2ap-ECGI						PRESENCE mandatory }|
+	{ ID id-GUMMEI-ID						CRITICALITY reject	TYPE X2ap-GUMMEI						PRESENCE mandatory }|
+	{ ID id-UE-ContextInformation			CRITICALITY reject	TYPE X2ap-UE-ContextInformation		PRESENCE mandatory }|
+	{ ID id-UE-HistoryInformation			CRITICALITY ignore	TYPE X2ap-UE-HistoryInformation		PRESENCE mandatory }|
+	{ ID id-TraceActivation					CRITICALITY ignore	TYPE X2ap-TraceActivation			PRESENCE optional}|
+	{ ID id-SRVCCOperationPossible			CRITICALITY ignore	TYPE X2ap-SRVCCOperationPossible		PRESENCE optional}|
+	{ ID id-CSGMembershipStatus				CRITICALITY reject	TYPE X2ap-CSGMembershipStatus		PRESENCE optional},
 	...
 }
 
-X2ap-UE-ContextInformation ::= SEQUENCE {
-	mME-UE-S1AP-ID						X2ap-UE-S1AP-ID,
-	uESecurityCapabilities				X2ap-UESecurityCapabilities,
-	aS-SecurityInformation				X2ap-AS-SecurityInformation,
-	uEaggregateMaximumBitRate			X2ap-UEAggregateMaximumBitRate,
-	subscriberProfileIDforRFP			X2ap-SubscriberProfileIDforRFP		OPTIONAL,
-	e-RABs-ToBeSetup-List				X2ap-E-RABs-ToBeSetup-List,
-	rRC-Context							X2ap-RRC-Context,
-	handoverRestrictionList				X2ap-HandoverRestrictionList		OPTIONAL,
-	locationReportingInformation		X2ap-LocationReportingInformation	OPTIONAL,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions						ProtocolExtensionContainer { {X2ap-UE-ContextInformation-ExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
 
 X2ap-UE-ContextInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 { ID id-ManagementBasedMDTallowed	CRITICALITY ignore	EXTENSION X2ap-ManagementBasedMDTallowed		PRESENCE optional },
@@ -231,17 +217,7 @@ X2ap-UE-ContextInformation-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 X2ap-E-RABs-ToBeSetup-List ::= SEQUENCE (SIZE(1..x2ap-maxnoofBearers)) OF ProtocolIE-Single-Container { {X2ap-E-RABs-ToBeSetup-ItemIEs} }
 
 X2ap-E-RABs-ToBeSetup-ItemIEs 	X2AP-PROTOCOL-IES ::= {
-	{ ID id-E-RABs-ToBeSetup-Item	 CRITICALITY ignore 	TYPE X2ap-X2ap-E-RABs-ToBeSetup-Item 	PRESENCE mandatory },
-	...
-}
-
-X2ap-E-RABs-ToBeSetup-Item ::= SEQUENCE {
-	e-RAB-ID					X2ap-E-RAB-ID,
-	e-RAB-Level-QoS-Parameters		X2ap-E-RAB-Level-QoS-Parameters,
-	dL-Forwarding					X2ap-DL-Forwarding													OPTIONAL,
-	uL-GTPtunnelEndpoint			X2ap-GTPtunnelEndpoint,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { {X2ap-E-RABs-ToBeSetup-ItemExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
+	{ ID id-E-RABs-ToBeSetup-Item	 CRITICALITY ignore 	TYPE X2ap-E-RABs-ToBeSetup-Item 	PRESENCE mandatory },
 	...
 }
 
@@ -263,12 +239,12 @@ X2ap-HandoverRequestAcknowledge ::= SEQUENCE {
 }
 
 X2ap-HandoverRequestAcknowledge-IEs X2AP-PROTOCOL-IES ::= {
-	{ ID id-Old-eNB-UE-X2AP-ID							CRITICALITY ignore	TYPE X2ap-X2ap-UE-X2AP-ID		PRESENCE mandatory} |
-	{ ID id-New-eNB-UE-X2AP-ID							CRITICALITY ignore	TYPE X2ap-X2ap-UE-X2AP-ID		PRESENCE mandatory} |
-	{ ID id-E-RABs-Admitted-List						CRITICALITY ignore	TYPE X2ap-X2ap-E-RABs-Admitted-List	PRESENCE mandatory} |
-	{ ID id-E-RABs-NotAdmitted-List						CRITICALITY ignore	TYPE X2ap-X2ap-E-RAB-List		PRESENCE optional} |
-	{ ID id-TargeteNBtoSource-eNBTransparentContainer	CRITICALITY ignore	TYPE X2ap-X2ap-TargeteNBtoSource-eNBTransparentContainer	PRESENCE mandatory }|
-	{ ID id-CriticalityDiagnostics						CRITICALITY ignore	TYPE X2ap-X2ap-CriticalityDiagnostics	PRESENCE optional },
+	{ ID id-Old-eNB-UE-X2AP-ID							CRITICALITY ignore	TYPE X2ap-UE-X2AP-ID		PRESENCE mandatory} |
+	{ ID id-New-eNB-UE-X2AP-ID							CRITICALITY ignore	TYPE X2ap-UE-X2AP-ID		PRESENCE mandatory} |
+	{ ID id-E-RABs-Admitted-List						CRITICALITY ignore	TYPE X2ap-E-RABs-Admitted-List	PRESENCE mandatory} |
+	{ ID id-E-RABs-NotAdmitted-List						CRITICALITY ignore	TYPE X2ap-E-RAB-List		PRESENCE optional} |
+	{ ID id-TargeteNBtoSource-eNBTransparentContainer	CRITICALITY ignore	TYPE X2ap-TargeteNBtoSource-eNBTransparentContainer	PRESENCE mandatory }|
+	{ ID id-CriticalityDiagnostics						CRITICALITY ignore	TYPE X2ap-CriticalityDiagnostics	PRESENCE optional },
 	...
 }
 
@@ -278,15 +254,6 @@ X2ap-E-RABs-Admitted-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-E-RABs-Admitted-Item	CRITICALITY ignore	TYPE X2ap-E-RABs-Admitted-Item 	PRESENCE mandatory	}
 }
 
-X2ap-E-RABs-Admitted-Item ::= SEQUENCE {
-	e-RAB-ID					X2ap-E-RAB-ID,
-	uL-GTP-TunnelEndpoint			X2ap-GTPtunnelEndpoint	OPTIONAL,
-	dL-GTP-TunnelEndpoint			X2ap-GTPtunnelEndpoint	OPTIONAL,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { {X2ap-E-RABs-Admitted-Item-ExtIEs} }	OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
-
 X2ap-E-RABs-Admitted-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
@@ -323,7 +290,7 @@ X2ap-HandoverReport ::= SEQUENCE {
 	...
 }
 
-HandoverReport-IEs X2AP-PROTOCOL-IES ::= {
+X2ap-HandoverReport-IEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-HandoverReportType			CRITICALITY ignore	TYPE X2ap-HandoverReportTYPE X2ap-PRESENCE mandatory}|
 	{ ID id-Cause						CRITICALITY ignore	TYPE X2ap-Cause				PRESENCE mandatory} |
 	{ ID id-SourceCellECGI				CRITICALITY ignore	TYPE X2ap-ECGI				PRESENCE mandatory}|
@@ -357,17 +324,6 @@ X2ap-E-RABs-SubjectToStatusTransfer-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-E-RABs-SubjectToStatusTransfer-Item	CRITICALITY ignore	TYPE X2ap-E-RABs-SubjectToStatusTransfer-Item 	PRESENCE mandatory	}
 }
 
-X2ap-E-RABs-SubjectToStatusTransfer-Item ::= SEQUENCE {
-	e-RAB-ID						X2ap-E-RAB-ID,
-	
-	receiveStatusofULPDCPSDUs		X2ap-ReceiveStatusofULPDCPSDUs			OPTIONAL,
-	uL-COUNTvalue					X2ap-COUNTvalue,
-	dL-COUNTvalue					X2ap-COUNTvalue,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions							ProtocolExtensionContainer { {X2ap-E-RABs-SubjectToStatusTransfer-ItemExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
-
 X2ap-E-RABs-SubjectToStatusTransfer-ItemExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
@@ -469,12 +425,12 @@ X2ap-ResetResponse-IEs X2AP-PROTOCOL-IES ::= {
 --
 -- **************************************************************
 
-X2ap-X2SetupRequest ::= SEQUENCE {
-	protocolIEs                     ProtocolIE-Container       {{X2ap-X2SetupRequest-IEs}},
+X2SetupRequest ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{X2SetupRequest-IEs}},
 	...
 }
 
-X2ap-X2SetupRequest-IEs X2AP-PROTOCOL-IES ::= {
+X2SetupRequest-IEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-GlobalENB-ID				CRITICALITY reject	TYPE X2ap-GlobalENB-ID				PRESENCE mandatory} |
 	{ ID id-ServedCells						CRITICALITY reject	TYPE X2ap-ServedCells			PRESENCE mandatory} |
 	{ ID id-GUGroupIDList					CRITICALITY reject  TYPE X2ap-GUGroupIDList			PRESENCE optional},
@@ -489,12 +445,12 @@ X2ap-X2SetupRequest-IEs X2AP-PROTOCOL-IES ::= {
 --
 -- **************************************************************
 
-X2ap-X2SetupResponse ::= SEQUENCE {
-	protocolIEs                     ProtocolIE-Container       {{X2ap-X2SetupResponse-IEs}},
+X2SetupResponse ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{X2SetupResponse-IEs}},
 	...
 }
 
-X2ap-X2SetupResponse-IEs X2AP-PROTOCOL-IES ::= {
+X2SetupResponse-IEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-GlobalENB-ID					CRITICALITY reject	TYPE X2ap-GlobalENB-ID			PRESENCE mandatory} |
 	{ ID id-ServedCells						CRITICALITY reject	TYPE X2ap-ServedCells			PRESENCE mandatory} |
 	{ ID id-GUGroupIDList					CRITICALITY reject  TYPE X2ap-GUGroupIDList			PRESENCE optional}|
@@ -510,12 +466,12 @@ X2ap-X2SetupResponse-IEs X2AP-PROTOCOL-IES ::= {
 --
 -- **************************************************************
 
-X2ap-X2SetupFailure ::= SEQUENCE {
-	protocolIEs                     ProtocolIE-Container       {{X2ap-X2SetupFailure-IEs}},
+X2SetupFailure ::= SEQUENCE {
+	protocolIEs                     ProtocolIE-Container       {{X2SetupFailure-IEs}},
 	...
 }
 
-X2ap-X2SetupFailure-IEs X2AP-PROTOCOL-IES ::= {
+X2SetupFailure-IEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-Cause					CRITICALITY ignore		TYPE X2ap-Cause								PRESENCE mandatory} |
 	{ ID id-TimeToWait				CRITICALITY ignore		TYPE X2ap-TimeToWait							PRESENCE optional} |
 	{ ID id-CriticalityDiagnostics	CRITICALITY ignore		TYPE X2ap-CriticalityDiagnostics				PRESENCE optional },
@@ -547,15 +503,6 @@ X2ap-CellInformation-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-CellInformation-Item	CRITICALITY ignore	TYPE X2ap-CellInformation-Item 	PRESENCE mandatory	}
 }
 
-X2ap-CellInformation-Item ::= SEQUENCE {
-	cell-ID							ECGI,
-	ul-InterferenceOverloadIndication		X2ap-UL-InterferenceOverloadIndication		OPTIONAL,
-	ul-HighInterferenceIndicationInfo		X2ap-UL-HighInterferenceIndicationInfo		OPTIONAL,
-	relativeNarrowbandTxPower				X2ap-RelativeNarrowbandTxPower				OPTIONAL,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions							ProtocolExtensionContainer { {X2ap-CellInformation-Item-ExtIEs} }	OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
 
 X2ap-CellInformation-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 { ID id-ABSInformation			CRITICALITY ignore	EXTENSION X2ap-ABSInformation		PRESENCE optional }|
@@ -585,23 +532,12 @@ X2ap-ENBConfigurationUpdate-IEs X2AP-PROTOCOL-IES ::= {
 
 X2ap-ServedCellsToModify::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ServedCellsToModify-Item
  
-X2ap-ServedCellsToModify-Item::= SEQUENCE {
-	old-ecgi						X2ap-ECGI,
-	servedCellInfo					X2ap-ServedCell-Information,
-	neighbour-Info					X2ap-Neighbour-Information			OPTIONAL,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { { X2ap-ServedCellsToModify-Item-ExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
 
 ServedCellsToModify-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 { ID id-DeactivationIndication			CRITICALITY ignore	EXTENSION X2ap-DeactivationIndication				PRESENCE optional },
 	...
 }
 
-X2ap-
-Old-ECGIs::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ECGI
-
 -- **************************************************************
 --
 -- ENB CONFIGURATION UPDATE ACKNOWLEDGE
@@ -667,12 +603,7 @@ X2ap-CellToReport-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-CellToReport-Item	CRITICALITY ignore	TYPE X2ap-CellToReport-Item 	PRESENCE mandatory	}
 }
 
-X2ap-CellToReport-Item ::= SEQUENCE {
-	cell-ID									X2ap-ECGI,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions							X2ap-ProtocolExtensionContainer { {CellToReport-Item-ExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
+
 
 X2ap-CellToReport-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
@@ -718,13 +649,7 @@ X2ap-MeasurementInitiationResult-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-MeasurementInitiationResult-Item	CRITICALITY ignore	TYPE X2ap-MeasurementInitiationResult-Item	PRESENCE mandatory}
 }
 
-X2ap-MeasurementInitiationResult-Item ::= SEQUENCE {
-	cell-ID											X2ap-ECGI,
-	measurementFailureCause-List					X2ap-MeasurementFailureCause-List	OPTIONAL,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions									ProtocolExtensionContainer { { X2ap-MeasurementInitiationResult-Item-ExtIEs} }	OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
+
 
 X2ap-MeasurementInitiationResult-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
@@ -736,13 +661,6 @@ X2ap-MeasurementFailureCause-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-MeasurementFailureCause-Item	CRITICALITY ignore	TYPE X2ap-MeasurementFailureCause-Item		PRESENCE mandatory}
 }
 
-X2ap-MeasurementFailureCause-Item ::= SEQUENCE {
-	measurementFailedReportCharacteristics			X2ap-ReportCharacteristics,
-	cause											X2ap-Cause,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions									ProtocolExtensionContainer { { X2ap-MeasurementFailureCause-Item-ExtIEs} }	OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
 
 X2ap-MeasurementFailureCause-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
@@ -774,14 +692,6 @@ X2ap-CompleteFailureCauseInformation-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-CompleteFailureCauseInformation-Item	CRITICALITY ignore	TYPE X2ap-CompleteFailureCauseInformation-Item	PRESENCE mandatory}
 }
 
-X2ap-CompleteFailureCauseInformation-Item ::= SEQUENCE {
-	cell-ID											X2ap-ECGI,
-	measurementFailureCause-List					X2ap-MeasurementFailureCause-List,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions									ProtocolExtensionContainer { { X2ap-CompleteFailureCauseInformation-Item-ExtIEs} }	OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
-
 X2ap-CompleteFailureCauseInformation-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
 }
@@ -810,16 +720,6 @@ X2ap-CellMeasurementResult-ItemIEs X2AP-PROTOCOL-IES ::= {
 	{ ID id-CellMeasurementResult-Item	CRITICALITY ignore	TYPE X2ap-CellMeasurementResult-Item 	PRESENCE mandatory	}
 }
 
-X2ap-CellMeasurementResult-Item ::= SEQUENCE {
-	cell-ID						X2ap-ECGI,
-	hWLoadIndicator				X2ap-HWLoadIndicator		OPTIONAL,
-	s1TNLLoadIndicator			X2ap-S1TNLLoadIndicator	OPTIONAL,
-	radioResourceStatus			X2ap-RadioResourceStatus	OPTIONAL,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions				X2ap-ProtocolExtensionContainer { {X2ap-CellMeasurementResult-Item-ExtIEs} }	OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
-
 X2ap-CellMeasurementResult-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	{ ID id-CompositeAvailableCapacityGroup	CRITICALITY ignore	EXTENSION X2ap-CompositeAvailableCapacityGroup		PRESENCE optional}|
 	{ ID id-ABS-Status						CRITICALITY ignore	EXTENSION X2ap-ABS-Status							PRESENCE optional},
@@ -942,12 +842,6 @@ X2ap-CellActivationRequest-IEs X2AP-PROTOCOL-IES ::= {
 
 X2ap-ServedCellsToActivate::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ServedCellsToActivate-Item
  
-X2ap-ServedCellsToActivate-Item::= SEQUENCE {
-	ecgi						ECGI,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions					ProtocolExtensionContainer { { X2ap-ServedCellsToActivate-Item-ExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
 
 X2ap-ServedCellsToActivate-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
@@ -972,12 +866,7 @@ X2ap-CellActivationResponse-IEs X2AP-PROTOCOL-IES ::= {
 
 X2ap-ActivatedCellList ::= SEQUENCE (SIZE (1..x2ap-maxCellineNB)) OF X2ap-ActivatedCellList-Item
  
-X2ap-ActivatedCellList-Item::= SEQUENCE {
-	ecgi								ECGI,
---EURECOM COMMENT, ADDED NEXT LINE	iE-Extensions						ProtocolExtensionContainer { { X2ap-ActivatedCellList-Item-ExtIEs} } OPTIONAL,
-	iE-Extensions               X2ap-IE-Extensions OPTIONAL,
-	...
-}
+
 
 X2ap-ActivatedCellList-Item-ExtIEs X2AP-PROTOCOL-EXTENSION ::= {
 	...
diff --git a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU.asn b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU.asn
index 50e2628b7..330c19b27 100755
--- a/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU.asn
+++ b/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-PDU.asn
@@ -52,52 +52,52 @@ X2ap-UnsuccessfulOutcome ::= SEQUENCE {
 }
 
 X2ap-HandoverRequest ::= SEQUENCE {
-    handoverRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-HandoverRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-HandoverRequestAcknowledge ::= SEQUENCE {
-    handoverRequestAcknowledge-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-HandoverRequestAcknowledge-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-HandoverPreparationFailure ::= SEQUENCE {
-    handoverPreparationFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-HandoverPreparationFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-SNStatusTransfer ::= SEQUENCE {
-    snStatusTransfer-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-SNStatusTransfer-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-UEContextRelease ::= SEQUENCE {
-    ueContextRelease-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-UEContextRelease-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-HandoverCancel ::= SEQUENCE {
-    handoverCancel-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-HandoverCancel-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-HandoverReport ::= SEQUENCE {
-    handoverReport-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-HandoverReport-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ErrorIndication ::= SEQUENCE {
-    errorIndication-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ErrorIndication-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ResetRequest ::= SEQUENCE {
-    resetRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ResetRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ResetResponse ::= SEQUENCE {
-    resetResponse-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ResetResponse-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
@@ -117,83 +117,83 @@ X2SetupFailure ::= SEQUENCE {
 }
 
 X2ap-LoadInformation ::= SEQUENCE {
-    loadInformation-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-LoadInformation-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ENBConfigurationUpdate ::= SEQUENCE {
-    eNBConfigurationUpdate-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ENBConfigurationUpdate-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ENBConfigurationUpdateAcknowledge ::= SEQUENCE {
-    eNBConfigurationUpdateAcknowledge-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ENBConfigurationUpdateAcknowledge-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ENBConfigurationUpdateFailure ::= SEQUENCE {
-    eNBConfigurationUpdateFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ENBConfigurationUpdateFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ResourceStatusRequest ::= SEQUENCE {
-    resourceStatusRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ResourceStatusRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ResourceStatusResponse ::= SEQUENCE {
-    resourceStatusResponse-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ResourceStatusResponse-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ResourceStatusFailure ::= SEQUENCE {
-    resourceStatusFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ResourceStatusFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-ResourceStatusUpdate ::= SEQUENCE {
-    resourceStatusUpdate-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-ResourceStatusUpdate-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-RLFIndication ::= SEQUENCE {
-    rlfIndication-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-RLFIndication-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-PrivateMessage ::= SEQUENCE {
-    privateMessage-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-PrivateMessage-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-MobilityChangeRequest ::= SEQUENCE {
-    mobilityChangeRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-MobilityChangeRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-MobilityChangeAcknowledge ::= SEQUENCE {
-    mobilityChangeAcknowledge-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-MobilityChangeAcknowledge-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-MobilityChangeFailure ::= SEQUENCE {
-    mobilityChangeFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-MobilityChangeFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-CellActivationRequest ::= SEQUENCE {
-    cellActivationRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-CellActivationRequest-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-CellActivationResponse ::= SEQUENCE {
-    cellActivationResponse-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-CellActivationResponse-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
 X2ap-CellActivationFailure ::= SEQUENCE {
-    cellActivationFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
+    x2ap-CellActivationFailure-ies SEQUENCE (SIZE (0..x2ap-maxProtocolIEs)) OF X2ap-IE,
     ...
 }
 
-END
\ No newline at end of file
+END
diff --git a/openair2/X2AP/MESSAGES/ASN1/asn1tostruct.py b/openair2/X2AP/MESSAGES/ASN1/asn1tostruct.py
index 479f45e91..c298e8ae8 100644
--- a/openair2/X2AP/MESSAGES/ASN1/asn1tostruct.py
+++ b/openair2/X2AP/MESSAGES/ASN1/asn1tostruct.py
@@ -3,7 +3,7 @@ import datetime
 import getopt
 import getpass
 
-version = "1.0.0"
+version = "1.0.2"
 
 lines = ""
 iesDefs = {}
@@ -19,6 +19,7 @@ WARN = '\033[93m'
 ENDC = '\033[0m'
 
 fileprefix = ""
+fileprefix_first_upper = ""
 
 def printFail(string):
     sys.stderr.write(FAIL + string + ENDC + "\n")
@@ -87,7 +88,7 @@ def lowerFirstCamelWord(word):
     for c in swapped:
         if c in string.lowercase:
             newstr += c
-            idx += 1
+            idx    += 1
         else:
             break
     if idx < 2:
@@ -164,6 +165,8 @@ if len(iesDefs) == 0:
     printFail("No Information Element parsed, exiting")
     sys.exit(0)
 
+fileprefix_first_upper = fileprefix[0].upper() + fileprefix[1:]
+
 f = open(outdir + fileprefix + '_ies_defs.h', 'w')
 outputHeaderToFile(f, filename)
 f.write("#include \"%s_common.h\"\n\n" % (fileprefix))
@@ -223,9 +226,9 @@ for key in iesDefs:
     f.write("} %s_t;\n\n" % (re.sub('-', '_', key)))
 
 f.write("typedef struct %s_message_s {\n" % (fileprefix))
-f.write("    ProcedureCode_t procedureCode;\n")
-f.write("    Criticality_t   criticality;\n")
-f.write("    uint8_t         direction;\n")
+f.write("    %s_ProcedureCode_t procedureCode;\n" % (fileprefix_first_upper))
+f.write("    %s_Criticality_t   criticality;\n" % (fileprefix_first_upper))
+f.write("    uint8_t            direction;\n")
 f.write("    union {\n")
 
 messageList = iesDefs.keys()
@@ -301,7 +304,8 @@ for key in iesDefs:
         f.write(" *  \\param file File descriptor to write output.\n")
         f.write(" **/\n")
         f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('item', 'list', firstlower.lower())))
-        f.write("    FILE *file,\n")
+        f.write("    asn_app_consume_bytes_f *cb,\n")
+        f.write("    void *app_key,\n")
         f.write("    %sIEs_t *%sIEs);\n\n" % (re.sub('item', 'list', asn1cStruct), firstlower))
     else:
         f.write("/** \\brief Display %s message using XER encoding.\n" % (asn1cStruct))
@@ -309,8 +313,13 @@ for key in iesDefs:
         f.write(" *  \\param file File descriptor to write output.\n")
         f.write(" **/\n")
         f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, firstlower.lower()))
-        f.write("    FILE *file,\n")
+        f.write("    asn_app_consume_bytes_f *cb,\n")
+        f.write("    void *app_key,\n")
         f.write("    %s_message *message_p);\n\n" % (fileprefix))
+
+f.write("int %s_xer__print2sp(const void *buffer, size_t size, void *app_key);\n\n" % (fileprefix.lower()))
+f.write("int %s_xer__print2fp(const void *buffer, size_t size, void *app_key);\n\n" % (fileprefix.lower()))
+f.write("extern size_t %s_string_total_size;\n\n" % (fileprefix.lower()))
 f.write("#endif /* %s_IES_DEFS_H_ */\n\n" % (fileprefix.upper()))
 
 #Generate Decode functions
@@ -353,7 +362,7 @@ for key in iesDefs:
     f.write("    %s_DEBUG(\"Decoding message %s (%%s:%%d)\\n\", __FILE__, __LINE__);\n\n" % (fileprefix.upper(), re.sub('-', '_', keyName)))
     f.write("    ANY_to_type_aper(any_p, &asn_DEF_%s, (void**)&%s_p);\n\n" % (asn1cStruct, asn1cStructfirstlower))
     f.write("    for (i = 0; i < %s_p->%slist.count; i++) {\n" % (asn1cStructfirstlower, iesaccess))
-    f.write("        IE_t *ie_p;\n")
+    f.write("        %s_IE_t *ie_p;\n" % (fileprefix[0].upper() + fileprefix[1:]))
     f.write("        ie_p = %s_p->%slist.array[i];\n" % (asn1cStructfirstlower, iesaccess))
     f.write("        switch(ie_p->id) {\n")
     for ie in iesDefs[key]["ies"]:
@@ -368,7 +377,7 @@ for key in iesDefs:
             f.write("            /* Optional field */\n")
         elif ie[3] == "conditional":
             f.write("            /* Conditional field */\n")
-        f.write("            case ProtocolIE_ID_%s:\n" % (re.sub('-', '_', ie[0])))
+        f.write("            case %s_ProtocolIE_ID_%s:\n" % (fileprefix_first_upper, re.sub('-', '_', ie[0])))
         f.write("            {\n")
         f.write("                %s_t *%s_p = NULL;\n" % (ietypeunderscore, lowerFirstCamelWord(ietypesubst)))
         if ie[3] != "mandatory":
@@ -416,12 +425,12 @@ for key in iesDefs:
     f.write("    assert(%sIEs != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname))));
 
     f.write("    for (i = 0; i < %s->list.count; i++) {\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname))))
-    f.write("        IE_t *ie_p = %s->list.array[i];\n" % (lowerFirstCamelWord(re.sub('-', '_', keyname))))
+    f.write("        %s_IE_t *ie_p = %s->list.array[i];\n" % (fileprefix[0].upper() + fileprefix[1:], lowerFirstCamelWord(re.sub('-', '_', keyname))))
     f.write("        switch (ie_p->id) {\n")
     for ie in iesDefs[key]["ies"]:
         iename = re.sub('id-', '', ie[0])
         ienameunderscore = lowerFirstCamelWord(re.sub('-', '_', iename))
-        f.write("            case ProtocolIE_ID_%s:\n" % (re.sub('-', '_', ie[0])))
+        f.write("            case %s_ProtocolIE_ID_%s:\n" % (fileprefix_first_upper, re.sub('-', '_', ie[0])))
         f.write("            {\n")
         f.write("                %s_t *%s_p = NULL;\n" % (re.sub('-', '_', ie[2]), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
         f.write("                tempDecoded = ANY_to_type_aper(&ie_p->value, &asn_DEF_%s, (void**)&%s_p);\n" % (re.sub('-', '_', ie[2]), lowerFirstCamelWord(re.sub('-', '', ie[2]))))
@@ -478,7 +487,7 @@ for key in iesDefs:
     f.write("    %s_t *%s,\n" % (asn1cStruct, firstwordlower))
     f.write("    %s_t *%s) {\n\n" % (re.sub('-', '_', key), lowerFirstCamelWord(re.sub('-', '_', key))))
 
-    f.write("    IE_t *ie;\n\n")
+    f.write("    %s_IE_t *ie;\n\n" % (fileprefix_first_upper))
 
     f.write("    assert(%s != NULL);\n" % (firstwordlower));
     f.write("    assert(%s != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', key))));
@@ -497,10 +506,10 @@ for key in iesDefs:
                 f.write("    /* Conditional field */\n")
             f.write("    if (%s->presenceMask & %s_%s_PRESENT) {\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), keyupperunderscore, ieupperunderscore))
             #f.write("        == %s_%s_PRESENT) {\n" % (keyupperunderscore, ieupperunderscore))
-            f.write("        if ((ie = %s_new_ie(ProtocolIE_ID_%s,\n" % (fileprefix, re.sub('-', '_', ie[0])))
-            f.write("                              Criticality_%s,\n" % (ie[1]))
-            f.write("                              &asn_DEF_%s,\n" % (ietypeunderscore))
-            f.write("                              &%s->%s)) == NULL) {\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), ienamefirstwordlower))
+            f.write("        if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,\n" % (fileprefix, fileprefix_first_upper, re.sub('-', '_', ie[0])))
+            f.write("                            %s_Criticality_%s,\n" % (fileprefix_first_upper, ie[1]))
+            f.write("                            &asn_DEF_%s,\n" % (ietypeunderscore))
+            f.write("                            &%s->%s)) == NULL) {\n" % (lowerFirstCamelWord(re.sub('-', '_', key)), ienamefirstwordlower))
             f.write("            return -1;\n")
             f.write("        }\n")
             f.write("        ASN_SEQUENCE_ADD(&%s->%slist, ie);\n" % (firstwordlower, iesaccess))
@@ -511,9 +520,9 @@ for key in iesDefs:
                 f.write("    memset(&%s, 0, sizeof(%s_t));\n" % (ienamefirstwordlower, ietypeunderscore))
                 f.write("\n")
                 f.write("    if (%s_encode_%s(&%s, &%s->%s) < 0) return -1;\n" % (fileprefix, ietypeunderscore.lower(), ienamefirstwordlower, lowerFirstCamelWord(re.sub('-', '_', key)), ienamefirstwordlower))
-            f.write("    if ((ie = %s_new_ie(ProtocolIE_ID_%s,\n" % (fileprefix, re.sub('-', '_', ie[0])))
-            f.write("                          Criticality_%s,\n" % (ie[1]))
-            f.write("                          &asn_DEF_%s,\n" % (ietypeunderscore))
+            f.write("    if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,\n" % (fileprefix, fileprefix_first_upper, re.sub('-', '_', ie[0])))
+            f.write("                        %s_Criticality_%s,\n" % (fileprefix_first_upper, ie[1]))
+            f.write("                        &asn_DEF_%s,\n" % (ietypeunderscore))
             if ie[2] in ieofielist.keys():
                 f.write("                          &%s)) == NULL) {\n" % (ienamefirstwordlower))
             else:
@@ -546,14 +555,14 @@ for (key, value) in iesDefs.items():
     f.write("    %sIEs_t *%sIEs) {\n\n" % (re.sub('-', '_', i), lowerFirstCamelWord(re.sub('-', '_', i))))
     f.write("    int i;\n")
 
-    f.write("    IE_t *ie;\n\n")
+    f.write("    %s_IE_t *ie;\n\n" % (fileprefix_first_upper))
 
     f.write("    assert(%s != NULL);\n" % (firstwordlower));
     f.write("    assert(%sIEs != NULL);\n\n" % (lowerFirstCamelWord(re.sub('-', '_', i))));
 
     f.write("    for (i = 0; i < %sIEs->%s.count; i++) {\n" % (firstwordlower, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
-    f.write("        if ((ie = %s_new_ie(ProtocolIE_ID_%s,\n" % (fileprefix, re.sub('-', '_', ie[0])))
-    f.write("                            Criticality_%s,\n" % (ie[1]))
+    f.write("        if ((ie = %s_new_ie(%s_ProtocolIE_ID_%s,\n" % (fileprefix, fileprefix_first_upper, re.sub('-', '_', ie[0])))
+    f.write("                            %s_Criticality_%s,\n" % (fileprefix_first_upper, ie[1]))
     f.write("                            &asn_DEF_%s,\n" % (ietypeunderscore))
     f.write("                            %sIEs->%s.array[i])) == NULL) {\n" % (firstwordlower, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
     f.write("            return -1;\n")
@@ -571,8 +580,9 @@ f.write("#include <stdio.h>\n\n")
 f.write("#include <asn_application.h>\n#include <asn_internal.h>\n\n")
 f.write("#include \"%s_common.h\"\n#include \"%s_ies_defs.h\"\n\n" % (fileprefix, fileprefix))
 
-f.write("""static int
-xer__print2fp(const void *buffer, size_t size, void *app_key) {
+f.write("size_t %s_string_total_size = 0;\n\n" % (fileprefix.lower()))
+f.write("""int
+%s_xer__print2fp(const void *buffer, size_t size, void *app_key) {
     FILE *stream = (FILE *)app_key;
 
     if(fwrite(buffer, 1, size, stream) != size)
@@ -581,7 +591,22 @@ xer__print2fp(const void *buffer, size_t size, void *app_key) {
     return 0;
 }
 
-static asn_enc_rval_t
+""" % (fileprefix.lower()))
+
+f.write("""int %s_xer__print2sp(const void *buffer, size_t size, void *app_key) {
+    char *string = (char *)app_key;
+
+    /* Copy buffer to the formatted string */
+    memcpy(&string[%s_string_total_size], buffer, size);
+
+    %s_string_total_size += size;
+
+    return 0;
+}
+
+""" % (fileprefix.lower(), fileprefix.lower(), fileprefix.lower()))
+
+f.write("""static asn_enc_rval_t
 xer_encode_local(asn_TYPE_descriptor_t *td, void *sptr,
         asn_app_consume_bytes_f *cb, void *app_key, int indent) {
     asn_enc_rval_t er, tmper;
@@ -622,7 +647,9 @@ for (key, value) in iesDefs.items():
         f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('ies', '', re.sub('item', 'list', re.sub('-', '_', key).lower()))))
     else:
         f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', key).lower())))
-    f.write("    FILE *file,\n")
+    #f.write("    FILE *file,\n")
+    f.write("    asn_app_consume_bytes_f *cb,\n")
+    f.write("    void *app_key,\n")
     if key in ieofielist.values():
         iesStructName = lowerFirstCamelWord(re.sub('Item', 'List', re.sub('-', '_', key)))
         f.write("    %sIEs_t *%s) {\n\n" % (re.sub('IEs', '', re.sub('Item', 'List', re.sub('-', '_', key))), iesStructName))
@@ -632,21 +659,23 @@ for (key, value) in iesDefs.items():
         f.write("    %s_message *message_p)\n{\n" % (fileprefix))
         f.write("    %s_t *%s;\n" % (re.sub('-', '_', key), iesStructName))
         f.write("    asn_enc_rval_t er;\n")
-        f.write("    void *app_key = (void *)file;\n")
-        f.write("    asn_app_consume_bytes_f *cb = xer__print2fp;\n\n")
+        #f.write("    void *app_key = (void *)file;\n")
+        #f.write("    asn_app_consume_bytes_f *cb = %s_xer__print2fp;\n\n" % (fileprefix.lower()))
 
         f.write("    %s = &message_p->msg.%s;\n\n" % (iesStructName, iesStructName))
 
     if key in ieofielist.values():
         # Increase indentation level
         f.write("    for (i = 0; i < %s->%s.count; i++) {\n" % (iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
-        f.write("        xer_fprint(file, &asn_DEF_%s, %s->%s.array[i]);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+        #f.write("        xer_fprint(file, &asn_DEF_%s, %s->%s.array[i]);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
+        f.write("        er = xer_encode(&asn_DEF_%s, %s->%s.array[i], XER_F_BASIC, cb, app_key);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
         f.write("    }\n")
     else:
-        f.write("    fprintf(file, \"<%s-PDU>\\n\");\n" % (fileprefix.upper()))
-        f.write("    xer_encode_local(&asn_DEF_Criticality, &message_p->criticality, cb, app_key, 1);\n")
-        f.write("    xer_encode_local(&asn_DEF_ProcedureCode, &message_p->procedureCode, cb, app_key, 1);\n")
-        f.write("    fprintf(file, \"    <%s>\\n\");\n" % (key))
+        f.write("    cb(\"<%s-PDU>\\n\", %d, app_key);\n" % (key, len("<%s-PDU>\n" % (key))))
+        f.write("    xer_encode_local(&asn_DEF_%s_Criticality, &message_p->criticality, cb, app_key, 1);\n" % fileprefix_first_upper)
+        f.write("    xer_encode_local(&asn_DEF_%s_ProcedureCode, &message_p->procedureCode, cb, app_key, 1);\n" % fileprefix_first_upper)
+
+        f.write("    cb(\"    <%s>\\n\", %d, app_key);\n" % (key, len("    <%s>\n" % (key))))
 
         for ie in iesDefs[key]["ies"]:
             iename = re.sub('-', '_', re.sub('id-', '', ie[0]))
@@ -664,12 +693,11 @@ for (key, value) in iesDefs.items():
 
             # Is it an encapsulated IE ?
             if ie[2] in ieofielist.keys():
-                f.write("    %s_xer_print_%s(file, &%s->%s);\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', ie[2]).lower()), iesStructName, ienamefirstwordlower))
+                f.write("    %s_xer_print_%s(cb, app_key, &%s->%s);\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', ie[2]).lower()), iesStructName, ienamefirstwordlower))
             else:
                 f.write("    xer_encode_local(&asn_DEF_%s, &%s->%s, cb, app_key, 2);\n" % (ietypeunderscore, iesStructName, ienamefirstwordlower))
-        #f.write("    _i_ASN_TEXT_INDENT(1, 1);\n")
-        f.write("    fprintf(file, \"    </%s>\\n\");\n" % (key))
-        f.write("    fprintf(file, \"</%s-PDU>\\n\");\n" % (fileprefix.upper()))
+        f.write("    cb(\"    </%s>\\n\", %d, app_key);\n" % (key, len("    </%s>\n" % (key))))
+        f.write("    cb(\"</%s-PDU>\\n\", %d, app_key);\n" % (key, len("</%s-PDU>\n" % (key))))
 
     f.write("    _ASN_ENCODED_OK(er);\n")
     #if key not in ieofielist.values():
diff --git a/openair2/X2AP/x2ap_common.h b/openair2/X2AP/x2ap_common.h
index c48360e08..fe7b710d9 100755
--- a/openair2/X2AP/x2ap_common.h
+++ b/openair2/X2AP/x2ap_common.h
@@ -35,23 +35,36 @@
 #include "X2ap-ABSInformation.h"
 #include "X2ap-ABSInformationTDD.h"
 #include "X2ap-ABS-Status.h"
+#include "X2ap-ActivatedCellList.h"
 #include "X2ap-AllocationAndRetentionPriority.h"
 #include "X2ap-AreaScopeOfMDT.h"
 #include "X2ap-AS-SecurityInformation.h"
 #include "X2ap-BandInfo.h"
 #include "X2ap-BitRate.h"
 #include "X2ap-BroadcastPLMNs-Item.h"
+
 #include "X2ap-CapacityValue.h"
 #include "X2ap-Cause.h"
 #include "X2ap-CauseMisc.h"
 #include "X2ap-CauseProtocol.h"
 #include "X2ap-CauseRadioNetwork.h"
 #include "X2ap-CauseTransport.h"
+#include "X2ap-CellActivationFailure.h"
+#include "X2ap-CellActivationRequest.h"
+#include "X2ap-CellActivationResponse.h"
 #include "X2ap-CellBasedMDT.h"
 #include "X2ap-CellCapacityClassValue.h"
 #include "X2ap-CellIdListforMDT.h"
+#include "X2ap-CellInformation-Item.h"
+#include "X2ap-CellInformation-List.h"
 #include "X2ap-Cell-Size.h"
+#include "X2ap-CellToReport-Item.h"
+#include "X2ap-CellToReport-List.h"
 #include "X2ap-CellType.h"
+#include "X2ap-CellMeasurementResult-Item.h" 
+#include "X2ap-CellMeasurementResult-List.h"
+#include "X2ap-CompleteFailureCauseInformation-Item.h"
+#include "X2ap-CompleteFailureCauseInformation-List.h"
 #include "X2ap-CompositeAvailableCapacityGroup.h"
 #include "X2ap-CompositeAvailableCapacity.h"
 #include "X2ap-COUNTvalue.h"
@@ -73,16 +86,24 @@
 #include "X2ap-ECGI.h"
 #include "X2ap-ENB-ID.h"
 #include "X2ap-ENBConfigurationUpdateFailure.h"
+#include "X2ap-ENBConfigurationUpdateAcknowledge.h"
+#include "X2ap-ENBConfigurationUpdate.h"
 #include "X2ap-EncryptionAlgorithms.h"
 #include "X2ap-EPLMNs.h"
 #include "X2ap-E-RAB-ID.h"
 #include "X2ap-E-RAB-Item.h"
+#include "X2ap-E-RABs-Admitted-List.h"
 #include "X2ap-E-RAB-Level-QoS-Parameters.h"
 #include "X2ap-E-RAB-List.h"
+#include "X2ap-E-RABs-SubjectToStatusTransfer-Item.h"
+#include "X2ap-E-RABs-Admitted-Item.h"
+#include "X2ap-E-RABs-SubjectToStatusTransfer-List.h"
+#include "X2ap-ErrorIndication.h"
 #include "X2ap-EUTRA-Mode-Info.h"
 #include "X2ap-EUTRANCellIdentifier.h"
 #include "X2ap-EUTRANTraceID.h"
 #include "X2ap-EventType.h"
+
 #include "X2ap-FDD-Info.h"
 #include "X2ap-ForbiddenInterRATs.h"
 #include "X2ap-ForbiddenLACs.h"
@@ -103,7 +124,11 @@
 #include "X2ap-HandoverCancel.h"
 #include "X2ap-HandoverReportType.h"
 #include "X2ap-HandoverRequest.h"
+#include "X2ap-HandoverReport.h"
 #include "X2ap-HandoverRestrictionList.h"
+#include "X2ap-HandoverPreparationFailure.h"
+#include "X2ap-HandoverRequestAcknowledge.h"
+
 #include "X2ap-HFN.h"
 #include "X2ap-HWLoadIndicator.h"
 #include "X2ap-IE-Extensions.h"
@@ -118,6 +143,7 @@
 #include "X2ap-LastVisitedGERANCellInformation.h"
 #include "X2ap-LastVisitedUTRANCellInformation.h"
 #include "X2ap-LoadIndicator.h"
+#include "X2ap-LoadInformation.h"
 #include "X2ap-LocationReportingInformation.h"
 #include "X2ap-ManagementBasedMDTallowed.h"
 #include "X2ap-MBMS-Service-Area-Identity.h"
@@ -129,6 +155,10 @@
 #include "X2ap-Measurement-ID.h"
 #include "X2ap-MeasurementsToActivate.h"
 #include "X2ap-MeasurementThresholdA2.h"
+#include "X2ap-MeasurementInitiationResult-Item.h"
+#include "X2ap-MeasurementInitiationResult-List.h"
+
+#include "X2ap-MeasurementFailureCause-Item.h"
 #include "X2ap-MME-Code.h"
 #include "X2ap-MME-Group-ID.h"
 #include "X2ap-MobilityChangeAcknowledge.h"
@@ -141,6 +171,8 @@
 #include "X2ap-NextHopChainingCount.h"
 #include "X2ap-Number-of-Antennaports.h"
 #include "X2ap-Oneframe.h"
+#include "X2ap-Old-ECGIs.h"
+#include "X2ap-PartialSuccessIndicator.h"
 #include "X2ap-PCI.h"
 #include "X2ap-PDCP-SN.h"
 #include "X2AP-PDU.h"
@@ -166,14 +198,22 @@
 #include "X2ap-ReportCharacteristics.h"
 #include "X2ap-ReportingTriggerMDT.h"
 #include "X2ap-ReportIntervalMDT.h"
+#include "X2ap-ReportingPeriodicity.h"
 #include "X2ap-ResourceStatusFailure.h"
+#include "X2ap-ResourceStatusResponse.h"
+#include "X2ap-ResourceStatusUpdate.h"
+
 #include "X2ap-RNTP-Threshold.h"
 #include "X2ap-RRCConnReestabIndicator.h"
 #include "X2ap-RRCConnSetupIndicator.h"
 #include "X2ap-RRC-Context.h"
+#include "X2ap-RLFIndication.h"
+#include "X2ap-ResourceStatusRequest.h"
 #include "X2ap-S1TNLLoadIndicator.h"
-#include "X2ap-ServedCell-Information.h"
+//nclude "X2ap-ServedCellInformation.h"
 #include "X2ap-ServedCells.h"
+#include "X2ap-ServedCellsToModify.h"
+#include "X2ap-ServedCellsToActivate.h"
 #include "X2ap-ShortMAC-I.h"
 #include "X2ap-SpecialSubframe-Info.h"
 #include "X2ap-SpecialSubframePatterns.h"
@@ -181,6 +221,8 @@
 #include "X2ap-SubframeAllocation.h"
 #include "X2ap-SubframeAssignment.h"
 #include "X2ap-SubscriberProfileIDforRFP.h"
+#include "X2ap-SNStatusTransfer.h"
+
 #include "X2ap-TABasedMDT.h"
 #include "X2ap-TAC.h"
 #include "X2ap-TAListforMDT.h"
@@ -193,6 +235,7 @@
 #include "X2ap-TimeToWait.h"
 #include "X2ap-Time-UE-StayedInCell-EnhancedGranularity.h"
 #include "X2ap-Time-UE-StayedInCell.h"
+#include "X2ap-E-RABs-ToBeSetup-Item.h"
 #include "X2ap-TraceActivation.h"
 #include "X2ap-TraceCollectionEntityIPAddress.h"
 #include "X2ap-TraceDepth.h"
@@ -201,6 +244,7 @@
 #include "X2ap-TriggeringMessage.h"
 #include "X2ap-TypeOfError.h"
 #include "X2ap-UEAggregateMaximumBitRate.h"
+#include "X2ap-UE-ContextInformation.h"
 #include "X2ap-UE-HistoryInformation.h"
 #include "X2ap-UE-RLF-Report-Container.h"
 #include "X2ap-UE-S1AP-ID.h"
@@ -218,10 +262,17 @@
 #include "X2ap-UsableABSInformationFDD.h"
 #include "X2ap-UsableABSInformation.h"
 #include "X2ap-UsableABSInformationTDD.h"
+
+#include "X2ap-ResetResponse.h"
+#include "X2ap-ResetRequest.h"
 #include "X2SetupFailure.h"
 #include "X2SetupRequest.h"
 #include "X2SetupResponse.h"
 
+#include "X2ap-Old-ECGIs.h"
+#include "X2ap-Criticality.h"
+#include "X2ap-ProcedureCode.h"
+
 #ifndef X2AP_COMMON_H_
 #define X2AP_COMMON_H_
 
-- 
GitLab