Commit ce3fe62d authored by Denis Filatov's avatar Denis Filatov
Browse files

construct asn1 file list dynamically. Check presense.

parent 6b5823d3
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -12,6 +12,14 @@ 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
@@ -26,8 +34,8 @@ $$(foreach I, $$(includes), $$(eval all_includes += $$(if $$(filter /%, $$(I)),
$$(foreach M, $$(modules),  $$(eval $$(call IncludeModule, $$(if $$(filter /%, $$(M)), $$(TOPDIR)/$$(M), $(1)/$$(M)))))
endef

all_includes := $(TTCN3_DIR)/include $(TTCN3_DIR)/src /usr/include/jsoncpp
defines  += TITAN_RUNTIME_2 _NO_SOFTLINKS_ $(ATS)  AS_USE_SSL
all_includes := $(TTCN3_DIR)/include $(TTCN3_DIR)/src /usr/include/jsoncpp /usr/include/libxml2
defines  += TITAN_RUNTIME_2 _NO_SOFTLINKS_ $(ATS)  AS_USE_SSL _GNU_SOURCE
libs     += $(TTCN3_DIR)/lib/libttcn3-rt2-parallel.a -lstdc++fs

ifeq (Windows_NT,$(OS))
@@ -49,7 +57,8 @@ $(eval $(call IncludeModule, $(TOPDIR)/ttcn/$(ATS)))
outdir := $(TOPDIR)/build/$(ATS)
bindir := $(TOPDIR)/bin

sources     := $(sort $(all_sources))
#sources     := $(sort $(all_sources))
sources     := $(all_sources)
includes    := $(outdir) $(outdir)/.. $(outdir)/../asn1 $(all_includes) $(NPCAP_INCLUDE)

ifeq (Windows_NT,$(OS))
@@ -114,11 +123,11 @@ t3d: all
	@echo -e "TTCN-3 doc generation done..."
	@echo -e "Output file is located here: $(outdir)/t3d.out"

$(outdir) $(bindir):
$(outdir) $(outdir)/asn1 $(bindir):
	mkdir -p $@

$(bindir)/$(ATS)$(EXE): $(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)
$(bindir)/$(ATS)$(EXE): $(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)

$(gen_objects) :%.o :%.cc
	g++ -g -O0 -std=c++17 -c $(addprefix -D, $(defines)) $(addprefix -I, $(includes)) -o $@ $<
@@ -139,9 +148,16 @@ $(outdir)/.generate: Makefile $(tt_sources)
$(bindir)/libItsAsn.so: $(outdir)/asn1/libItsAsn.so
	cp -f $< $@

$(outdir)/../asn1/libItsAsn.a: FORCE
	mkdir -p $(outdir)/../asn1
	$(MAKE) -C $(outdir)/../asn1 -f ../../asn1/Makefile
$(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)))

asn1/Makefile

deleted100644 → 0
+0 −209
Original line number Diff line number Diff line
##########################################################
#  This Makefile is to build the ASN1 library to be used
#  for external codec in Titan
#  This Makefile is expected that asn1c compiler is 
#  installed in the PATHs
##########################################################

# The name of the library
ASN_LIBRARY = libItsAsn.a
# ASN.1 files to be included in the library
ASN_FILES = \
            AtsMBR/lib/asn1/EtsiTs103759AsrAppAgnostic.asn                      \
            AtsMBR/lib/asn1/EtsiTs103759AsrCam.asn                              \
            AtsMBR/lib/asn1/EtsiTs103759AsrDenm.asn                             \
            AtsMBR/lib/asn1/EtsiTs103759BaseTypes.asn                           \
            AtsMBR/lib/asn1/EtsiTs103759CommonObservations.asn                  \
            AtsMBR/lib/asn1/EtsiTs103759Core.asn                                \
            AtsMBR/lib/asn1/SaeJ3287AsrBsm.asn                                  \
            AtsSecurity/lib/asn1/EtsiTs103097ExtensionModule.asn                \
            AtsSecurity/lib/asn1/EtsiTs103097Module.asn                         \
            AtsSecurity/lib/asn1/ieee1609dot2/IEEE1609dot2BaseTypes.asn         \
            AtsSecurity/lib/asn1/ieee1609dot2/IEEE1609dot2.asn                  \
            AtsPki/lib/asn1/ieee_1609.2.1/ieee1609dot2/Ieee1609Dot2Crl.asn      \
            AtsPki/lib/asn1/ieee_1609.2.1/ieee1609dot2/Ieee1609Dot2CrlBaseTypes.asn \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1AcaEeInterface.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1AcaLaInterface.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1AcaMaInterface.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1AcaRaInterface.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1Acpc.asn              \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1CamRaInterface.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1CertManagement.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1EcaEeInterface.asn    \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1EeMaInterface.asn     \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1EeRaInterface.asn     \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1LaMaInterface.asn     \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1LaRaInterface.asn     \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1MaRaInterface.asn     \
            AtsPki/lib/asn1/ieee_1609.2.1/Ieee1609Dot2Dot1Protocol.asn          \
            AtsCAM/lib/asn1/CAM_PDU_Descriptions.asn                            \
            AtsCAM/lib/asn1/cdd/ITS_Container.asn                               \
            AtsDENM/lib/asn1/DENM_PDU_Descriptions.asn                          \
            AtsIS/lib/asn1/IVIM_PDU_Descriptions.asn                            \
            AtsIS/lib/asn1/MAPEM_PDU_Descriptions.asn                           \
            AtsIS/lib/asn1/RTCMEM_PDU_Descriptions.asn                          \
            AtsIS/lib/asn1/SPATEM_PDU_Descriptions.asn                          \
            AtsIS/lib/asn1/SREM_PDU_Descriptions.asn                            \
            AtsIS/lib/asn1/SSEM_PDU_Descriptions.asn                            \
            AtsIS/lib/asn1/iso-patched/EfcDsrcApplication.asn                   \
            AtsIS/lib/asn1/iso-patched/EfcDsrcGeneric.asn                       \
            AtsIS/lib/asn1/iso-patched/ElectronicRegistrationIdentificationVehicleDataModule.asn \
            AtsIS/lib/asn1/iso-patched/GDD.asn                                  \
            AtsIS/lib/asn1/iso-patched/DSRC.asn                                 \
            AtsIS/lib/asn1/iso-patched/DSRC_noCircular.asn                      \
            AtsIS/lib/asn1/iso-patched/REGION.asn                               \
            AtsIS/lib/asn1/iso-patched/AddGrpC.asn                              \
            AtsIS/lib/asn1/iso-patched/AddGrpC_noCircular.asn                   \
            ../build/asn1/ISO_TS_14816/AVIAEINumberingAndDataStructures.asn     \
            ../build/asn1/ISO_TS_17419/CITSapplMgmtIDs.asn                      \
            ../build/asn1/ISO_TS_19321/IVI.asn                                  \


# PDUs
PDU = CAM DENM MAPEM SPATEM SREM SSEM IVIM RTCMEM EtsiTs103097Data EtsiTs103097Certificate EtsiTs103759Data
#EtsiTs102941Data

#patches
#PATCHES = PsidGroupPermissions.c.diff

ASN1C:=asn1c
#Override ASN1C instalation path
#ASN1C_PATH = 

ifneq (, $(ASN1C_PATH))
# OS=$(shell uname)
 ifneq (Windows_NT,$(OS))
  ASN1C:=$(ASN1C_PATH)/asn1c/asn1c -S $(ASN1C_PATH)/skeletons
 else
  ASN1C:=$(ASN1C_PATH)/asn1c/asn1c.exe -S $(ASN1C_PATH)/skeletons
 endif
endif

ifeq (,$(ASN_DIR))
##########################################################
# Build path for the library
BIN_DIR := .
SCRIPT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
ASN_DIR := $(dir $(SCRIPT_DIR))../ttcn

.PHONY: FORCE

all: $(BIN_DIR)/$(ASN_LIBRARY)
clean:
	rm -rf $(BIN_DIR)

$(BIN_DIR)/$(ASN_LIBRARY): $(BIN_DIR)/Makefile
	make -C $(BIN_DIR) all

$(BIN_DIR):
	mkdir -p $@

$(BIN_DIR)/Makefile: $(BIN_DIR) $(SCRIPT_DIR)/Makefile
	echo SCRIPT_DIR=$(SCRIPT_DIR) > $@
	echo ASN_DIR=$(ASN_DIR)       >>$@
	cat $(SCRIPT_DIR)/Makefile    >>$@

##########################################################
else
##########################################################
# This part is executed within the BIN_DIR directory to
# override variables from the Makefile.am.libasncodec 
# generated by asn1c
LIB_MAKEFILE=Makefile.am.libasncodec
include $(LIB_MAKEFILE)
OBJS = ${ASN_MODULE_SRCS:.c=.o}
CONVERTER=converter
ASN_CONVERTER_SOURCES := \
	converter-example.c\
	pdu_collection.c
CONVERTER_OBJS=${ASN_CONVERTER_SOURCES:.c=.o}
CFLAGS += $(ASN_MODULE_CFLAGS) -DPDU=CAM -DASN_PDU_COLLECTION -fPIC -I.
CC = gcc -std=c99
GEN_EXAMPLE=-no-gen-example 
ifeq (yes,$(DEBUG))
  CFLAGS += -g -O0 -DASN_EMIT_DEBUG=1
endif

all: Makefile $(ASN_LIBRARY)

$(LIB_MAKEFILE): $(addprefix $(ASN_DIR)/, $(ASN_FILES))
	$(ASN1C) $(GEN_EXAMPLE) $(addprefix -pdu=,$(PDU)) -fcompound-names $^
	-for n in $(PATCHES); do git apply "$(SCRIPT_DIR)/$$n"; done

$(CONVERTER): $(ASN_LIBRARY) $(CONVERTER_OBJS) 
	$(CC) $(CFLAGS) -o $@ $(CONVERTER_OBJS) $(ASN_LIBRARY) $(LIBS)

$(ASN_LIBRARY): ${ASN_MODULE_SRCS:.c=.o}
	ar rcs $@ $^
#	$(CC) $(CFLAGS) -o $@ $^ -shared $(LDFLAGS) $(LIBS)

.SUFFIXES:
.SUFFIXES: .c .o

.c.o:
	$(CC) $(CFLAGS) -o $@ -c $<

clean:
	rm -f $(CONVERTER) $(ASN_LIBRARY)
	rm -f $(OBJS) $(CONVERTER_OBJS)

regen: clear-asn1c $(LIB_MAKEFILE)
clear-asn1c:
	rm -f $(LIB_MAKEFILE)

Makefile: $(SCRIPT_DIR)/Makefile
	echo SCRIPT_DIR=$(SCRIPT_DIR) > $@
	echo ASN_DIR=$(ASN_DIR) >>$@
	cat $<                  >>$@
##########################################################

$(ASN_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' > "$@"

#../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'

#../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'

$(ASN_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'

$(ASN_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' > "$@"

$(ASN_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'

$(ASN_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'

#../build/asn1/ISO_TS_19091/AddGrpC.asn:
#../build/asn1/ISO_TS_19091/AddGrpC_noCircular.asn:
#../build/asn1/ISO_TS_19091/DSRC.asn:
#../build/asn1/ISO_TS_19091/DSRC_REGION_noCircular.asn
#../build/asn1/ISO_TS_19091/REGION.asn

$(ASN_DIR)/../build/asn1/ISO_TS_19321/IVI.asn:
	mkdir -p "$(dir $@)"
	curl 'https://standards.iso.org/iso/ts/19321/ed-2/en/ISO19321IVIv2.asn' | \
	sed -e 's/\bCITSdataDictionary1\b/CITSapplMgmtIDs/g' \
	    -e 's/,\s*\.\.\.\s*,\s*[0-9]\+/,.../g' \
	> "$@"

#$(ASN_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'

endif

asn1/PsidGroupPermissions.c.diff

deleted100644 → 0
+0 −35
Original line number Diff line number Diff line
--- PsidGroupPermissions.c-orig	2018-08-23 15:50:25.762030100 +0200
+++ PsidGroupPermissions.c	2018-09-10 16:47:19.921571200 +0200
@@ -51,6 +51,22 @@
 	*st = 0;
 	return 0;
 }
+static int asn_DFL_5_cmp_0(const void *sptr) {
+	uint8_t def_buf[] = { 0 };
+	BIT_STRING_t def = { &def_buf[0], 1, 7 };
+	return BIT_STRING_compare(&asn_DEF_EndEntityType, sptr, &def);
+}
+
+static int asn_DFL_5_set_0(void **sptr) {
+	BIT_STRING_t * st = *(BIT_STRING_t **)sptr;
+	if (!st) {
+		st = (*sptr = CALLOC(1, sizeof(*st)));
+		if (!st) return -1;
+	}
+	OCTET_STRING_fromBuf((OCTET_STRING_t *)st, "\x0", 1);
+	return 0;
+}
+
 asn_TYPE_member_t asn_MBR_PsidGroupPermissions_1[] = {
 	{ ATF_NOFLAGS, 0, offsetof(struct PsidGroupPermissions, subjectPermissions),
 		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
@@ -87,7 +103,8 @@
 		&asn_DEF_EndEntityType,
 		0,
 		{ 0, 0, 0 },
-		0, 0, /* No default value */
+		asn_DFL_5_cmp_0,
+		asn_DFL_5_set_0,
 		"eeType"
 		},
 };
+13 −7
Original line number Diff line number Diff line
#include <asn1/asn_application.h>

#include "asn1_recode_per.hh"
#include "asn1_recoder.hh"

#include <TTCN3.hh>

@@ -12,7 +12,7 @@ static int asn1c_collect_encoded_data(const void *buffer, size_t size, void *app
}
}

int asn1_recode_per::recode(const asn_TYPE_descriptor_s &td, int from, int to, TTCN_Buffer &buf) {
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;
@@ -30,16 +30,22 @@ int asn1_recode_per::recode(const asn_TYPE_descriptor_s &td, int from, int to, T
  return rc;
}

int asn1_recode_per::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::ber2per(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf) 
{
  return recode(td, (int)ATS_BER, (int)ATS_UNALIGNED_CANONICAL_PER, buf);
}

int asn1_recode_per::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::per2ber(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf) 
{
  return recode(td, (int)ATS_UNALIGNED_BASIC_PER, (int)ATS_DER, buf);
}

/*int asn1_recode_oer::ber2oer(const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf)
int asn1_recoder::ber2oer(const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf)
{
  return recode(td, (int)ATS_XER, (int)ATS_CANONICAL_OER, buf);
}

int asn1_recode_oer::oer2ber(const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf)
int asn1_recoder::oer2ber(const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf)
{
  return recodeOer(td, (int)ATS_BASIC_OER, (int)ATS_XER, buf);
  }*/
}
+3 −1
Original line number Diff line number Diff line
@@ -19,9 +19,11 @@ class TTCN_Typedescriptor_t; //! Forward declaration of TITAN class

struct asn_TYPE_descriptor_s; //! Forward declaration of asn1c class

class asn1_recode_per {
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