Commit 75370a26 authored by Bostjan Pintar's avatar Bostjan Pintar
Browse files

Merge branch 'devel' into 'main'

Devel

See merge request !12
parents fa43d01e bb576d00
Loading
Loading
Loading
Loading

LICENSE

0 → 100644
+23 −0
Original line number Diff line number Diff line
Copyright 2019-2022 ETSI

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors 
   may be used to endorse or promote products derived from this software without 
   specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
OF THE POSSIBILITY OF SUCH DAMAGE.
+5 −33
Original line number Diff line number Diff line
@@ -12,16 +12,6 @@ ifeq (,$(TTCN3_DIR))
 $(error TTCN3_DIR shall be defined in config.mk)
endif

ifeq (,$(ASN1C))
 ifneq (,$(ASN1C_PATH))
  ASN1C := $(ASN1C_PATH)/asn1c/.libs/asn1c -S $(ASN1C_PATH)/skeletons
 else
  ASN1C := asn1c
 endif
endif

export ASN1C_PATH

first: all

define IncludeModule
@@ -103,8 +93,7 @@ echo: echo_sources
	@echo -e "defines: $(addsuffix \n, $(defines))"

clean:
	rm -f $(outdir)/$(ATS)$(EXE) $(gen_objects) $(gen_sources) $(gen_headers) $(cc_objects) $(outdir)/.generate $(outdir)/../lib5GNGAPAsn.so
#	rm -f $(outdir)/asn1/*.so $(outdir)/asn1/*.o $(outdir)/asn1/*.c $(outdir)/asn1/*.h $(outdir)/asn1/Makefile.am.libasncodec
	rm -f $(outdir)/$(ATS)$(EXE) $(gen_objects) $(gen_sources) $(gen_headers) $(cc_objects) $(outdir)/.generate

regen: force_regen $(outdir)/.generate
force_regen:
@@ -125,8 +114,8 @@ t3d: all
$(outdir) $(outdir)/asn1 $(bindir):
	mkdir -p $@

$(bindir)/$(ATS)$(EXE): $(outdir)/asn1/lib5GNGAPAsn.a $(gen_objects) $(cc_objects) 
	g++ -g -O0 -std=c++17 -o $@ $(LDFLAGS) $(gen_objects) $(cc_objects) $(outdir)/asn1/lib5GNGAPAsn.a $(libs)
$(bindir)/$(ATS)$(EXE): $(gen_objects) $(cc_objects) 
	g++ -g -O0 -std=c++17 -o $@ $(LDFLAGS) $(gen_objects) $(cc_objects) $(libs)

$(gen_objects) :%.o :%.cc
	g++ -g -O0 -std=c++17 -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<
@@ -136,32 +125,15 @@ $(cc_objects) : $(outdir)/%.o : %.cc
	g++ -g -O0 -std=c++17 -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<

#$(gen_sources):
#	$(TTCN3_DIR)/bin/compiler -n -e -L -R -U none -o $(outdir) $(tt_sources)
#	$(TTCN3_DIR)/bin/asn1_compiler $(TTCN3_COMPILER_OPTIONS) -o $(outdir) $(tt_sources)

$(gen_sources): $(outdir)/.generate

$(outdir)/.generate: Makefile $(tt_sources)
	$(TTCN3_DIR)/bin/compiler $(TTCN3_COMPILER_OPTIONS) -o  $(outdir) $(tt_sources)
	touch $@

$(bindir)/lib5GNGAPAsn.so: $(outdir)/asn1/lib5GNGAPAsn.so
	cp -f $< $@

$(outdir)/asn1/lib5GNGAPAsn.a: $(asn_sources) $(asn1_sources) libNr5gcAsn1.mk Makefile
	mkdir -p $(outdir)/asn1
	echo TOP_DIR   := ../../..                                               >$(outdir)/asn1/Makefile
	echo ASN_PDU   := $(pdu)                                                >>$(outdir)/asn1/Makefile
	echo ASN_FILES := \\                                                    >>$(outdir)/asn1/Makefile
	for n in $(asn_sources) $(asn1_sources); do echo "        $$n \\"; done >>$(outdir)/asn1/Makefile
	echo                                                                    >>$(outdir)/asn1/Makefile
	cat libNr5gcAsn1.mk                                                     >>$(outdir)/asn1/Makefile
	$(MAKE) -C $(outdir)/asn1
	$(TTCN3_DIR)/bin/asn1_compiler $(TTCN3_COMPILER_OPTIONS) -o $(outdir) $(tt_sources)
	touch $@

$(foreach S, $(ttcn_sources),  $(eval $(outdir)/$(notdir $(patsubst %.ttcn, %.cc,  $(S))): $(S)))
$(foreach S, $(ttcn3_sources), $(eval $(outdir)/$(notdir $(patsubst %.ttcn3, %.cc, $(S))): $(S)))
$(foreach S, $(asn_sources),   $(eval $(outdir)/$(notdir $(patsubst %.asn, %.cc,   $(S))): $(S)))
$(foreach S, $(asn1_sources),  $(eval $(outdir)/$(notdir $(patsubst %.asn1, %.cc,  $(S))): $(S)))

$(asn_sources) $(asn1_sources):
+9 −2
Original line number Diff line number Diff line
@@ -4,12 +4,19 @@
			"path": "."
		},
		{
			"path": "../../../tmp/osmo-ttcn3-hacks"
			"path": "../pipeline-scripts"
		},
		{
			"path": "../../tmp/titan_5gngap_per_issue"
		},
		{
			"path": "../nas"
		}
	],
	"settings": {
		"files.associations": {
			"pdusessionresourcemodifyindication.h": "c"
			"pdusessionresourcemodifyindication.h": "c",
			"random": "cpp"
		}
	}
}
 No newline at end of file

ccsrc/Asn1c/asn1_recoder.cc

deleted100644 → 0
+0 −56
Original line number Diff line number Diff line
#include <asn1/asn_application.h>

#include "asn1_recoder.hh"

#include <TTCN3.hh>

extern "C" {
static int asn1c_collect_encoded_data(const void *buffer, size_t size, void *application_specific_key) {
  TTCN_Buffer *tb = (TTCN_Buffer *)application_specific_key;
  tb->put_s(size, (unsigned char *)buffer);
  return 0;
}
}

int asn1_recoder::recode(const asn_TYPE_descriptor_s &td, int from, int to, TTCN_Buffer &buf) {
  int            rc  = -1;
  void *         ptr = NULL;
  asn_dec_rval_t rc_d;
  rc_d = asn_decode(NULL, (asn_transfer_syntax)from, (asn_TYPE_descriptor_s *)&td, &ptr, buf.get_data(), buf.get_len());
  if (rc_d.code == RC_OK) {
    // Encode as PER
    asn_enc_rval_t rc_e;
    buf.clear();
    rc_e = asn_encode(NULL, (asn_transfer_syntax)to, (asn_TYPE_descriptor_s *)&td, ptr, asn1c_collect_encoded_data, &buf);
    rc   = rc_e.encoded;
  }
  if (ptr) {
    ASN_STRUCT_FREE(td, ptr);
  }
  return rc;
}

int asn1_recoder::ber2per(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf) 
{
  //return recode(td, (int)ATS_BER, (int)ATS_UNALIGNED_CANONICAL_PER, buf);
  //return recode(td, (int)ATS_BER, (int)ATS_ALIGNED_CANONICAL_PER, buf);
  return recode(td, (int)ATS_BER, (int)ATS_ALIGNED_BASIC_PER, buf);
  //return recode(td, (int)ATS_BER, (int)ATS_UNALIGNED_BASIC_PER, buf);
}

int asn1_recoder::per2ber(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf) 
{
  //return recode(td, (int)ATS_UNALIGNED_BASIC_PER, (int)ATS_DER, buf);
  //return recode(td, (int)ATS_ALIGNED_CANONICAL_PER, (int)ATS_BER, buf);
  return recode(td, (int)ATS_ALIGNED_BASIC_PER, (int)ATS_BER, buf);
}

int asn1_recoder::ber2oer(const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf)
{
  return recode(td, (int)ATS_BER, (int)ATS_CANONICAL_OER, buf);
}

int asn1_recoder::oer2ber(const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf)
{
  return recode(td, (int)ATS_BASIC_OER, (int)ATS_BER, buf);
}

ccsrc/Asn1c/asn1_recoder.hh

deleted100644 → 0
+0 −29
Original line number Diff line number Diff line
/*!
 * \file      asn1_recode_per.hh
 * \brief     Header file ASN.1 PER codec based on asn1c external tool.
 * \author    ETSI STF525
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */
#pragma once

class OCTETSTRING;           //! Forward declaration of TITAN class
class CHARSTRING;            //! Forward declaration of TITAN class
class BITSTRING;             //! Forward declaration of TITAN class
class TTCN_Buffer;           //! Forward declaration of TITAN class
class TTCN_EncDec;           //! Forward declaration of TITAN class
class TTCN_Typedescriptor_t; //! Forward declaration of TITAN class

struct asn_TYPE_descriptor_s; //! Forward declaration of asn1c class

class asn1_recoder {
protected:
  int ber2per(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf);
  int per2ber(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf);
  int ber2oer(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf);
  int oer2ber(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf);
  int recode(const asn_TYPE_descriptor_s &td, int from, int to, TTCN_Buffer &buf);
}; // End of class asn1_recode_per
Loading