Commit 02fa652d authored by Yann Garcia's avatar Yann Garcia
Browse files

Use of built-in TITAN ASN.1 codec; Renaming some of layers/codecs

parent ea297f90
Loading
Loading
Loading
Loading
+62 −36
Original line number Diff line number Diff line
@@ -12,20 +12,14 @@ ifeq (,$(TOPDIR))
 TOPDIR := .
endif

ifeq (,$(TTCN3_DIR))
 $(error TTCN3_DIR shall be defined in config.mk)
ifeq (,$(TOP_DIR))
 TOP_DIR := .
endif

ifeq (,$(ASN1C))
 ifneq (,$(ASN1C_PATH))
  ASN1C := $(ASN1C_PATH)/asn1c/.libs/asn1c -S $(ASN1C_PATH)/skeletons
 else
  ASN1C := asn1c
 endif
ifeq (,$(TTCN3_DIR))
 $(error TTCN3_DIR shall be defined in config.mk)
endif

export ASN1C_PATH

first: all

define IncludeModule
@@ -56,8 +50,8 @@ endif

libs += -lssl -lcrypto -lxml2 -ljsoncpp -lzip

bindir := $(TOPDIR)/bin
outdir := $(TOPDIR)/build/$(ATS)
bindir := $(TOPDIR)/bin

$(eval $(call IncludeModule, $(TOPDIR)/ttcn/$(ATS)))

@@ -93,9 +87,9 @@ cc_objects := $(patsubst %.cc, $(outdir)/%.o, $(cc_sources))

outbin = $(bindir)/$(ATS)$(SUB_ATS)$(EXE)

.PHONY: all FORCE echo postamble
.PHONY: all FORCE echo

all: $(bindir) $(outdir) $(outbin) postamble
all: $(bindir) $(outdir) $(outbin) 

echo_sources:
	@echo -e "$(addsuffix \n,$(all_sources))"
@@ -109,8 +103,7 @@ echo: echo_sources
	@echo -e "defines: $(addsuffix \n, $(defines))"

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

regen: force_regen $(outdir)/.generate
force_regen:
@@ -128,18 +121,18 @@ t3d: all
	@echo -e "TTCN-3 doc generation done..."
	@echo -e "Output file is located here: $(outdir)/t3d.out"

$(outdir) $(outdir)/asn1 $(bindir):
$(outdir) $(outdir)/asn1 $(bindir):  $(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSapplMgmtIDs.asn $(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSapplMgmtIDs.asn $(TOP_DIR)/./build/asn1/ISO_TS_19091/ISO-TS-19091-addgrp-C-2018-patched.asn $(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSdataDictionary1.asn $(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSdataDictionary2.asn
	mkdir -p $@

$(outbin): $(outdir)/asn1/libItsAsn.a $(gen_objects) $(cc_objects) 
	g++ -g -O0 -std=c++17 -o $@ $(LDFLAGS) $(gen_objects) $(cc_objects) $(outdir)/asn1/libItsAsn.a $(libs)
$(outbin): $(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 $@ $<
	g++ -g -O0 -std=c++17 -Wno-long-long -flarge-source-files -Wmisleading-indentation -fPIC -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<

$(cc_objects) : $(outdir)/%.o : %.cc
	mkdir -p $(dir $@)
	g++ -g -O0 -std=c++17 -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<
	g++ -g -O0 -std=c++17 -Wno-long-long -flarge-source-files -Wmisleading-indentation -fPIC -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<

#$(gen_sources):
#	$(TTCN3_DIR)/bin/compiler -n -e -L -R -U none -o $(outdir) $(tt_sources)
@@ -150,25 +143,58 @@ $(outdir)/.generate: Makefile $(tt_sources)
	$(TTCN3_DIR)/bin/compiler $(TTCN3_COMPILER_OPTIONS) -o  $(outdir) $(tt_sources)
	touch $@

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

$(outdir)/asn1/libItsAsn.a: $(asn_sources) $(asn1_sources) libasn1.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 libasn1.mk                                                          >>$(outdir)/asn1/Makefile
	$(MAKE) -C $(outdir)/asn1
	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):
#$(asn_sources) $(asn1_sources):

$(TOP_DIR)/./build/asn1/ISO_TS_14816/AVIAEINumberingAndDataStructures.asn:
	mkdir -p "$(dir $@)"
	curl 'https://standards.iso.org/iso/14816/ISO14816%20ASN.1%20repository/ISO14816_AVIAEINumberingAndDataStructures.asn' | \
	sed -e 's/IssuerIdentifier/AVIAEIIssuerIdentifier/g' > "$@"

#$(TOP_DIR)/./build/asn1/ISO_TS_14906/EfcDsrcApplication.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/14906/ed-3/en/ISO14906(2018)EfcDsrcApplicationv6.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_14906/EfcDsrcGeneric.asn:
#	mkdir -p "$(dir $@)
#	curl -o "$@" 'https://standards.iso.org/iso/14906/ed-3/en/ISO14906(2018)EfcDsrcGenericv7.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_ISO17573_3/EfcDataDictionary.asn:
#	mkdir -p "$(dir $@)
#	curl -o "$@" 'https://standards.iso.org/iso/17573/-3/ed-1/en/ISO17573-3(2023)EfcDataDictionaryV1.3.asn'

$(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSapplMgmtIDs.asn:
	mkdir -p "$(dir $@)"
	curl -o "$@" 'https://standards.iso.org/iso/ts/17419/TS%2017419%20ASN.1%20repository/TS17419_2014_CITSapplMgmtIDs.asn'

$(TOP_DIR)/./build/asn1/ISO_TS_19091/ISO-TS-19091-addgrp-C-2018-patched.asn:
	mkdir -p "$(dir $@)"
	curl 'https://standards.iso.org/iso/ts/19091/ed-2/en/ISO-TS-19091-addgrp-C-2018.asn' | \
	sed -e 's/\bHeadingConfidence\b/HeadingConfidenceDSRC/g' \
        -e 's/\bSpeedConfidence\b/SpeedConfidenceDSRC/g' \
        -e 's/\bHeading\b/HeadingDSRC/g' > "$@"

$(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSdataDictionary1.asn:
	mkdir -p "$(dir $@)"
	curl -o "$@" 'https://standards.iso.org/iso/17419/ed-1/en/17419.1.asn'

$(TOP_DIR)/./build/asn1/ISO_TS_17419/CITSdataDictionary2.asn:
	mkdir -p "$(dir $@)"
	curl -o "$@" 'https://standards.iso.org/iso/17419/ed-1/en/17419.2.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_19321/IVI.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/ts/19321/ed-3/en/ISO_CD%20TS%2019321%20ed.3%20-%20id.82956%20Approval%20ISO19321IVIv3.1.asn'

#$(TOP_DIR)/./build/asn1/ISO_TS_19321/IVI-IS.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/ts/19321/ed-3/en/ISO_CD%20TS%2019321%20ed.3%20-%20id.82956%20Approval%20ISO19321IVI-IS.asn'

#$(TOP_DIR)/build/asn1/ISO_TS_24534-3/ElectronicRegistrationIdentificationVehicleDataModule.asn:
#	mkdir -p "$(dir $@)"
#	curl -o "$@" 'https://standards.iso.org/iso/24534/-3/ISO%2024534-3%20ASN.1%20repository/ISO24534-3_ElectronicRegistrationIdentificationVehicleDataModule_ForBallot.asn'
postamble:
+1 −2
Original line number Diff line number Diff line
@@ -289,13 +289,12 @@ Procedure:
    - $HOME/dev
    - $HOME/lib
- In $HOME/frameworks, build the following package:
    - asn1c, according the procedure specified [here](https://github.com/fillabs/asn1c.git)
    - TITAN, according the procedure specified [here](https://github.com/eclipse/titan.core)

- Clone the ETSI ITS protocols project into $HOME/dev folder

```sh
$ git clone --recurse-submodules --branch=TTF_T036 https://forge.etsi.org/gitlab/ITS/TS.ITS.git TS.ITS.TTF_T036
$ git clone --recurse-submodules --branch=TTF_T05x https://forge.etsi.org/gitlab/ITS/TS.ITS.git TS.ITS.TTF_T05x
```

- Execute the script install.sh
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@
        },
        {
            "path": "../../frameworks/titan/titan.core"
        },
        {
            "path": "../TS.ITS.TTF_T036"
        }
    ]
}
 No newline at end of file
+12 −12
Original line number Diff line number Diff line
@@ -1078,8 +1078,8 @@
    <FileResource projectRelativePath="bin/RTCMEM_PDU_Descriptions.o" relativeURI="bin/RTCMEM_PDU_Descriptions.o"/>
    <FileResource projectRelativePath="bin/RtcmemCodec.d" relativeURI="bin/RtcmemCodec.d"/>
    <FileResource projectRelativePath="bin/RtcmemCodec.o" relativeURI="bin/RtcmemCodec.o"/>
    <FileResource projectRelativePath="bin/RtcmemLayer.d" relativeURI="bin/RtcmemLayer.d"/>
    <FileResource projectRelativePath="bin/RtcmemLayer.o" relativeURI="bin/RtcmemLayer.o"/>
    <FileResource projectRelativePath="bin/rtcmem_layer.d" relativeURI="bin/rtcmem_layer.d"/>
    <FileResource projectRelativePath="bin/rtcmem_layer.o" relativeURI="bin/rtcmem_layer.o"/>
    <FileResource projectRelativePath="bin/RtcmemPort.d" relativeURI="bin/RtcmemPort.d"/>
    <FileResource projectRelativePath="bin/RtcmemPort.o" relativeURI="bin/RtcmemPort.o"/>
    <FileResource projectRelativePath="bin/SPATEM_PDU_Descriptions.cc" relativeURI="bin/SPATEM_PDU_Descriptions.cc"/>
@@ -1096,8 +1096,8 @@
    <FileResource projectRelativePath="bin/SSEM_PDU_Descriptions.o" relativeURI="bin/SSEM_PDU_Descriptions.o"/>
    <FileResource projectRelativePath="bin/SremCodec.d" relativeURI="bin/SremCodec.d"/>
    <FileResource projectRelativePath="bin/SremCodec.o" relativeURI="bin/SremCodec.o"/>
    <FileResource projectRelativePath="bin/SremSsemLayer.d" relativeURI="bin/SremSsemLayer.d"/>
    <FileResource projectRelativePath="bin/SremSsemLayer.o" relativeURI="bin/SremSsemLayer.o"/>
    <FileResource projectRelativePath="bin/srem_ssem_layer.d" relativeURI="bin/srem_ssem_layer.d"/>
    <FileResource projectRelativePath="bin/srem_ssem_layer.o" relativeURI="bin/srem_ssem_layer.o"/>
    <FileResource projectRelativePath="bin/SremSsemPort.d" relativeURI="bin/SremSsemPort.d"/>
    <FileResource projectRelativePath="bin/SremSsemPort.o" relativeURI="bin/SremSsemPort.o"/>
    <FileResource projectRelativePath="bin/SsemCodec.d" relativeURI="bin/SsemCodec.d"/>
@@ -1522,10 +1522,10 @@
    <FileResource projectRelativePath="ccsrc/Protocols/RawSocket/module.mk" relativeURI="ccsrc/Protocols/RawSocket/module.mk"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/RtcmemCodec.cc" relativeURI="ccsrc/Protocols/Rtcmem/RtcmemCodec.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/RtcmemCodec.hh" relativeURI="ccsrc/Protocols/Rtcmem/RtcmemCodec.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/RtcmemLayer.cc" relativeURI="ccsrc/Protocols/Rtcmem/RtcmemLayer.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/RtcmemLayer.hh" relativeURI="ccsrc/Protocols/Rtcmem/RtcmemLayer.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/RtcmemLayerFactory.hh" relativeURI="ccsrc/Protocols/Rtcmem/RtcmemLayerFactory.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/RtcmemTypes.hh" relativeURI="ccsrc/Protocols/Rtcmem/RtcmemTypes.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/rtcmem_layer.cc" relativeURI="ccsrc/Protocols/Rtcmem/rtcmem_layer.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/rtcmem_layer.hh" relativeURI="ccsrc/Protocols/Rtcmem/rtcmem_layer.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/rtcmem_layer_factory.hh" relativeURI="ccsrc/Protocols/Rtcmem/rtcmem_layer_factory.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/rtcmem_types.hh" relativeURI="ccsrc/Protocols/Rtcmem/rtcmem_types.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Rtcmem/module.mk" relativeURI="ccsrc/Protocols/Rtcmem/module.mk"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Security/certificates_loader.cc" relativeURI="ccsrc/Protocols/Security/certificates_loader.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/Security/certificates_loader.hh" relativeURI="ccsrc/Protocols/Security/certificates_loader.hh"/>
@@ -1583,10 +1583,10 @@
    <FileResource projectRelativePath="ccsrc/Protocols/Security/sha384.hh" relativeURI="ccsrc/Protocols/Security/sha384.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SremCodec.cc" relativeURI="ccsrc/Protocols/SremSsem/SremCodec.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SremCodec.hh" relativeURI="ccsrc/Protocols/SremSsem/SremCodec.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SremSsemLayer.cc" relativeURI="ccsrc/Protocols/SremSsem/SremSsemLayer.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SremSsemLayer.hh" relativeURI="ccsrc/Protocols/SremSsem/SremSsemLayer.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SremSsemLayerFactory.hh" relativeURI="ccsrc/Protocols/SremSsem/SremSsemLayerFactory.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SremSsemTypes.hh" relativeURI="ccsrc/Protocols/SremSsem/SremSsemTypes.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/srem_ssem_layer.cc" relativeURI="ccsrc/Protocols/SremSsem/srem_ssem_layer.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/srem_ssem_layer.hh" relativeURI="ccsrc/Protocols/SremSsem/srem_ssem_layer.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/srem_ssem_layer_factory.hh" relativeURI="ccsrc/Protocols/SremSsem/srem_ssem_layer_factory.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/srem_ssem_types.hh" relativeURI="ccsrc/Protocols/SremSsem/srem_ssem_types.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SsemCodec.cc" relativeURI="ccsrc/Protocols/SremSsem/SsemCodec.cc"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/SsemCodec.hh" relativeURI="ccsrc/Protocols/SremSsem/SsemCodec.hh"/>
    <FileResource projectRelativePath="ccsrc/Protocols/SremSsem/module.mk" relativeURI="ccsrc/Protocols/SremSsem/module.mk"/>

ccsrc/Asn1c/asn1_recoder.cc

deleted100644 → 0
+0 −51
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);
}

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);
}

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);
}
Loading