├── .cproject ├── .project ├── Debug ├── makefile ├── objects.mk ├── sources.mk └── src │ ├── appHandshake │ └── subdir.mk │ ├── codec │ └── subdir.mk │ ├── din │ └── subdir.mk │ ├── iso1 │ └── subdir.mk │ ├── iso2 │ └── subdir.mk │ ├── test │ └── subdir.mk │ ├── transport │ └── subdir.mk │ └── xmldsig │ └── subdir.mk ├── LICENSE.txt ├── README.txt ├── Release ├── makefile ├── objects.mk ├── sources.mk └── src │ ├── appHandshake │ └── subdir.mk │ ├── codec │ └── subdir.mk │ ├── din │ └── subdir.mk │ ├── iso1 │ └── subdir.mk │ ├── iso2 │ └── subdir.mk │ ├── test │ └── subdir.mk │ ├── transport │ └── subdir.mk │ └── xmldsig │ └── subdir.mk ├── data ├── sessionSetupReq.xml ├── sessionSetupReq.xml.exi ├── sessionSetupRes.xml └── sessionSetupRes.xml.exi └── src ├── appHandshake ├── appHandEXIDatatypes.c ├── appHandEXIDatatypes.h ├── appHandEXIDatatypesDecoder.c ├── appHandEXIDatatypesDecoder.h ├── appHandEXIDatatypesEncoder.c └── appHandEXIDatatypesEncoder.h ├── codec ├── BitInputStream.c ├── BitInputStream.h ├── BitOutputStream.c ├── BitOutputStream.h ├── ByteStream.c ├── ByteStream.h ├── DecoderChannel.c ├── DecoderChannel.h ├── EXIConfig.h ├── EXIHeaderDecoder.c ├── EXIHeaderDecoder.h ├── EXIHeaderEncoder.c ├── EXIHeaderEncoder.h ├── EXIOptions.h ├── EXITypes.h ├── EncoderChannel.c ├── EncoderChannel.h ├── ErrorCodes.h ├── MethodsBag.c └── MethodsBag.h ├── din ├── dinEXIDatatypes.c ├── dinEXIDatatypes.h ├── dinEXIDatatypesDecoder.c ├── dinEXIDatatypesDecoder.h ├── dinEXIDatatypesEncoder.c └── dinEXIDatatypesEncoder.h ├── iso1 ├── iso1EXIDatatypes.c ├── iso1EXIDatatypes.h ├── iso1EXIDatatypesDecoder.c ├── iso1EXIDatatypesDecoder.h ├── iso1EXIDatatypesEncoder.c └── iso1EXIDatatypesEncoder.h ├── iso2 ├── iso2EXIDatatypes.c ├── iso2EXIDatatypes.h ├── iso2EXIDatatypesDecoder.c ├── iso2EXIDatatypesDecoder.h ├── iso2EXIDatatypesEncoder.c └── iso2EXIDatatypesEncoder.h ├── test ├── main.c ├── main.h ├── main_databinder.c └── main_example.c ├── transport ├── v2gtp.c └── v2gtp.h └── xmldsig ├── xmldsigEXIDatatypes.c ├── xmldsigEXIDatatypes.h ├── xmldsigEXIDatatypesDecoder.c ├── xmldsigEXIDatatypesDecoder.h ├── xmldsigEXIDatatypesEncoder.c └── xmldsigEXIDatatypesEncoder.h /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenV2G 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?name? 14 | 15 | 16 | 17 | org.eclipse.cdt.make.core.append_environment 18 | true 19 | 20 | 21 | org.eclipse.cdt.make.core.autoBuildTarget 22 | all 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | make 31 | 32 | 33 | org.eclipse.cdt.make.core.buildLocation 34 | ./OpenV2G/Debug 35 | 36 | 37 | org.eclipse.cdt.make.core.cleanBuildTarget 38 | clean 39 | 40 | 41 | org.eclipse.cdt.make.core.contents 42 | org.eclipse.cdt.make.core.activeConfigSettings 43 | 44 | 45 | org.eclipse.cdt.make.core.enableAutoBuild 46 | false 47 | 48 | 49 | org.eclipse.cdt.make.core.enableCleanBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.enableFullBuild 54 | true 55 | 56 | 57 | org.eclipse.cdt.make.core.fullBuildTarget 58 | all 59 | 60 | 61 | org.eclipse.cdt.make.core.stopOnError 62 | true 63 | 64 | 65 | org.eclipse.cdt.make.core.useDefaultBuildCmd 66 | true 67 | 68 | 69 | 70 | 71 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 72 | 73 | 74 | 75 | 76 | 77 | org.eclipse.cdt.core.cnature 78 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 79 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 80 | 81 | 82 | -------------------------------------------------------------------------------- /Debug/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/xmldsig/subdir.mk 12 | -include src/transport/subdir.mk 13 | -include src/test/subdir.mk 14 | -include src/iso2/subdir.mk 15 | -include src/iso1/subdir.mk 16 | -include src/din/subdir.mk 17 | -include src/codec/subdir.mk 18 | -include src/appHandshake/subdir.mk 19 | -include subdir.mk 20 | -include objects.mk 21 | 22 | ifneq ($(MAKECMDGOALS),clean) 23 | ifneq ($(strip $(C_DEPS)),) 24 | -include $(C_DEPS) 25 | endif 26 | endif 27 | 28 | -include ../makefile.defs 29 | 30 | # Add inputs and outputs from these tool invocations to the build variables 31 | 32 | # All Target 33 | all: OpenV2G.exe 34 | 35 | # Tool invocations 36 | OpenV2G.exe: $(OBJS) $(USER_OBJS) 37 | @echo 'Building target: $@' 38 | @echo 'Invoking: MinGW C Linker' 39 | gcc -o "OpenV2G.exe" $(OBJS) $(USER_OBJS) $(LIBS) 40 | @echo 'Finished building target: $@' 41 | @echo ' ' 42 | 43 | # Other Targets 44 | clean: 45 | -$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) OpenV2G.exe 46 | -@echo ' ' 47 | 48 | .PHONY: all clean dependents 49 | .SECONDARY: 50 | 51 | -include ../makefile.targets 52 | -------------------------------------------------------------------------------- /Debug/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := 8 | 9 | -------------------------------------------------------------------------------- /Debug/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | OBJ_SRCS := 6 | ASM_SRCS := 7 | C_SRCS := 8 | S_UPPER_SRCS := 9 | O_SRCS := 10 | EXECUTABLES := 11 | OBJS := 12 | C_DEPS := 13 | 14 | # Every subdirectory with source files must be described here 15 | SUBDIRS := \ 16 | src/xmldsig \ 17 | src/transport \ 18 | src/test \ 19 | src/iso2 \ 20 | src/iso1 \ 21 | src/din \ 22 | src/codec \ 23 | src/appHandshake \ 24 | 25 | -------------------------------------------------------------------------------- /Debug/src/appHandshake/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/appHandshake/appHandEXIDatatypes.c \ 8 | ../src/appHandshake/appHandEXIDatatypesDecoder.c \ 9 | ../src/appHandshake/appHandEXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/appHandshake/appHandEXIDatatypes.o \ 13 | ./src/appHandshake/appHandEXIDatatypesDecoder.o \ 14 | ./src/appHandshake/appHandEXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/appHandshake/appHandEXIDatatypes.d \ 18 | ./src/appHandshake/appHandEXIDatatypesDecoder.d \ 19 | ./src/appHandshake/appHandEXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/appHandshake/%.o: ../src/appHandshake/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Debug/src/codec/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/codec/BitInputStream.c \ 8 | ../src/codec/BitOutputStream.c \ 9 | ../src/codec/ByteStream.c \ 10 | ../src/codec/DecoderChannel.c \ 11 | ../src/codec/EXIHeaderDecoder.c \ 12 | ../src/codec/EXIHeaderEncoder.c \ 13 | ../src/codec/EncoderChannel.c \ 14 | ../src/codec/MethodsBag.c 15 | 16 | OBJS += \ 17 | ./src/codec/BitInputStream.o \ 18 | ./src/codec/BitOutputStream.o \ 19 | ./src/codec/ByteStream.o \ 20 | ./src/codec/DecoderChannel.o \ 21 | ./src/codec/EXIHeaderDecoder.o \ 22 | ./src/codec/EXIHeaderEncoder.o \ 23 | ./src/codec/EncoderChannel.o \ 24 | ./src/codec/MethodsBag.o 25 | 26 | C_DEPS += \ 27 | ./src/codec/BitInputStream.d \ 28 | ./src/codec/BitOutputStream.d \ 29 | ./src/codec/ByteStream.d \ 30 | ./src/codec/DecoderChannel.d \ 31 | ./src/codec/EXIHeaderDecoder.d \ 32 | ./src/codec/EXIHeaderEncoder.d \ 33 | ./src/codec/EncoderChannel.d \ 34 | ./src/codec/MethodsBag.d 35 | 36 | 37 | # Each subdirectory must supply rules for building sources it contributes 38 | src/codec/%.o: ../src/codec/%.c 39 | @echo 'Building file: $<' 40 | @echo 'Invoking: GCC C Compiler' 41 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 42 | @echo 'Finished building: $<' 43 | @echo ' ' 44 | 45 | 46 | -------------------------------------------------------------------------------- /Debug/src/din/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/din/dinEXIDatatypes.c \ 8 | ../src/din/dinEXIDatatypesDecoder.c \ 9 | ../src/din/dinEXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/din/dinEXIDatatypes.o \ 13 | ./src/din/dinEXIDatatypesDecoder.o \ 14 | ./src/din/dinEXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/din/dinEXIDatatypes.d \ 18 | ./src/din/dinEXIDatatypesDecoder.d \ 19 | ./src/din/dinEXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/din/%.o: ../src/din/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Debug/src/iso1/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/iso1/iso1EXIDatatypes.c \ 8 | ../src/iso1/iso1EXIDatatypesDecoder.c \ 9 | ../src/iso1/iso1EXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/iso1/iso1EXIDatatypes.o \ 13 | ./src/iso1/iso1EXIDatatypesDecoder.o \ 14 | ./src/iso1/iso1EXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/iso1/iso1EXIDatatypes.d \ 18 | ./src/iso1/iso1EXIDatatypesDecoder.d \ 19 | ./src/iso1/iso1EXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/iso1/%.o: ../src/iso1/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Debug/src/iso2/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/iso2/iso2EXIDatatypes.c \ 8 | ../src/iso2/iso2EXIDatatypesDecoder.c \ 9 | ../src/iso2/iso2EXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/iso2/iso2EXIDatatypes.o \ 13 | ./src/iso2/iso2EXIDatatypesDecoder.o \ 14 | ./src/iso2/iso2EXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/iso2/iso2EXIDatatypes.d \ 18 | ./src/iso2/iso2EXIDatatypesDecoder.d \ 19 | ./src/iso2/iso2EXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/iso2/%.o: ../src/iso2/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Debug/src/test/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/test/main.c \ 8 | ../src/test/main_databinder.c \ 9 | ../src/test/main_example.c 10 | 11 | OBJS += \ 12 | ./src/test/main.o \ 13 | ./src/test/main_databinder.o \ 14 | ./src/test/main_example.o 15 | 16 | C_DEPS += \ 17 | ./src/test/main.d \ 18 | ./src/test/main_databinder.d \ 19 | ./src/test/main_example.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/test/%.o: ../src/test/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Debug/src/transport/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/transport/v2gtp.c 8 | 9 | OBJS += \ 10 | ./src/transport/v2gtp.o 11 | 12 | C_DEPS += \ 13 | ./src/transport/v2gtp.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | src/transport/%.o: ../src/transport/%.c 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: GCC C Compiler' 20 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /Debug/src/xmldsig/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/xmldsig/xmldsigEXIDatatypes.c \ 8 | ../src/xmldsig/xmldsigEXIDatatypesDecoder.c \ 9 | ../src/xmldsig/xmldsigEXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/xmldsig/xmldsigEXIDatatypes.o \ 13 | ./src/xmldsig/xmldsigEXIDatatypesDecoder.o \ 14 | ./src/xmldsig/xmldsigEXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/xmldsig/xmldsigEXIDatatypes.d \ 18 | ./src/xmldsig/xmldsigEXIDatatypesDecoder.d \ 19 | ./src/xmldsig/xmldsigEXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/xmldsig/%.o: ../src/xmldsig/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------- 2 | OpenV2G - an open source project implementing the basic functionality of the ISO IEC 15118 vehicle to grid (V2G) communication interface 3 | Version 0.9.4, released January 30, 2018 4 | http://openv2g.sourceforge.net/ 5 | 6 | Please report bugs via the SourceForge bug tracking system at http://sourceforge.net/tracker/?group_id=350113. 7 | Thank you. 8 | 9 | Copyright (C) 2007-2018 Siemens AG 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU Lesser General Public License as published 13 | by the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public License 22 | along with this program. If not, see . 23 | 24 | 25 | ------------------------------------------------------------------------- 26 | CHANGES from version 0.9.3: 27 | ------------------------------------------------------------------------- 28 | * Support for 15118-2-2016 (ISO2) started besides 15118-2-2013 (ISO1) and DIN 29 | * fix eMAID fragment encoding/decoding support 30 | * internal coding updates 31 | * bug-fixes 32 | 33 | ------------------------------------------------------------------------- 34 | CHANGES from version 0.9.2: 35 | ------------------------------------------------------------------------- 36 | * resolves XML signature interoperability issue 37 | Note: To make use of xmldsig the following defines have to be set. 38 | in "xmldsigEXIDatatypes.h" 39 | #define DEPLOY_XMLDSIG_CODEC SUPPORT_YES 40 | #define DEPLOY_XMLDSIG_CODEC_FRAGMENT SUPPORT_YES 41 | in "v2gEXIDatatypes.h" 42 | #define DEPLOY_ISO_CODEC_FRAGMENT SUPPORT_YES 43 | Otherwise the code is turned off. 44 | 45 | ------------------------------------------------------------------------- 46 | CHANGES from version 0.9.1: 47 | ------------------------------------------------------------------------- 48 | * resolves bug with name clashes w.r.t. iso and din track 49 | * fixes issue with test code for init handshake 50 | * Note: OpenV2G 0.9.2 is essentially just a bug fixed version of OpenV2G 0.9.1 51 | 52 | ------------------------------------------------------------------------- 53 | CHANGES from version 0.9: 54 | ------------------------------------------------------------------------- 55 | * includes support for DIN and hence interoperability with OpenV2G 0.7 56 | (needs to be switched on though by #define DEPLOY_DIN_CODEC) 57 | * fixes bugs and warnings for Visual Studio 58 | * Note: OpenV2G 0.9.1 is a superset of previous versions 59 | v2g...c/h files support ISO track 60 | din...c/h files support DIN track 61 | 62 | ------------------------------------------------------------------------- 63 | CHANGES from version 0.8: 64 | ------------------------------------------------------------------------- 65 | * large code footprint reduction which resulted in a new API 66 | (please take a look at the example in src/test folder) 67 | * datatype differences w.r.t. arrays, strings, bytes, isUsed, and enum-naming 68 | * bug-fixes 69 | * Note: OpenV2G 0.8 and 0.9 are interoperable, meaning that one can generate 70 | streams with one and decode with the other or vice-versa 71 | 72 | ------------------------------------------------------------------------- 73 | CHANGES from version 0.7: 74 | ------------------------------------------------------------------------- 75 | * adaption of V2G schema changes (reflects the ISO/IEC 15118-2 FDIS status) 76 | * bug-fixes 77 | 78 | 79 | ------------------------------------------------------------------------- 80 | CHANGES from version 0.7: 81 | ------------------------------------------------------------------------- 82 | * adaption of V2G schema changes (reflects the ISO/IEC 15118-2 FDIS status) 83 | * bug-fixes 84 | 85 | ------------------------------------------------------------------------- 86 | CHANGES from version 0.6: 87 | ------------------------------------------------------------------------- 88 | * adaption of V2G schema changes (reflects the ISO/IEC 15118-2 DIS status and DIN 70121) 89 | * reduced memory usage 90 | * EXI decoder skips schema deviations according to EXI Profile 91 | * bug-fixes 92 | 93 | ------------------------------------------------------------------------- 94 | CHANGES from version 0.5: 95 | ------------------------------------------------------------------------- 96 | * adaption of V2G schema changes 97 | * application handshake protocol implementation 98 | * asynchronised communication 99 | * reduced memory usage 100 | * changed V2GTP byte order from little endian to big endian 101 | * bug-fixes 102 | * updated AC demo interaction between EV and EVSE, and 103 | * updated DC demo interaction between EV and EVSE 104 | 105 | 106 | ------------------------------------------------------------------------- 107 | CHANGES from version 0.4: 108 | ------------------------------------------------------------------------- 109 | * adaption of V2G schema changes 110 | * V2GTP implementation (replaces the DoIP implementation) 111 | * EXI default coder for the 15118 schema (replaces the strict mode of EXI) 112 | * AC demo interaction between PEV and EVSE, and 113 | * DC demo interaction between PEV and EVSE 114 | 115 | 116 | ------------------------------------------------------------------------- 117 | CHANGES from version 0.3.1: 118 | ------------------------------------------------------------------------- 119 | * adaption of V2G schema changes 120 | * supporting of DC messages 121 | * example program showing the message sequence of AC charging and 122 | DC charging 123 | * bug-fixes 124 | 125 | ------------------------------------------------------------------------- 126 | CHANGES from version 0.3: 127 | ------------------------------------------------------------------------- 128 | * Bug-fixes 129 | * reduced memory usage 130 | * some type changes in the EXI codec and V2G service: 131 | ** struct v2gService->struct EXIService in v2g_service.h 132 | ** size_t->uint16_t in v2g_serviceClientDataTransmitter.h and doIP.h 133 | * renaming of some enumeration values in v2g_serviceDataTypes.h 134 | 135 | ------------------------------------------------------------------------- 136 | CHANGES from version 0.2.2: 137 | ------------------------------------------------------------------------- 138 | * Bug-fixes 139 | * first DoIP implementation 140 | * V2G message error handling 141 | * adaption of V2G schema changes 142 | * code optimizations 143 | 144 | ------------------------------------------------------------------------- 145 | CHANGES from version 0.2.1: 146 | ------------------------------------------------------------------------- 147 | * Bug-fixes 148 | * adaption of V2G schema changes 149 | * some code optimizations 150 | 151 | ------------------------------------------------------------------------- 152 | CHANGES from version 0.2: 153 | ------------------------------------------------------------------------- 154 | * Bug-fixes 155 | * Fixed compiler warnings 156 | 157 | ------------------------------------------------------------------------- 158 | CHANGES from version 0.1: 159 | ------------------------------------------------------------------------- 160 | * Bug-fixes 161 | * Service and Client added -------------------------------------------------------------------------------- /Release/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm -rf 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include src/xmldsig/subdir.mk 12 | -include src/transport/subdir.mk 13 | -include src/test/subdir.mk 14 | -include src/iso2/subdir.mk 15 | -include src/iso1/subdir.mk 16 | -include src/din/subdir.mk 17 | -include src/codec/subdir.mk 18 | -include src/appHandshake/subdir.mk 19 | -include subdir.mk 20 | -include objects.mk 21 | 22 | ifneq ($(MAKECMDGOALS),clean) 23 | ifneq ($(strip $(C_DEPS)),) 24 | -include $(C_DEPS) 25 | endif 26 | endif 27 | 28 | -include ../makefile.defs 29 | 30 | # Add inputs and outputs from these tool invocations to the build variables 31 | 32 | # All Target 33 | all: OpenV2G.exe 34 | 35 | # Tool invocations 36 | OpenV2G.exe: $(OBJS) $(USER_OBJS) 37 | @echo 'Building target: $@' 38 | @echo 'Invoking: MinGW C Linker' 39 | gcc -o "OpenV2G.exe" $(OBJS) $(USER_OBJS) $(LIBS) 40 | @echo 'Finished building target: $@' 41 | @echo ' ' 42 | 43 | # Other Targets 44 | clean: 45 | -$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) OpenV2G.exe 46 | -@echo ' ' 47 | 48 | .PHONY: all clean dependents 49 | .SECONDARY: 50 | 51 | -include ../makefile.targets 52 | -------------------------------------------------------------------------------- /Release/objects.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | USER_OBJS := 6 | 7 | LIBS := 8 | 9 | -------------------------------------------------------------------------------- /Release/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | OBJ_SRCS := 6 | ASM_SRCS := 7 | C_SRCS := 8 | S_UPPER_SRCS := 9 | O_SRCS := 10 | EXECUTABLES := 11 | OBJS := 12 | C_DEPS := 13 | 14 | # Every subdirectory with source files must be described here 15 | SUBDIRS := \ 16 | src/xmldsig \ 17 | src/transport \ 18 | src/test \ 19 | src/iso2 \ 20 | src/iso1 \ 21 | src/din \ 22 | src/codec \ 23 | src/appHandshake \ 24 | 25 | -------------------------------------------------------------------------------- /Release/src/appHandshake/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/appHandshake/appHandEXIDatatypes.c \ 8 | ../src/appHandshake/appHandEXIDatatypesDecoder.c \ 9 | ../src/appHandshake/appHandEXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/appHandshake/appHandEXIDatatypes.o \ 13 | ./src/appHandshake/appHandEXIDatatypesDecoder.o \ 14 | ./src/appHandshake/appHandEXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/appHandshake/appHandEXIDatatypes.d \ 18 | ./src/appHandshake/appHandEXIDatatypesDecoder.d \ 19 | ./src/appHandshake/appHandEXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/appHandshake/%.o: ../src/appHandshake/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Release/src/codec/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/codec/BitInputStream.c \ 8 | ../src/codec/BitOutputStream.c \ 9 | ../src/codec/ByteStream.c \ 10 | ../src/codec/DecoderChannel.c \ 11 | ../src/codec/EXIHeaderDecoder.c \ 12 | ../src/codec/EXIHeaderEncoder.c \ 13 | ../src/codec/EncoderChannel.c \ 14 | ../src/codec/MethodsBag.c 15 | 16 | OBJS += \ 17 | ./src/codec/BitInputStream.o \ 18 | ./src/codec/BitOutputStream.o \ 19 | ./src/codec/ByteStream.o \ 20 | ./src/codec/DecoderChannel.o \ 21 | ./src/codec/EXIHeaderDecoder.o \ 22 | ./src/codec/EXIHeaderEncoder.o \ 23 | ./src/codec/EncoderChannel.o \ 24 | ./src/codec/MethodsBag.o 25 | 26 | C_DEPS += \ 27 | ./src/codec/BitInputStream.d \ 28 | ./src/codec/BitOutputStream.d \ 29 | ./src/codec/ByteStream.d \ 30 | ./src/codec/DecoderChannel.d \ 31 | ./src/codec/EXIHeaderDecoder.d \ 32 | ./src/codec/EXIHeaderEncoder.d \ 33 | ./src/codec/EncoderChannel.d \ 34 | ./src/codec/MethodsBag.d 35 | 36 | 37 | # Each subdirectory must supply rules for building sources it contributes 38 | src/codec/%.o: ../src/codec/%.c 39 | @echo 'Building file: $<' 40 | @echo 'Invoking: GCC C Compiler' 41 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 42 | @echo 'Finished building: $<' 43 | @echo ' ' 44 | 45 | 46 | -------------------------------------------------------------------------------- /Release/src/din/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/din/dinEXIDatatypes.c \ 8 | ../src/din/dinEXIDatatypesDecoder.c \ 9 | ../src/din/dinEXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/din/dinEXIDatatypes.o \ 13 | ./src/din/dinEXIDatatypesDecoder.o \ 14 | ./src/din/dinEXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/din/dinEXIDatatypes.d \ 18 | ./src/din/dinEXIDatatypesDecoder.d \ 19 | ./src/din/dinEXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/din/%.o: ../src/din/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Release/src/iso1/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/iso1/iso1EXIDatatypes.c \ 8 | ../src/iso1/iso1EXIDatatypesDecoder.c \ 9 | ../src/iso1/iso1EXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/iso1/iso1EXIDatatypes.o \ 13 | ./src/iso1/iso1EXIDatatypesDecoder.o \ 14 | ./src/iso1/iso1EXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/iso1/iso1EXIDatatypes.d \ 18 | ./src/iso1/iso1EXIDatatypesDecoder.d \ 19 | ./src/iso1/iso1EXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/iso1/%.o: ../src/iso1/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Release/src/iso2/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/iso2/iso2EXIDatatypes.c \ 8 | ../src/iso2/iso2EXIDatatypesDecoder.c \ 9 | ../src/iso2/iso2EXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/iso2/iso2EXIDatatypes.o \ 13 | ./src/iso2/iso2EXIDatatypesDecoder.o \ 14 | ./src/iso2/iso2EXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/iso2/iso2EXIDatatypes.d \ 18 | ./src/iso2/iso2EXIDatatypesDecoder.d \ 19 | ./src/iso2/iso2EXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/iso2/%.o: ../src/iso2/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Release/src/test/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/test/main.c \ 8 | ../src/test/main_databinder.c \ 9 | ../src/test/main_example.c 10 | 11 | OBJS += \ 12 | ./src/test/main.o \ 13 | ./src/test/main_databinder.o \ 14 | ./src/test/main_example.o 15 | 16 | C_DEPS += \ 17 | ./src/test/main.d \ 18 | ./src/test/main_databinder.d \ 19 | ./src/test/main_example.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/test/%.o: ../src/test/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /Release/src/transport/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/transport/v2gtp.c 8 | 9 | OBJS += \ 10 | ./src/transport/v2gtp.o 11 | 12 | C_DEPS += \ 13 | ./src/transport/v2gtp.d 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | src/transport/%.o: ../src/transport/%.c 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: GCC C Compiler' 20 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | -------------------------------------------------------------------------------- /Release/src/xmldsig/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | C_SRCS += \ 7 | ../src/xmldsig/xmldsigEXIDatatypes.c \ 8 | ../src/xmldsig/xmldsigEXIDatatypesDecoder.c \ 9 | ../src/xmldsig/xmldsigEXIDatatypesEncoder.c 10 | 11 | OBJS += \ 12 | ./src/xmldsig/xmldsigEXIDatatypes.o \ 13 | ./src/xmldsig/xmldsigEXIDatatypesDecoder.o \ 14 | ./src/xmldsig/xmldsigEXIDatatypesEncoder.o 15 | 16 | C_DEPS += \ 17 | ./src/xmldsig/xmldsigEXIDatatypes.d \ 18 | ./src/xmldsig/xmldsigEXIDatatypesDecoder.d \ 19 | ./src/xmldsig/xmldsigEXIDatatypesEncoder.d 20 | 21 | 22 | # Each subdirectory must supply rules for building sources it contributes 23 | src/xmldsig/%.o: ../src/xmldsig/%.c 24 | @echo 'Building file: $<' 25 | @echo 'Invoking: GCC C Compiler' 26 | gcc -I"../src/codec" -I"../src/din" -I"../src/iso1" -I"../src/iso2" -I"../src/xmldsig" -I"../src/appHandshake" -I"../src/transport" -I"../src/test" -Os -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" 27 | @echo 'Finished building: $<' 28 | @echo ' ' 29 | 30 | 31 | -------------------------------------------------------------------------------- /data/sessionSetupReq.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 0000000000000000 9 | 10 | 11 | 12 | 01 13 | 14 | 15 | -------------------------------------------------------------------------------- /data/sessionSetupReq.xml.exi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ecognize/openv2g/d9431580c05988fa34291699303485705d2ca4fd/data/sessionSetupReq.xml.exi -------------------------------------------------------------------------------- /data/sessionSetupRes.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 0000000000000010 9 | 10 | 11 | 12 | OK 13 | 1234567 14 | 123456789 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /data/sessionSetupRes.xml.exi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ecognize/openv2g/d9431580c05988fa34291699303485705d2ca4fd/data/sessionSetupRes.xml.exi -------------------------------------------------------------------------------- /src/appHandshake/appHandEXIDatatypes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_AppProtocol.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include 33 | 34 | #include "appHandEXIDatatypes.h" 35 | #include "EXITypes.h" 36 | 37 | 38 | #ifndef EXI_appHand_DATATYPES_C 39 | #define EXI_appHand_DATATYPES_C 40 | 41 | 42 | 43 | void init_appHandEXIDocument(struct appHandEXIDocument* exiDoc) { 44 | exiDoc->supportedAppProtocolReq_isUsed = 0u; 45 | exiDoc->supportedAppProtocolRes_isUsed = 0u; 46 | } 47 | 48 | void init_appHandAppProtocolType(struct appHandAppProtocolType* appHandAppProtocolType) { 49 | } 50 | 51 | void init_appHandAnonType_supportedAppProtocolReq(struct appHandAnonType_supportedAppProtocolReq* appHandAnonType_supportedAppProtocolReq) { 52 | appHandAnonType_supportedAppProtocolReq->AppProtocol.arrayLen = 0u; 53 | } 54 | 55 | void init_appHandAnonType_supportedAppProtocolRes(struct appHandAnonType_supportedAppProtocolRes* appHandAnonType_supportedAppProtocolRes) { 56 | appHandAnonType_supportedAppProtocolRes->SchemaID_isUsed = 0u; 57 | } 58 | 59 | 60 | 61 | 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /src/appHandshake/appHandEXIDatatypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_AppProtocol.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypes.h 34 | * \brief Datatype definitions and structs for given XML Schema definitions and initialization methods 35 | * 36 | */ 37 | 38 | #ifndef EXI_appHand_DATATYPES_H 39 | #define EXI_appHand_DATATYPES_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | #include 47 | 48 | #include "EXITypes.h" 49 | 50 | 51 | /* Datatype definitions and structs for given XML Schema definitions */ 52 | 53 | #define UNION_YES 1 54 | #define UNION_NO 2 55 | #define SAVE_MEMORY_WITH_UNNAMED_UNION UNION_YES 56 | 57 | /* Complex type name='urn:iso:15118:2:2010:AppProtocol,AppProtocolType', base type name='anyType', content type='ELEMENT', isAbstract='false', hasTypeId='false', final='0', block='0', particle='(ProtocolNamespace,VersionNumberMajor,VersionNumberMinor,SchemaID,Priority)', derivedBy='RESTRICTION'. */ 58 | #define appHandAppProtocolType_ProtocolNamespace_CHARACTERS_SIZE 100 /* XML schema facet maxLength for urn:iso:15118:2:2010:AppProtocol,protocolNamespaceType is 100 */ 59 | struct appHandAppProtocolType { 60 | /* element: ProtocolNamespace, urn:iso:15118:2:2010:AppProtocol,protocolNamespaceType */ 61 | struct { 62 | exi_string_character_t characters[appHandAppProtocolType_ProtocolNamespace_CHARACTERS_SIZE]; 63 | uint16_t charactersLen; 64 | } ProtocolNamespace ; 65 | /* element: VersionNumberMajor, http://www.w3.org/2001/XMLSchema,unsignedInt */ 66 | uint32_t VersionNumberMajor ; 67 | /* element: VersionNumberMinor, http://www.w3.org/2001/XMLSchema,unsignedInt */ 68 | uint32_t VersionNumberMinor ; 69 | /* element: SchemaID, urn:iso:15118:2:2010:AppProtocol,idType */ 70 | uint8_t SchemaID ; 71 | /* element: Priority, urn:iso:15118:2:2010:AppProtocol,priorityType */ 72 | uint8_t Priority ; 73 | }; 74 | 75 | typedef enum { 76 | appHandresponseCodeType_OK_SuccessfulNegotiation = 0, 77 | appHandresponseCodeType_OK_SuccessfulNegotiationWithMinorDeviation = 1, 78 | appHandresponseCodeType_Failed_NoNegotiation = 2 79 | } appHandresponseCodeType; 80 | 81 | /* Complex type name='urn:iso:15118:2:2010:AppProtocol,#AnonType_supportedAppProtocolRes', base type name='anyType', content type='ELEMENT', isAbstract='false', hasTypeId='false', final='0', block='0', particle='(ResponseCode,SchemaID{0-1})', derivedBy='RESTRICTION'. */ 82 | struct appHandAnonType_supportedAppProtocolRes { 83 | /* element: ResponseCode, urn:iso:15118:2:2010:AppProtocol,responseCodeType */ 84 | appHandresponseCodeType ResponseCode ; 85 | /* element: SchemaID, urn:iso:15118:2:2010:AppProtocol,idType */ 86 | uint8_t SchemaID ; 87 | unsigned int SchemaID_isUsed:1; 88 | }; 89 | 90 | /* Complex type name='urn:iso:15118:2:2010:AppProtocol,#AnonType_supportedAppProtocolReq', base type name='anyType', content type='ELEMENT', isAbstract='false', hasTypeId='false', final='0', block='0', particle='(AppProtocol{1-20})', derivedBy='RESTRICTION'. */ 91 | #define appHandAnonType_supportedAppProtocolReq_AppProtocol_ARRAY_SIZE 5 92 | struct appHandAnonType_supportedAppProtocolReq { 93 | /* element: AppProtocol, Complex type name='urn:iso:15118:2:2010:AppProtocol,AppProtocolType', base type name='anyType', content type='ELEMENT', isAbstract='false', hasTypeId='false', final='0', block='0', particle='(ProtocolNamespace,VersionNumberMajor,VersionNumberMinor,SchemaID,Priority)', derivedBy='RESTRICTION'. */ 94 | struct { 95 | struct appHandAppProtocolType array[appHandAnonType_supportedAppProtocolReq_AppProtocol_ARRAY_SIZE]; 96 | uint16_t arrayLen; 97 | } AppProtocol; 98 | }; 99 | 100 | 101 | 102 | 103 | 104 | /* Possible root elements of EXI Document */ 105 | struct appHandEXIDocument { 106 | #if SAVE_MEMORY_WITH_UNNAMED_UNION == UNION_YES 107 | union { 108 | #endif /* SAVE_MEMORY_WITH_UNNAMED_UNION == UNION_YES */ 109 | struct appHandAnonType_supportedAppProtocolReq supportedAppProtocolReq ; 110 | struct appHandAnonType_supportedAppProtocolRes supportedAppProtocolRes ; 111 | #if SAVE_MEMORY_WITH_UNNAMED_UNION == UNION_YES 112 | }; 113 | #endif /* SAVE_MEMORY_WITH_UNNAMED_UNION == UNION_YES */ 114 | unsigned int supportedAppProtocolReq_isUsed:1; 115 | unsigned int supportedAppProtocolRes_isUsed:1; 116 | 117 | 118 | int _warning_; 119 | }; 120 | 121 | /* Initialization methods for structs */ 122 | 123 | void init_appHandEXIDocument(struct appHandEXIDocument* exiDoc); 124 | void init_appHandAppProtocolType(struct appHandAppProtocolType* appHandAppProtocolType); 125 | void init_appHandAnonType_supportedAppProtocolReq(struct appHandAnonType_supportedAppProtocolReq* appHandAnonType_supportedAppProtocolReq); 126 | void init_appHandAnonType_supportedAppProtocolRes(struct appHandAnonType_supportedAppProtocolRes* appHandAnonType_supportedAppProtocolRes); 127 | 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /src/appHandshake/appHandEXIDatatypesDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_AppProtocol.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesDecoder.h 34 | * \brief Decoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_appHand_DATATYPES_DECODER_H 39 | #define EXI_appHand_DATATYPES_DECODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | #include 47 | 48 | #include "EXITypes.h" 49 | #include "appHandEXIDatatypes.h" 50 | 51 | int decode_appHandExiDocument(bitstream_t* stream, struct appHandEXIDocument* exiDoc); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/appHandshake/appHandEXIDatatypesEncoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_AppProtocol.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesEncoder.h 34 | * \brief Encoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_appHand_DATATYPES_ENCODER_H 39 | #define EXI_appHand_DATATYPES_ENCODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include 46 | 47 | #include "EXITypes.h" 48 | #include "appHandEXIDatatypes.h" 49 | 50 | 51 | int encode_appHandExiDocument(bitstream_t* stream, struct appHandEXIDocument* exiDoc); 52 | 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/codec/BitInputStream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include "BitInputStream.h" 33 | #include "EXIConfig.h" 34 | #include "EXITypes.h" 35 | #include "ErrorCodes.h" 36 | 37 | #ifndef BIT_INPUT_STREAM_C 38 | #define BIT_INPUT_STREAM_C 39 | 40 | /* internal method to (re)fill buffer */ 41 | static int readBuffer(bitstream_t* stream) 42 | { 43 | int errn = 0; 44 | if(stream->capacity==0) 45 | { 46 | #if EXI_STREAM == BYTE_ARRAY 47 | if ( (*stream->pos) < stream->size ) { 48 | stream->buffer = stream->data[(*stream->pos)++]; 49 | stream->capacity = BITS_IN_BYTE; 50 | } else { 51 | errn = EXI_ERROR_INPUT_STREAM_EOF; 52 | } 53 | #endif 54 | #if EXI_STREAM == FILE_STREAM 55 | stream->buffer = (uint8_t)(getc(stream->file)); 56 | /* EOF cannot be used, 0xFF valid value */ 57 | if ( feof(stream->file) || ferror(stream->file) ) { 58 | errn = EXI_ERROR_INPUT_STREAM_EOF; 59 | } else { 60 | stream->capacity = BITS_IN_BYTE; 61 | } 62 | #endif 63 | } 64 | return errn; 65 | } 66 | 67 | int readBits(bitstream_t* stream, size_t num_bits, uint32_t* b) 68 | { 69 | int errn = readBuffer(stream); 70 | if (errn == 0) { 71 | /* read the bits in one step */ 72 | if(num_bits <= stream->capacity) { 73 | stream->capacity = (uint8_t)(stream->capacity - num_bits); 74 | *b = (uint32_t)((stream->buffer >> stream->capacity) & (0xff >> (BITS_IN_BYTE - num_bits))); 75 | } else { 76 | /* read bits as much as possible */ 77 | *b = (uint32_t)(stream->buffer & (0xff >> (BITS_IN_BYTE - stream->capacity))); 78 | num_bits = (num_bits - stream->capacity); 79 | stream->capacity = 0; 80 | 81 | /* read whole bytes */ 82 | while(errn == 0 && num_bits >= 8) 83 | { 84 | errn = readBuffer(stream); 85 | *b = ((*b) << BITS_IN_BYTE) | stream->buffer; 86 | num_bits = (num_bits - BITS_IN_BYTE); 87 | stream->capacity = 0; 88 | } 89 | 90 | /* read the spare bits in the buffer */ 91 | if(errn == 0 && num_bits > 0) 92 | { 93 | errn = readBuffer(stream); 94 | if (errn == 0) { 95 | *b = ( (*b) << num_bits) | (uint8_t)(stream->buffer >> (BITS_IN_BYTE - num_bits)) ; 96 | stream->capacity = (uint8_t)(BITS_IN_BYTE - num_bits); 97 | } 98 | } 99 | } 100 | } 101 | 102 | return errn; 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/codec/BitInputStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file BitInputStream.h 34 | * \brief Bit Input Stream 35 | * 36 | * Read bits and bytes from an underlying input stream. 37 | * 38 | */ 39 | 40 | #ifndef BIT_INPUT_STREAM_H 41 | #define BIT_INPUT_STREAM_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #include "EXITypes.h" 48 | 49 | /** 50 | * \brief Read bits 51 | * 52 | * Read the next num_bits bits and returns result an integer. 53 | * 54 | * \param stream Input Stream 55 | * \param num_bits Number of bits 56 | * \param b Integer value (out) 57 | * \return Error-Code <> 0 58 | * 59 | */ 60 | int readBits(bitstream_t* stream, size_t num_bits, uint32_t* b); 61 | 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/codec/BitOutputStream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include "BitOutputStream.h" 33 | #include "EXIConfig.h" 34 | #include "EXITypes.h" 35 | #include "ErrorCodes.h" 36 | 37 | #ifndef BIT_OUTPUT_STREAM_C 38 | #define BIT_OUTPUT_STREAM_C 39 | 40 | int writeBits(bitstream_t* stream, size_t nbits, uint32_t val) { 41 | int errn = 0; 42 | /* is there enough space in the buffer */ 43 | if (nbits <= stream->capacity) { 44 | /* all bits fit into the current buffer */ 45 | stream->buffer = (uint8_t)(stream->buffer << (nbits)) | (uint8_t)(val & (uint32_t)(0xff >> (uint32_t)(BITS_IN_BYTE - nbits))); 46 | stream->capacity = (uint8_t)(stream->capacity - nbits); 47 | /* if the buffer is full write byte */ 48 | if (stream->capacity == 0) { 49 | #if EXI_STREAM == BYTE_ARRAY 50 | if ((*stream->pos) >= stream->size) { 51 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 52 | } else { 53 | stream->data[(*stream->pos)++] = stream->buffer; 54 | } 55 | #endif 56 | #if EXI_STREAM == FILE_STREAM 57 | if ( putc(stream->buffer, stream->file) == EOF ) { 58 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 59 | } 60 | #endif 61 | stream->capacity = BITS_IN_BYTE; 62 | stream->buffer = 0; 63 | } 64 | } else { 65 | /* the buffer is not enough 66 | * fill the buffer */ 67 | stream->buffer = (uint8_t)(stream->buffer << stream->capacity) | 68 | ( (uint8_t)(val >> (nbits - stream->capacity)) & (uint8_t)(0xff >> (BITS_IN_BYTE - stream->capacity)) ); 69 | 70 | nbits = (nbits - stream->capacity); 71 | #if EXI_STREAM == BYTE_ARRAY 72 | if ((*stream->pos) >= stream->size) { 73 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 74 | } else { 75 | stream->data[(*stream->pos)++] = stream->buffer; 76 | } 77 | #endif 78 | #if EXI_STREAM == FILE_STREAM 79 | if ( putc(stream->buffer, stream->file) == EOF ) { 80 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 81 | } 82 | #endif 83 | stream->buffer = 0; 84 | 85 | /* write whole bytes */ 86 | while (errn == 0 && nbits >= BITS_IN_BYTE) { 87 | nbits = (nbits - BITS_IN_BYTE); 88 | #if EXI_STREAM == BYTE_ARRAY 89 | if ((*stream->pos) >= stream->size) { 90 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 91 | } else { 92 | stream->data[(*stream->pos)++] = (uint8_t)(val >> (nbits)); 93 | } 94 | #endif 95 | #if EXI_STREAM == FILE_STREAM 96 | if ( putc((int)(val >> (nbits)), stream->file) == EOF ) { 97 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 98 | } 99 | #endif 100 | } 101 | 102 | /* spared bits are kept in the buffer */ 103 | stream->buffer = (uint8_t)val; /* Note: the high bits will be shifted out during further filling */ 104 | stream->capacity = (uint8_t)(BITS_IN_BYTE - (nbits)); 105 | } 106 | 107 | return errn; 108 | } 109 | 110 | /** 111 | * Flush output 112 | */ 113 | int flush(bitstream_t* stream) { 114 | int errn = 0; 115 | if (stream->capacity == BITS_IN_BYTE) { 116 | /* nothing to do, no bits in buffer */ 117 | } else { 118 | errn = writeBits(stream, stream->capacity, 0); 119 | } 120 | return errn; 121 | } 122 | 123 | #endif 124 | 125 | -------------------------------------------------------------------------------- /src/codec/BitOutputStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file BitOutputStream.h 34 | * \brief Bit Output Stream 35 | * 36 | * Write bits and bytes to an underlying output stream. 37 | * 38 | */ 39 | 40 | #ifndef BIT_OUTPUT_STREAM_H 41 | #define BIT_OUTPUT_STREAM_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #include 48 | 49 | #include "EXITypes.h" 50 | 51 | /** 52 | * \brief Write bits 53 | * 54 | * Write the n least significant bits of parameter b starting 55 | * with the most significant, i.e. from left to right. 56 | * 57 | * \param stream Output Stream 58 | * \param nbits Number of bits 59 | * \param bits value 60 | * \return Error-Code <> 0 61 | * 62 | */ 63 | int writeBits(bitstream_t* stream, size_t nbits, uint32_t bits); 64 | 65 | 66 | /** 67 | * \brief Flush output 68 | * 69 | * If there are some unwritten bits, pad them if necessary and 70 | * write them out. Note that this method does flush the 71 | * underlying stream. 72 | * 73 | * \param stream Output Stream 74 | * \return Error-Code <> 0 75 | * 76 | */ 77 | int flush(bitstream_t* stream); 78 | 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif 85 | 86 | -------------------------------------------------------------------------------- /src/codec/ByteStream.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ecognize/openv2g/d9431580c05988fa34291699303485705d2ca4fd/src/codec/ByteStream.c -------------------------------------------------------------------------------- /src/codec/ByteStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file ByteStream.h 34 | * \brief Byte Stream utilities 35 | * 36 | */ 37 | 38 | #ifndef BYTE_STREAM_H 39 | #define BYTE_STREAM_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "EXITypes.h" 46 | 47 | /** 48 | * \brief Write bytes to file 49 | * 50 | * \param data byte array 51 | * \param len length 52 | * \param filename File name 53 | * \return Error-Code <> 0 54 | * 55 | */ 56 | int writeBytesToFile(uint8_t* data, size_t len, const char * filename); 57 | 58 | 59 | /** 60 | * \brief Read bytes from file 61 | * 62 | * \param filename File name 63 | * \param data byte array 64 | * \param size byte array size 65 | * \param pos byte array position 66 | * \return Error-Code <> 0 67 | * 68 | */ 69 | int readBytesFromFile(const char * filename, uint8_t* data, size_t size, size_t* pos); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* BYTE_STREAM_H */ 76 | -------------------------------------------------------------------------------- /src/codec/DecoderChannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file DecoderChannel.h 34 | * \brief EXI Decoder Channel 35 | * 36 | */ 37 | 38 | #ifndef DECODER_CHANNEL_H 39 | #define DECODER_CHANNEL_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "EXIOptions.h" 46 | #include "EXITypes.h" 47 | 48 | /** 49 | * \brief Decode byte value 50 | * 51 | * \param stream Input Stream 52 | * \param b byte (out) 53 | * \return Error-Code <> 0 54 | * 55 | */ 56 | int decode(bitstream_t* stream, uint8_t* b); 57 | 58 | 59 | /** 60 | * \brief Decode boolean 61 | * 62 | * Decode a single boolean value. The value false is 63 | * represented by 0, and the value true is represented by 1. 64 | * 65 | * \param stream Input Stream 66 | * \param b boolean (out) 67 | * \return Error-Code <> 0 68 | * 69 | */ 70 | int decodeBoolean(bitstream_t* stream, int* b); 71 | 72 | 73 | /** 74 | * \brief Decode n-bit unsigned integer 75 | * 76 | * Decodes and returns an n-bit unsigned integer. 77 | * 78 | * \param stream Input Stream 79 | * \param nbits Number of bits 80 | * \param uint32 Value (out) 81 | * \return Error-Code <> 0 82 | * 83 | */ 84 | int decodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint32_t* uint32); 85 | 86 | 87 | /** 88 | * \brief Decode unsigned integer 89 | * 90 | * Decode an arbitrary precision non negative integer using 91 | * a sequence of octets. The most significant bit of the last 92 | * octet is set to zero to indicate sequence termination. 93 | * Only seven bits per octet are used to store the integer's value. 94 | * 95 | * \param stream Input Stream 96 | * \param iv Unsigned Integer Value (out) 97 | * \return Error-Code <> 0 98 | * 99 | */ 100 | int decodeUnsignedInteger(bitstream_t* stream, exi_integer_t* iv); 101 | 102 | 103 | /** 104 | * \brief Decode unsigned integer 105 | * 106 | * Decode an arbitrary precision non negative integer using 107 | * a sequence of octets. The most significant bit of the last 108 | * octet is set to zero to indicate sequence termination. 109 | * Only seven bits per octet are used to store the integer's value. 110 | * 111 | * \param stream Input Stream 112 | * \param uint16 Unsigned Integer Value 16 bits (out) 113 | * \return Error-Code <> 0 114 | * 115 | */ 116 | int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16); 117 | 118 | 119 | /** 120 | * \brief Decode unsigned integer 121 | * 122 | * Decode an arbitrary precision non negative integer using 123 | * a sequence of octets. The most significant bit of the last 124 | * octet is set to zero to indicate sequence termination. 125 | * Only seven bits per octet are used to store the integer's value. 126 | * 127 | * \param stream Input Stream 128 | * \param uint32 Unsigned Integer Value 32 bits (out) 129 | * \return Error-Code <> 0 130 | * 131 | */ 132 | int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32); 133 | 134 | 135 | /** 136 | * \brief Decode unsigned integer 137 | * 138 | * Decode an arbitrary precision non negative integer using 139 | * a sequence of octets. The most significant bit of the last 140 | * octet is set to zero to indicate sequence termination. 141 | * Only seven bits per octet are used to store the integer's value. 142 | * 143 | * \param stream Input Stream 144 | * \param sizeT Unsigned Integer Value (out) 145 | * \return Error-Code <> 0 146 | * 147 | */ 148 | int decodeUnsignedIntegerSizeT(bitstream_t* stream, size_t* sizeT); 149 | 150 | 151 | /** 152 | * \brief Decode unsigned integer 153 | * 154 | * Decode an arbitrary precision non negative integer using 155 | * a sequence of octets. The most significant bit of the last 156 | * octet is set to zero to indicate sequence termination. 157 | * Only seven bits per octet are used to store the integer's value. 158 | * 159 | * \param stream Input Stream 160 | * \param uint64 Unsigned Integer Value 64 bits (out) 161 | * \return Error-Code <> 0 162 | * 163 | */ 164 | int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64); 165 | 166 | /** 167 | * \brief Decode unsigned integer 168 | * 169 | * Decode an arbitrary precision non negative integer using 170 | * a sequence of octets. The most significant bit of the last 171 | * octet is set to zero to indicate sequence termination. 172 | * Only seven bits per octet are used to store the integer's value. 173 | * 174 | * \param stream Input Stream 175 | * \param size size array 176 | * \param data data array 177 | * \param len length array 178 | * \return Error-Code <> 0 179 | * 180 | */ 181 | int decodeUnsignedIntegerBig(bitstream_t* stream, size_t size, uint8_t* data, size_t* len); 182 | 183 | 184 | /** 185 | * \brief Decode integer 186 | * 187 | * Decode an arbitrary precision integer using a sign bit 188 | * followed by a sequence of octets. The most significant bit 189 | * of the last octet is set to zero to indicate sequence termination. 190 | * Only seven bits per octet are used to store the integer's value. 191 | * 192 | * \param stream Input Stream 193 | * \param iv Integer Value 64 bits (out) 194 | * \return Error-Code <> 0 195 | * 196 | */ 197 | int decodeInteger(bitstream_t* stream, exi_integer_t* iv); 198 | 199 | 200 | /** 201 | * \brief Decode integer 202 | * 203 | * Decode an arbitrary precision integer using a sign bit 204 | * followed by a sequence of octets. The most significant bit 205 | * of the last octet is set to zero to indicate sequence termination. 206 | * Only seven bits per octet are used to store the integer's value. 207 | * 208 | * \param stream Input Stream 209 | * \param int16 Integer Value 16 bits (out) 210 | * \return Error-Code <> 0 211 | * 212 | */ 213 | int decodeInteger16(bitstream_t* stream, int16_t* int16); 214 | 215 | 216 | /** 217 | * \brief Decode integer 218 | * 219 | * Decode an arbitrary precision integer using a sign bit 220 | * followed by a sequence of octets. The most significant bit 221 | * of the last octet is set to zero to indicate sequence termination. 222 | * Only seven bits per octet are used to store the integer's value. 223 | * 224 | * \param stream Input Stream 225 | * \param int32 Integer Value 32 bits (out) 226 | * \return Error-Code <> 0 227 | * 228 | */ 229 | int decodeInteger32(bitstream_t* stream, int32_t* int32); 230 | 231 | 232 | /** 233 | * \brief Decode integer 234 | * 235 | * Decode an arbitrary precision integer using a sign bit 236 | * followed by a sequence of octets. The most significant bit 237 | * of the last octet is set to zero to indicate sequence termination. 238 | * Only seven bits per octet are used to store the integer's value. 239 | * 240 | * \param stream Input Stream 241 | * \param int64 Integer Value 64 bits (out) 242 | * \return Error-Code <> 0 243 | * 244 | */ 245 | int decodeInteger64(bitstream_t* stream, int64_t* int64); 246 | 247 | /** 248 | * \brief Decode integer 249 | * 250 | * Decode an arbitrary precision integer using a sign bit 251 | * followed by a sequence of octets. The most significant bit 252 | * of the last octet is set to zero to indicate sequence termination. 253 | * Only seven bits per octet are used to store the integer's value. 254 | * 255 | * \param stream Input Stream 256 | * \param negative negative integer 257 | * \param size size array 258 | * \param data data array 259 | * \param len length array 260 | * \return Error-Code <> 0 261 | * 262 | */ 263 | int decodeIntegerBig(bitstream_t* stream, int* negative, size_t size, uint8_t* data, size_t* len); 264 | 265 | /** 266 | * \brief Decode float 267 | * 268 | * Decode a Float datatype as two consecutive Integers. The 269 | * first Integer represents the mantissa of the floating point 270 | * number and the second Integer represents the base-10 exponent 271 | * of the floating point number. 272 | * 273 | * \param stream Input Stream 274 | * \param f Float Value (out) 275 | * \return Error-Code <> 0 276 | * 277 | */ 278 | int decodeFloat(bitstream_t* stream, exi_float_me_t* f); 279 | 280 | 281 | /** 282 | * \brief Decode decimal 283 | * 284 | * Decode a decimal represented as a Boolean sign followed by two 285 | * Unsigned Integers. A sign value of zero (0) is used to represent 286 | * positive Decimal values and a sign value of one (1) is used to 287 | * represent negative Decimal values The first Integer represents 288 | * the integral portion of the Decimal value. The second positive 289 | * integer represents the fractional portion of the decimal with 290 | * the digits in reverse order to preserve leading zeros. 291 | * 292 | * \param stream Input Stream 293 | * \param d Decimal Value (out) 294 | * \return Error-Code <> 0 295 | * 296 | */ 297 | int decodeDecimal(bitstream_t* stream, exi_decimal_t* d); 298 | 299 | 300 | /** 301 | * \brief Decode String (no length prefix) 302 | * 303 | * Decode a sequence of characters for a given length. 304 | * 305 | * \param stream Input Stream 306 | * \param len Characters length 307 | * \param s String Value (out) 308 | * \return Error-Code <> 0 309 | * 310 | */ 311 | int decodeStringOnly(bitstream_t* stream, size_t len, exi_string_t* s); 312 | 313 | 314 | /** 315 | * \brief Decode String 316 | * 317 | * Decode a length prefixed sequence of characters. 318 | * 319 | * \param stream Input Stream 320 | * \param s String Value (out) 321 | * \return Error-Code <> 0 322 | * 323 | */ 324 | int decodeString(bitstream_t* stream, exi_string_t* s); 325 | 326 | 327 | 328 | /** 329 | * \brief Decode String value 330 | * 331 | * Decode a length prefixed sequence of characters in the sense of string tables. 332 | * length == 0: local value partition hit. 333 | * length == 1: global value partition hit. 334 | * length > 1: string literal is encoded as a String with the length incremented by two 335 | * 336 | * \param stream Input Stream 337 | * \param stringTable String Table 338 | * \param qnameID Qualified Name ID 339 | * \param namespaceUriID Qualified Namespace ID 340 | * \param localNameID Qualified LocalName ID 341 | * \param s String Value (out) 342 | * \return Error-Code <> 0 343 | * 344 | */ 345 | int decodeStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, size_t namespaceUriID, size_t localNameID, exi_string_value_t* s); 346 | 347 | 348 | /** 349 | * \brief Decode Restricted characters set string value 350 | * 351 | * \param stream Input Stream 352 | * \param stringTable StringTable 353 | * \param namespaceUriID qualified namespace ID 354 | * \param localNameID qualified localName ID 355 | * \param rcs Restricted character set 356 | * \param s String Value (out) 357 | * \return Error-Code <> 0 358 | * 359 | */ 360 | int decodeRCSStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, size_t namespaceUriID, size_t localNameID, exi_rcs_t* rcs, exi_string_value_t* s); 361 | 362 | 363 | /** 364 | * \brief Decode characters 365 | * 366 | * Decode a sequence of characters according to a given length. 367 | * 368 | * \param stream Input Stream 369 | * \param len Length 370 | * \param chars Characters (out) 371 | * \param charsSize Size of possible characters 372 | * \return Error-Code <> 0 373 | * 374 | */ 375 | int decodeCharacters(bitstream_t* stream, size_t len, exi_string_character_t* chars, size_t charsSize); 376 | 377 | 378 | /** 379 | * \brief Decode restricted character set characters 380 | * 381 | * Decode a sequence of characters according to a given length and rcs code-length, size and set. 382 | * 383 | * \param stream Input Stream 384 | * \param len Length 385 | * \param chars Characters (out) 386 | * \param charsSize Size of possible characters 387 | * \param rcsCodeLength RCS code-length 388 | * \param rcsCodeLength RCS size 389 | * \param rcsCodeLength RCS set 390 | * \return Error-Code <> 0 391 | * 392 | */ 393 | int decodeRCSCharacters(bitstream_t* stream, size_t len, exi_string_character_t* chars, size_t charsSize, size_t rcsCodeLength, size_t rcsSize, const exi_string_character_t rcsSet[]); 394 | 395 | 396 | 397 | /** 398 | * \brief Decode Binary 399 | * 400 | * Decode a binary value as a length-prefixed sequence of octets. 401 | * 402 | * \param stream Input Stream 403 | * \param bytes Bytes (out) 404 | * \return Error-Code <> 0 405 | * 406 | */ 407 | int decodeBinary(bitstream_t* stream, exi_bytes_t* bytes); 408 | 409 | /** 410 | * \brief Decode Binary data 411 | * 412 | * Decode a sequence of octets. 413 | * 414 | * \param stream Input Stream 415 | * \param len Length 416 | * \param data Bytes (out) 417 | * \return Error-Code <> 0 418 | * 419 | */ 420 | int decodeBytes(bitstream_t* stream, size_t len, uint8_t* data); 421 | 422 | /** 423 | * \brief Decode DateTime 424 | * 425 | * Decode Date-Time as sequence of values representing the 426 | * individual components of the Date-Time. 427 | * 428 | * \param stream Input Stream 429 | * \param type Datetime type 430 | * \param datetime Datetime (out) 431 | * \return Error-Code <> 0 432 | * 433 | */ 434 | int decodeDateTime(bitstream_t* stream, exi_datetime_type_t type, exi_datetime_t* datetime); 435 | 436 | 437 | #ifdef __cplusplus 438 | } 439 | #endif 440 | 441 | #endif 442 | -------------------------------------------------------------------------------- /src/codec/EXIConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-23 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIConfig.h 34 | * \brief EXI Configurations for the EXI Codec 35 | * 36 | */ 37 | 38 | #ifndef EXI_CONFIG_H 39 | #define EXI_CONFIG_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /** EXI stream - Option Byte Array */ 47 | #define BYTE_ARRAY 1 48 | /** EXI stream - Option File */ 49 | #define FILE_STREAM 2 50 | /** \brief EXI stream 51 | * 52 | * Byte array or file 53 | * */ 54 | #define EXI_STREAM BYTE_ARRAY 55 | 56 | 57 | 58 | 59 | 60 | /** Memory allocation - static */ 61 | #define STATIC_ALLOCATION 1 62 | /** Memory allocation - dynamic */ 63 | #define DYNAMIC_ALLOCATION 2 64 | /** */ 65 | /** \brief Memory allocation mode 66 | * 67 | * static or dynamic memory allocation 68 | * */ 69 | #define MEMORY_ALLOCATION STATIC_ALLOCATION 70 | 71 | 72 | 73 | /** String representation ASCII */ 74 | #define STRING_REPRESENTATION_ASCII 1 75 | /** String representation Universal Character Set (UCS) */ 76 | #define STRING_REPRESENTATION_UCS 2 77 | /** */ 78 | /** \brief String representation mode 79 | * 80 | * ASCII or UCS 81 | * */ 82 | #define STRING_REPRESENTATION STRING_REPRESENTATION_UCS 83 | 84 | 85 | /* in the case of ASCII an extra char (null terminator) for printf and other functions is useful */ 86 | #if STRING_REPRESENTATION == STRING_REPRESENTATION_ASCII 87 | #define EXTRA_CHAR 1 88 | #endif /* STRING_REPRESENTATION_ASCII */ 89 | #if STRING_REPRESENTATION == STRING_REPRESENTATION_UCS 90 | #define EXTRA_CHAR 0 91 | #endif /* STRING_REPRESENTATION_UCS */ 92 | 93 | 94 | 95 | 96 | 97 | /** Maximum number of cascading elements, XML tree depth */ 98 | #define EXI_ELEMENT_STACK_SIZE 24 99 | 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* EXI_CONFIG_H */ 106 | 107 | -------------------------------------------------------------------------------- /src/codec/EXIHeaderDecoder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include "EXIHeaderDecoder.h" 33 | #include "BitInputStream.h" 34 | #include "DecoderChannel.h" 35 | #include "ErrorCodes.h" 36 | 37 | #ifndef EXI_HEADER_DECODER_C 38 | #define EXI_HEADER_DECODER_C 39 | 40 | int readEXIHeader(bitstream_t* stream) { 41 | int errn; 42 | uint32_t header = 0; 43 | 44 | /* init stream */ 45 | stream->buffer = 0; 46 | stream->capacity = 0; 47 | 48 | errn = readBits(stream, 8, &header); 49 | if (errn == 0) { 50 | if(header == '$') { 51 | /* we do not support "EXI Cookie" */ 52 | errn = EXI_UNSUPPORTED_HEADER_COOKIE; 53 | } else if ( header & 0x20 ) { 54 | /* we do not support "Presence Bit for EXI Options" */ 55 | errn = EXI_UNSUPPORTED_HEADER_OPTIONS; 56 | } else { 57 | /* Yes, a *simple* header */ 58 | errn = 0; 59 | } 60 | } 61 | 62 | return errn; 63 | } 64 | 65 | 66 | #endif 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/codec/EXIHeaderDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIHeaderDecoder.h 34 | * \brief EXI Header Decoder 35 | * 36 | */ 37 | 38 | #ifndef EXI_HEADER_DECODER_H 39 | #define EXI_HEADER_DECODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "EXITypes.h" 46 | 47 | /** 48 | * \brief Reads EXI header 49 | * 50 | * \param stream Input Stream 51 | * \return Error-Code <> 0 52 | * 53 | */ 54 | int readEXIHeader(bitstream_t* stream); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/codec/EXIHeaderEncoder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include "EXIHeaderEncoder.h" 33 | #include "BitOutputStream.h" 34 | #include "EncoderChannel.h" 35 | 36 | #ifndef EXI_HEADER_ENCODER_C 37 | #define EXI_HEADER_ENCODER_C 38 | 39 | int writeEXIHeader(bitstream_t* stream) { 40 | /* init stream */ 41 | stream->buffer = 0; 42 | stream->capacity = 8; 43 | 44 | return writeBits(stream, 8, 128); 45 | } 46 | 47 | 48 | #endif 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/codec/EXIHeaderEncoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIHeaderEncoder.h 34 | * \brief EXI Header Encoder 35 | * 36 | */ 37 | 38 | #ifndef EXI_HEADER_ENCODER_H 39 | #define EXI_HEADER_ENCODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "EXITypes.h" 46 | 47 | 48 | /** 49 | * \brief Writes EXI header 50 | * 51 | * \param stream Output Stream 52 | * \return Error-Code <> 0 53 | * 54 | */ 55 | int writeEXIHeader(bitstream_t* stream); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/codec/EXIOptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIOptions.h 34 | * \brief EXI Options for the EXI Codec 35 | * 36 | */ 37 | 38 | #ifndef EXI_OPTIONS_H 39 | #define EXI_OPTIONS_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /** EXI alignment - Option bit-packed */ 47 | #define BIT_PACKED 1 48 | /** EXI alignment - Option byte-packed */ 49 | #define BYTE_ALIGNMENT 2 50 | /** EXI alignment */ 51 | /** 52 | * \brief EXI Option 'alignment' 53 | * 54 | * The alignment option is used to control the alignment of event codes and content items. 55 | * Default Value: bit-packed 56 | */ 57 | #define EXI_OPTION_ALIGNMENT BIT_PACKED 58 | 59 | 60 | 61 | /** 62 | * \brief EXI Option 'strict' 63 | * 64 | * Strict interpretation of schemas is used to achieve better compactness. 65 | * Default Value: false 66 | */ 67 | #define EXI_OPTION_STRICT 0 68 | 69 | 70 | /** 71 | * \brief EXI Option 'valueMaxLength' 72 | * 73 | * Specifies the maximum string length of value content items to be 74 | * considered for addition to the string table. 75 | * Default Value: unbounded (-1) 76 | */ 77 | #define EXI_OPTION_VALUE_MAX_LENGTH -1 78 | 79 | 80 | /** 81 | * \brief EXI Option 'valuePartitionCapacity' 82 | * 83 | * Specifies the total capacity of value partitions in a string table. 84 | * Default Value: unbounded (-1) 85 | */ 86 | #define EXI_OPTION_VALUE_PARTITION_CAPACITY 0 87 | 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif /* EXI_OPTIONS_H */ 94 | -------------------------------------------------------------------------------- /src/codec/EXITypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXITypes.h 34 | * \brief Basic type definitions and structs 35 | * 36 | */ 37 | 38 | #ifndef EXI_TYPES_H 39 | #define EXI_TYPES_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include 46 | #include 47 | #include "EXIConfig.h" 48 | #if EXI_STREAM == FILE_STREAM 49 | #include 50 | #endif 51 | 52 | 53 | /** Number of bits for each byte */ 54 | #define BITS_IN_BYTE 8 55 | 56 | /** EXI Date-Time offset for year */ 57 | #define DATETIME_YEAR_OFFSET 2000 58 | /** EXI Date-Time number of bits for monthDay */ 59 | #define DATETIME_NUMBER_BITS_MONTHDAY 9 60 | /** EXI Date-Time number of bits for time */ 61 | #define DATETIME_NUMBER_BITS_TIME 17 62 | /** EXI Date-Time number of bits for timezone */ 63 | #define DATETIME_NUMBER_BITS_TIMEZONE 11 64 | /** EXI Date-Time month multiplicator */ 65 | #define DATETIME_MONTH_MULTIPLICATOR 32 66 | /** EXI Date-Time offset for timzone minutes */ 67 | #define DATETIME_TIMEZONE_OFFSET_IN_MINUTES 896 68 | 69 | /** Maximum integer value for uint */ 70 | #define UINT_MAX_VALUE 65535 71 | 72 | 73 | /** EXI Float exponent special values */ 74 | #define FLOAT_EXPONENT_SPECIAL_VALUES -16384 75 | /** EXI Float mantissa infinity */ 76 | #define FLOAT_MANTISSA_INFINITY 1 77 | /** EXI Float minus mantissa infinity */ 78 | #define FLOAT_MANTISSA_MINUS_INFINITY -1 79 | /** EXI Float not a number */ 80 | #define FLOAT_MANTISSA_NOT_A_NUMBER 0 81 | 82 | /** \brief EXI Events */ 83 | typedef enum { 84 | /** Start Document SD */ 85 | EXI_EVENT_START_DOCUMENT, 86 | /** End Document ED */ 87 | EXI_EVENT_END_DOCUMENT, 88 | /** Start Element SE(qname) */ 89 | EXI_EVENT_START_ELEMENT, 90 | /** Start Element SE(uri:*) */ 91 | EXI_EVENT_START_ELEMENT_NS, 92 | /** Start Element SE(*) generic */ 93 | EXI_EVENT_START_ELEMENT_GENERIC, 94 | /** Start Element SE(*) generic undeclared */ 95 | EXI_EVENT_START_ELEMENT_GENERIC_UNDECLARED, 96 | /** End Element EE */ 97 | EXI_EVENT_END_ELEMENT, 98 | /** End Element EE undeclared*/ 99 | EXI_EVENT_END_ELEMENT_UNDECLARED, 100 | /** Characters CH */ 101 | EXI_EVENT_CHARACTERS, 102 | /** Characters CH generic */ 103 | EXI_EVENT_CHARACTERS_GENERIC, 104 | /** Characters CH generic undeclared */ 105 | EXI_EVENT_CHARACTERS_GENERIC_UNDECLARED, 106 | /** Attribute AT(xsi:type) */ 107 | EXI_EVENT_ATTRIBUTE_XSI_TYPE, 108 | /** Attribute AT(xsi:nil) */ 109 | EXI_EVENT_ATTRIBUTE_XSI_NIL, 110 | /** Attribute AT(qname) */ 111 | EXI_EVENT_ATTRIBUTE, 112 | /** Attribute AT(uri:*) */ 113 | EXI_EVENT_ATTRIBUTE_NS, 114 | /** Attribute AT(*) generic */ 115 | EXI_EVENT_ATTRIBUTE_GENERIC, 116 | /** Attribute AT(*) invalid value */ 117 | EXI_EVENT_ATTRIBUTE_INVALID_VALUE, 118 | /** Attribute AT(*) any invalid value */ 119 | EXI_EVENT_ATTRIBUTE_ANY_INVALID_VALUE, 120 | /** Attribute AT(*) generic undeclared */ 121 | EXI_EVENT_ATTRIBUTE_GENERIC_UNDECLARED, 122 | /* error state */ 123 | EXI_EVENT_ERROR 124 | } exi_event_t; 125 | 126 | 127 | /** 128 | * \brief Bit stream container 129 | * 130 | * Structure for byteArray/file stream. 131 | * 132 | * # General 133 | * .size defines the maximum size of the byte array (see .data) 134 | * 135 | * .data points to the input/output array of bytes (unsigned char*). 136 | * 137 | * .pos has to be set to an pointer to an 32 bit long unsigned integer (uint32_t *) 138 | * as this variable is read/write. 139 | * Therefore it is best practice to declare the variable itself and use the &-operator 140 | * to assign the address. The value of that variable points to the position inside the 141 | * buffer where the stream begins. Which is usually the first (0th) byte but can also be 142 | * another value if there more information transferred in that stream. 143 | * After processing .pos points to the next "available" byte (if any left). 144 | * 145 | * .buffer has to be set to 0 for internal use only (single byte buffer) 146 | * 147 | * # Receiving data (input) 148 | * .capacity is used for addressing single bits in the actual byte (see .buffer) 149 | * and has to be set to 0, which means there are 0 bits read so far and a new 150 | * byte needs to be read from the input stream/data-array to the current byte buffer. 151 | * 152 | * # Sending data (output) 153 | * .capacity is used for addressing single bits in the actual byte (see .buffer) 154 | * and has to be set to 8, which means there are still 8 bits left to fill up 155 | * the current byte buffer before writing the final byte to the output stream/data-array. 156 | * 157 | */ 158 | typedef struct { 159 | #if EXI_STREAM == BYTE_ARRAY 160 | /** byte array size */ 161 | size_t size; 162 | /** byte array data */ 163 | uint8_t* data; 164 | /** byte array next position in array */ 165 | size_t* pos; 166 | #endif 167 | #if EXI_STREAM == FILE_STREAM 168 | /** file pointer */ 169 | FILE *file; 170 | #endif 171 | /** Current byte buffer*/ 172 | uint8_t buffer; 173 | /** Remaining bit capacity in current byte buffer*/ 174 | uint8_t capacity; 175 | } bitstream_t; 176 | 177 | 178 | /** \brief EXI Value Datatypes */ 179 | typedef enum { 180 | /** Binary Base64 */ 181 | EXI_DATATYPE_BINARY_BASE64, 182 | /** Binary Hex */ 183 | EXI_DATATYPE_BINARY_HEX, 184 | /** Boolean */ 185 | EXI_DATATYPE_BOOLEAN, 186 | /** Boolean with Facets */ 187 | EXI_DATATYPE_BOOLEAN_FACET, 188 | /** Decimal */ 189 | EXI_DATATYPE_DECIMAL, 190 | /** Float & Double */ 191 | EXI_DATATYPE_FLOAT, 192 | /** N-Bit Unsigned Integer */ 193 | EXI_DATATYPE_NBIT_UNSIGNED_INTEGER, 194 | /** Unsigned Integer */ 195 | EXI_DATATYPE_UNSIGNED_INTEGER, 196 | /** (Signed) Integer */ 197 | EXI_DATATYPE_INTEGER, 198 | /** Datetime */ 199 | EXI_DATATYPE_DATETIME, 200 | /** String */ 201 | EXI_DATATYPE_STRING, 202 | /** Restricted Character Set String */ 203 | EXI_DATATYPE_RCS_STRING, 204 | /** Enumeration */ 205 | EXI_DATATYPE_ENUMERATION, 206 | /** List */ 207 | EXI_DATATYPE_LIST, 208 | /** QName (e.g. xsi:type) */ 209 | EXI_DATATYPE_QNAME 210 | } exi_datatype_t; 211 | 212 | 213 | /** \brief EXI Integer Value types */ 214 | typedef enum { 215 | /** Unsigned Integer 8 bits */ 216 | EXI_UNSIGNED_INTEGER_8, 217 | /** Unsigned Integer 16 bits */ 218 | EXI_UNSIGNED_INTEGER_16, 219 | /** Unsigned Integer 32 bits */ 220 | EXI_UNSIGNED_INTEGER_32, 221 | /** Unsigned Integer 64 bits */ 222 | EXI_UNSIGNED_INTEGER_64, 223 | /** (Signed) Integer 8 bits */ 224 | EXI_INTEGER_8, 225 | /** (Signed) Integer 16 bits */ 226 | EXI_INTEGER_16, 227 | /** (Signed) Integer 32 bits */ 228 | EXI_INTEGER_32, 229 | /** (Signed) Integer 64 bits */ 230 | EXI_INTEGER_64 231 | } exi_integer_type_t; 232 | 233 | 234 | /** \brief EXI Datetime types */ 235 | typedef enum { 236 | /** gYear */ 237 | EXI_DATETIME_GYEAR, 238 | /** gYearMonth */ 239 | EXI_DATETIME_GYEARMONTH, 240 | /** date */ 241 | EXI_DATETIME_DATE, 242 | /** datetime */ 243 | EXI_DATETIME_DATETIME, 244 | /** gMonth */ 245 | EXI_DATETIME_GMONTH, 246 | /** gMonthDay */ 247 | EXI_DATETIME_GMONTHDAY, 248 | /** gDay */ 249 | EXI_DATETIME_GDAY, 250 | /** time */ 251 | EXI_DATETIME_TIME 252 | } exi_datetime_type_t; 253 | 254 | 255 | /** \brief String value type */ 256 | typedef enum { 257 | /** value miss */ 258 | EXI_STRING_VALUE_MISS, 259 | /** value local-hit */ 260 | EXI_STRING_VALUE_LOCAL_HIT, 261 | /** value global-hit */ 262 | EXI_STRING_VALUE_GLOBAL_HIT 263 | } exi_string_value_type_t; 264 | 265 | /** \brief EXI string character */ 266 | /* Note: define whether you wan't to support ASCII only or UCS */ 267 | #if STRING_REPRESENTATION == STRING_REPRESENTATION_ASCII 268 | typedef char exi_string_character_t; 269 | #endif /* STRING_REPRESENTATION_ASCII */ 270 | #if STRING_REPRESENTATION == STRING_REPRESENTATION_UCS 271 | typedef uint32_t exi_string_character_t; 272 | #endif /* STRING_REPRESENTATION_UCS */ 273 | 274 | 275 | 276 | /** \brief Universal Character Set (UCS) strings */ 277 | typedef struct { 278 | /** container size */ 279 | size_t size; 280 | /** string character container */ 281 | exi_string_character_t* characters; 282 | /** current string length == number of code-points, (len <= size) */ 283 | size_t len; 284 | } exi_string_t; 285 | 286 | 287 | /** \brief String value */ 288 | typedef struct { 289 | /** value type (e.g., miss, local-hit, global-hit) */ 290 | exi_string_value_type_t type; 291 | /** miss entry */ 292 | exi_string_t miss; 293 | /** (local) hit entry */ 294 | size_t localID; 295 | /** (global) hit entry */ 296 | size_t globalID; 297 | } exi_string_value_t; 298 | 299 | 300 | /** \brief Restricted Characeter Set */ 301 | typedef struct { 302 | /** size */ 303 | size_t size; 304 | /** rcs codepoints */ 305 | exi_string_character_t* characters; 306 | /** character coding length (less than 256 characters) */ 307 | uint8_t codingLength; 308 | } exi_rcs_t; 309 | 310 | 311 | /** \brief Byte value container */ 312 | typedef struct { 313 | /** bytes array size */ 314 | size_t size; 315 | /** bytes array data container */ 316 | uint8_t* data; 317 | /** bytes array length (len <= size) */ 318 | size_t len; 319 | } exi_bytes_t; 320 | 321 | 322 | /** \brief Integer value container */ 323 | typedef struct { 324 | /** type */ 325 | exi_integer_type_t type; 326 | union { 327 | /* (signed) values */ 328 | /** (signed) int 8 bits */ 329 | int8_t int8; 330 | /** (signed) int 16 bits */ 331 | int16_t int16; 332 | /** (signed) int 32 bits */ 333 | int32_t int32; 334 | /** (signed) int 64 bits */ 335 | int64_t int64; 336 | /* unsigned values */ 337 | /** unsigned int 8 bits */ 338 | uint8_t uint8; 339 | /** unsigned int 16 bits */ 340 | uint16_t uint16; 341 | /** unsigned int 32 bits */ 342 | uint32_t uint32; 343 | /** unsigned int 64 bits */ 344 | uint64_t uint64; 345 | } val; 346 | } exi_integer_t; 347 | 348 | 349 | /** \brief Float value container */ 350 | typedef struct { 351 | /** range of the mantissa is -(2^63) to 2^63-1 */ 352 | int64_t mantissa; 353 | /** range of the exponent is - (2^14-1) to 2^14-1 */ 354 | int16_t exponent; /* base-10 */ 355 | } exi_float_me_t; 356 | 357 | 358 | /** \brief Decimal value container */ 359 | typedef struct { 360 | /** a sign value */ 361 | int negative; 362 | /** represents the integral portion of the Decimal */ 363 | exi_integer_t integral; 364 | /** represents the fractional portion of the Decimal with the digits in reverse order to preserve leading zeros */ 365 | exi_integer_t reverseFraction; 366 | } exi_decimal_t; 367 | 368 | 369 | /** \brief Datetime value container */ 370 | typedef struct { 371 | /** datetime type */ 372 | exi_datetime_type_t type; 373 | /** Datetime value for year */ 374 | int32_t year; 375 | /** Datetime value for monthDay */ 376 | uint32_t monthDay; 377 | /** Datetime value for time */ 378 | uint32_t time; 379 | /** Datetime value for presenceFractionalSecs */ 380 | int presenceFractionalSecs; 381 | /** Datetime value for fractionalSecs */ 382 | uint32_t fractionalSecs; 383 | /** Datetime value for presenceTimezone */ 384 | int presenceTimezone; 385 | /** Datetime value for timezone */ 386 | uint32_t timezone; 387 | } exi_datetime_t; 388 | 389 | 390 | /** \brief List value container */ 391 | typedef struct { 392 | /** list item type */ 393 | exi_datatype_t type; 394 | /** number of items */ 395 | size_t len; 396 | /* Special datatype: integer */ 397 | /* exi_integer_type_t intType;*/ 398 | /** Special datatype: datetime */ 399 | exi_datetime_type_t datetimeType; 400 | } exi_list_t; 401 | 402 | 403 | /** \brief Efficient qname */ 404 | typedef struct { 405 | /** namespace URI ID*/ 406 | size_t namespaceURI; 407 | /** local name ID*/ 408 | size_t localPart; 409 | } exi_eqname_t; 410 | 411 | 412 | /** \brief Name entry type */ 413 | typedef enum { 414 | /** As known IDs */ 415 | EXI_NAME_ENTRY_TYPE_ID, 416 | /** As String */ 417 | EXI_NAME_ENTRY_TYPE_STRING_AND_ID 418 | } exi_name_entry_type_t; 419 | 420 | 421 | /** \brief Name entry */ 422 | typedef struct { 423 | /** type */ 424 | exi_name_entry_type_t type; 425 | /** entry ID */ 426 | size_t id; 427 | /** entry string */ 428 | exi_string_t str; 429 | } exi_name_entry_t; 430 | 431 | 432 | /** \brief Qualified name */ 433 | typedef struct { 434 | /** Uri */ 435 | exi_name_entry_t uri; 436 | /** LocalName */ 437 | exi_name_entry_t localName; 438 | } exi_qname_t; 439 | 440 | /*TODO Doxygen Documentation */ 441 | 442 | 443 | /* ==================================== */ 444 | /* URI and LocalName Entries */ 445 | typedef struct exiNameTablePrepopulated { 446 | /* number of namespaces AND length name-partitions array */ 447 | size_t len; 448 | /* number of localName entries divided by URI */ 449 | size_t* localNames; 450 | } exi_name_table_prepopulated_t; 451 | 452 | #define EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES 25 453 | 454 | typedef enum { 455 | EXI_NAME_PARTITION_URI, EXI_NAME_PARTITION_LOCALNAME 456 | } exi_name_partition_type_t; 457 | 458 | typedef struct { 459 | char* uri; 460 | size_t uriID; 461 | } exi_uri_partition_t; 462 | 463 | typedef struct { 464 | char* localName; 465 | size_t localNameID; 466 | size_t uriID; 467 | } exi_localname_partition_t; 468 | 469 | typedef struct { 470 | exi_name_partition_type_t namePartitionType; 471 | struct { 472 | exi_uri_partition_t uriPartition; 473 | exi_localname_partition_t localNamePartition; 474 | } entry; 475 | } exi_name_partition_t; 476 | 477 | typedef struct exiNameTableRuntime { 478 | /* maximum number of characters in the name partitions entries PLUS null terminators */ 479 | /* char characters[EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_CHARACTERS + EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES]; */ 480 | /* uint16_t numberOfUsedCharacters; *//* initially zero <= EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_CHARACTERS */ 481 | /* maximum number of name partitions entries. Name partitions entries consist in all uri, and local-name partition entries */ 482 | exi_name_partition_t 483 | namePartitionsEntries[EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES]; 484 | /* uint16_t numberOfUsedNamePartitions; *//* initially zero */ 485 | /* added entries */ 486 | size_t addedUriEntries; /* initially zero */ 487 | size_t addedLocalNameEntries; /* initially zero */ 488 | } exi_name_table_runtime_t; 489 | 490 | 491 | /* StartTagContent grammar initially empty */ 492 | /* ElementContent grammar has EE per default */ 493 | typedef struct { 494 | size_t namespaceUriID; 495 | size_t localNameID; 496 | size_t numberOfProductions; 497 | int hasXsiType; /* StartTagContent only */ 498 | int hasEE; /* ElementContentper default TRUE */ 499 | } exi_runtime_element_t; 500 | 501 | /* Note: We do have twice as many runtime grammars (StartTagContent and ElementContent)*/ 502 | #define MAX_NUMBER_OF_RUNTIME_ELEMENTS 80 503 | 504 | 505 | 506 | /* ==================================== */ 507 | /* Value string table */ 508 | typedef struct exiValueStringTableEntry { 509 | /** Qualified namespace URI */ 510 | size_t namespaceUriID; 511 | /** Qualified localName */ 512 | size_t localNameID; 513 | /** Local Value ID */ 514 | size_t localValueID; 515 | /** String */ 516 | exi_string_t str; 517 | } exi_value_string_table_entry_t; 518 | 519 | typedef struct exiValueStringTable { 520 | /** maximum number of global string table entry size */ 521 | size_t size; 522 | /** string table entry array container */ 523 | exi_value_string_table_entry_t* strs; 524 | /** current number of string table entries (len <= size) */ 525 | size_t len; 526 | } exi_value_string_table_t; 527 | 528 | /* typedef struct { */ 529 | /** number of global strings */ 530 | /* uint16_t numberOfGlobalStrings; */ 531 | /** size of local-names container */ 532 | /* uint16_t sizeLocalStrings; */ 533 | /** number of local strings container */ 534 | /* uint16_t* numberOfLocalStrings; */ 535 | /** string values */ 536 | /* exi_value_string_table_t* valueStringTable; 537 | } exi_value_table_t;*/ 538 | 539 | typedef struct { 540 | /** stack of grammar states */ 541 | int16_t grammarStack[EXI_ELEMENT_STACK_SIZE]; 542 | /** stack of grammar elements / qnameIDs */ 543 | exi_eqname_t elementStack[EXI_ELEMENT_STACK_SIZE]; 544 | /** stack index for both stacks */ 545 | size_t stackIndex; 546 | 547 | /** event-code */ 548 | uint32_t eventCode; 549 | 550 | /** name table entries, pre-populated */ 551 | exi_name_table_prepopulated_t* nameTablePrepopulated; 552 | /** name table entries, at runtime */ 553 | exi_name_table_runtime_t* nameTableRuntime; 554 | 555 | /** next qname ID */ 556 | size_t nextQNameID; 557 | 558 | /** string table entries */ 559 | exi_value_string_table_t* stringTable; 560 | 561 | /** runtime built-in element grammars - numbers */ 562 | size_t numberOfRuntimeGrammars; 563 | /** runtime built-in element grammars */ 564 | exi_runtime_element_t runtimeGrammars[MAX_NUMBER_OF_RUNTIME_ELEMENTS * 2]; 565 | } exi_state_t; 566 | 567 | typedef struct { 568 | /* type of value */ 569 | exi_datatype_t type; 570 | 571 | /* base types */ 572 | int boolean; 573 | uint32_t enumeration; 574 | 575 | /* complex types: Integers, Bytes, Strings and Lists are not native types anymore */ 576 | exi_integer_t integer; 577 | exi_bytes_t binary; 578 | exi_string_value_t str; 579 | exi_float_me_t float_me; 580 | exi_decimal_t decimal; 581 | exi_datetime_t datetime; 582 | exi_list_t list; 583 | exi_eqname_t eqname; 584 | } exi_value_t; 585 | 586 | 587 | #ifdef __cplusplus 588 | } 589 | #endif 590 | 591 | #endif 592 | -------------------------------------------------------------------------------- /src/codec/EncoderChannel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include "EncoderChannel.h" 33 | #include "EXIOptions.h" 34 | #include "BitOutputStream.h" 35 | #include "EXITypes.h" 36 | #include "ErrorCodes.h" 37 | #include "MethodsBag.h" 38 | /*#include "v2gEXICoder.h"*/ 39 | 40 | #ifndef ENCODER_CHANNEL_C 41 | #define ENCODER_CHANNEL_C 42 | 43 | int encodeUnsignedInteger(bitstream_t* stream, exi_integer_t* iv) { 44 | int errn = 0; 45 | switch (iv->type) { 46 | /* Unsigned Integer */ 47 | case EXI_UNSIGNED_INTEGER_8: 48 | errn = encodeUnsignedInteger32(stream, iv->val.uint8); 49 | break; 50 | case EXI_UNSIGNED_INTEGER_16: 51 | errn = encodeUnsignedInteger32(stream, iv->val.uint16); 52 | break; 53 | case EXI_UNSIGNED_INTEGER_32: 54 | errn = encodeUnsignedInteger32(stream, iv->val.uint32); 55 | break; 56 | case EXI_UNSIGNED_INTEGER_64: 57 | errn = encodeUnsignedInteger64(stream, iv->val.uint64); 58 | break; 59 | /* (Signed) Integer */ 60 | case EXI_INTEGER_8: 61 | if (iv->val.int8 < 0) { 62 | return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE; 63 | } 64 | errn = encodeUnsignedInteger32(stream, (uint32_t)(iv->val.int8)); 65 | break; 66 | case EXI_INTEGER_16: 67 | if (iv->val.int16 < 0) { 68 | return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE; 69 | } 70 | errn = encodeUnsignedInteger32(stream, (uint32_t)(iv->val.int16)); 71 | break; 72 | case EXI_INTEGER_32: 73 | if (iv->val.int32 < 0) { 74 | return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE; 75 | } 76 | errn = encodeUnsignedInteger32(stream, (uint32_t)(iv->val.int32)); 77 | break; 78 | case EXI_INTEGER_64: 79 | if (iv->val.int64 < 0) { 80 | return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE; 81 | } 82 | errn = encodeUnsignedInteger64(stream, (uint64_t)(iv->val.int64)); 83 | break; 84 | default: 85 | errn = EXI_UNSUPPORTED_INTEGER_VALUE_TYPE; 86 | break; 87 | } 88 | 89 | return errn; 90 | } 91 | 92 | /** 93 | * Encode an arbitrary precision non negative integer using a sequence of 94 | * octets. The most significant bit of the last octet is set to zero to 95 | * indicate sequence termination. Only seven bits per octet are used to 96 | * store the integer's value. 97 | */ 98 | int encodeUnsignedInteger16(bitstream_t* stream, uint16_t n) { 99 | int errn = 0; 100 | if (n < 128) { 101 | /* write byte as is */ 102 | errn = encode(stream, (uint8_t) n); 103 | } else { 104 | uint8_t n7BitBlocks = numberOf7BitBlocksToRepresent(n); 105 | 106 | switch (n7BitBlocks) { 107 | case 3: 108 | errn = encode(stream, (uint8_t) (128 | n)); 109 | n = n >> 7; 110 | if (errn != 0) { 111 | break; 112 | } 113 | /* no break */ 114 | case 2: 115 | errn = encode(stream, (uint8_t) (128 | n)); 116 | n = n >> 7; 117 | if (errn != 0) { 118 | break; 119 | } 120 | /* no break */ 121 | case 1: 122 | /* 0 .. 7 (last byte) */ 123 | errn = encode(stream, (uint8_t) (0 | n)); 124 | /* no break */ 125 | } 126 | } 127 | 128 | return errn; 129 | } 130 | 131 | /** 132 | * Encode an arbitrary precision non negative integer using a sequence of 133 | * octets. The most significant bit of the last octet is set to zero to 134 | * indicate sequence termination. Only seven bits per octet are used to 135 | * store the integer's value. 136 | */ 137 | int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n) { 138 | int errn = 0; 139 | if (n < 128) { 140 | /* write byte as is */ 141 | errn = encode(stream, (uint8_t) n); 142 | } else { 143 | uint8_t n7BitBlocks = numberOf7BitBlocksToRepresent(n); 144 | 145 | switch (n7BitBlocks) { 146 | case 5: 147 | errn = encode(stream, (uint8_t) (128 | n)); 148 | n = n >> 7; 149 | if (errn != 0) { 150 | break; 151 | } 152 | /* no break */ 153 | case 4: 154 | errn = encode(stream, (uint8_t) (128 | n)); 155 | n = n >> 7; 156 | if (errn != 0) { 157 | break; 158 | } 159 | /* no break */ 160 | case 3: 161 | errn = encode(stream, (uint8_t) (128 | n)); 162 | n = n >> 7; 163 | if (errn != 0) { 164 | break; 165 | } 166 | /* no break */ 167 | case 2: 168 | errn = encode(stream, (uint8_t) (128 | n)); 169 | n = n >> 7; 170 | if (errn != 0) { 171 | break; 172 | } 173 | /* no break */ 174 | case 1: 175 | /* 0 .. 7 (last byte) */ 176 | errn = encode(stream, (uint8_t) (0 | n)); 177 | /* no break */ 178 | } 179 | } 180 | 181 | return errn; 182 | } 183 | 184 | /** 185 | * Encode an arbitrary precision non negative integer using a sequence of 186 | * octets. The most significant bit of the last octet is set to zero to 187 | * indicate sequence termination. Only seven bits per octet are used to 188 | * store the integer's value. 189 | */ 190 | int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n) { 191 | int errn = 0; 192 | uint8_t lastEncode = (uint8_t) n; 193 | n >>= 7; 194 | 195 | while (n != 0 && errn == 0) { 196 | errn = encode(stream, lastEncode | 128); 197 | lastEncode = (uint8_t) n; 198 | n >>= 7; 199 | } 200 | 201 | if (errn == 0) { 202 | errn = encode(stream, lastEncode); 203 | } 204 | 205 | return errn; 206 | } 207 | 208 | void _shiftRight7(uint8_t* buf, int len) { 209 | const int shift = 7; 210 | unsigned char tmp = 0x00, tmp2 = 0x00; 211 | for (int k = 0; k <= len; k++) { 212 | if (k == 0) { 213 | tmp = buf[k]; 214 | buf[k] >>= shift; 215 | } else { 216 | tmp2 = buf[k]; 217 | buf[k] >>= shift; 218 | buf[k] |= ((tmp & 0x7F) << (8 - shift)); 219 | 220 | if (k != len) { 221 | tmp = tmp2; 222 | } 223 | } 224 | } 225 | } 226 | 227 | /** 228 | * Encode an arbitrary precision non negative integer using a sequence of 229 | * octets. The most significant bit of the last octet is set to zero to 230 | * indicate sequence termination. Only seven bits per octet are used to 231 | * store the integer's value. 232 | */ 233 | int encodeUnsignedIntegerBig(bitstream_t* stream, size_t size, uint8_t* data, size_t len) { 234 | int errn = 0; 235 | int i; 236 | int lenM1 = len - 1; 237 | const int MAX_BIGINT_ARRAY = 25; 238 | uint8_t lastEncode = 0; 239 | uint8_t bytesToShift[MAX_BIGINT_ARRAY]; // MAXIMUM 240 | size_t bitsToEncode = len * 8; 241 | 242 | if(MAX_BIGINT_ARRAY <= len) { 243 | return -1; 244 | } 245 | 246 | /* init */ 247 | for(i=0; i 7) { 257 | lastEncode = bytesToShift[lenM1]; 258 | lastEncode = lastEncode | 128; 259 | errn = encode(stream, lastEncode); 260 | _shiftRight7(bytesToShift, len); 261 | bitsToEncode -= 7; 262 | } 263 | 264 | if (errn == 0) { 265 | errn = encode(stream, bytesToShift[lenM1]); 266 | } 267 | 268 | return errn; 269 | } 270 | 271 | int encodeInteger(bitstream_t* stream, exi_integer_t* iv) { 272 | int errn = 0; 273 | switch (iv->type) { 274 | /* Unsigned Integer */ 275 | case EXI_UNSIGNED_INTEGER_8: 276 | errn = encodeInteger32(stream, iv->val.uint8); 277 | break; 278 | case EXI_UNSIGNED_INTEGER_16: 279 | errn = encodeInteger32(stream, iv->val.uint16); 280 | break; 281 | case EXI_UNSIGNED_INTEGER_32: 282 | errn = encodeInteger64(stream, iv->val.uint32); 283 | break; 284 | case EXI_UNSIGNED_INTEGER_64: 285 | errn = encodeInteger64(stream, (int64_t)(iv->val.uint64)); 286 | break; 287 | /* (Signed) Integer */ 288 | case EXI_INTEGER_8: 289 | errn = encodeInteger32(stream, iv->val.int8); 290 | break; 291 | case EXI_INTEGER_16: 292 | errn = encodeInteger32(stream, iv->val.int16); 293 | break; 294 | case EXI_INTEGER_32: 295 | errn = encodeInteger32(stream, iv->val.int32); 296 | break; 297 | case EXI_INTEGER_64: 298 | errn = encodeInteger64(stream, iv->val.int64); 299 | break; 300 | default: 301 | errn = EXI_UNSUPPORTED_INTEGER_VALUE_TYPE; 302 | break; 303 | } 304 | 305 | return errn; 306 | } 307 | 308 | 309 | /** 310 | * Encode an arbitrary precision integer using a sign bit followed by a 311 | * sequence of octets. The most significant bit of the last octet is set to 312 | * zero to indicate sequence termination. Only seven bits per octet are used 313 | * to store the integer's value. 314 | */ 315 | int encodeInteger16(bitstream_t* stream, int16_t n) { 316 | int errn; 317 | /* signalize sign */ 318 | if (n < 0) { 319 | errn = encodeBoolean(stream, 1); 320 | /* For negative values, the Unsigned Integer holds the 321 | * magnitude of the value minus 1 */ 322 | n = (int16_t)((-n) - 1); 323 | } else { 324 | errn = encodeBoolean(stream, 0); 325 | } 326 | if (errn == 0) { 327 | errn = encodeUnsignedInteger16(stream, (uint16_t)n); 328 | } 329 | return errn; 330 | } 331 | 332 | 333 | 334 | /** 335 | * Encode an arbitrary precision integer using a sign bit followed by a 336 | * sequence of octets. The most significant bit of the last octet is set to 337 | * zero to indicate sequence termination. Only seven bits per octet are used 338 | * to store the integer's value. 339 | */ 340 | int encodeInteger32(bitstream_t* stream, int32_t n) { 341 | int errn; 342 | /* signalize sign */ 343 | if (n < 0) { 344 | errn = encodeBoolean(stream, 1); 345 | /* For negative values, the Unsigned Integer holds the 346 | * magnitude of the value minus 1 */ 347 | n = (-n) - 1; 348 | } else { 349 | errn = encodeBoolean(stream, 0); 350 | } 351 | if (errn == 0) { 352 | errn = encodeUnsignedInteger32(stream, (uint32_t)n); 353 | } 354 | return errn; 355 | } 356 | 357 | /** 358 | * Encode an arbitrary precision integer using a sign bit followed by a 359 | * sequence of octets. The most significant bit of the last octet is set to 360 | * zero to indicate sequence termination. Only seven bits per octet are used 361 | * to store the integer's value. 362 | */ 363 | int encodeInteger64(bitstream_t* stream, int64_t n) { 364 | int errn; 365 | /* signalize sign */ 366 | if (n < 0) { 367 | errn = encodeBoolean(stream, 1); 368 | /* For negative values, the Unsigned Integer holds the 369 | * magnitude of the value minus 1 */ 370 | n = (-n) - 1; 371 | } else { 372 | errn = encodeBoolean(stream, 0); 373 | } 374 | if (errn == 0) { 375 | errn = encodeUnsignedInteger64(stream, (uint64_t)n); 376 | } 377 | return errn; 378 | } 379 | 380 | 381 | /** 382 | * Encode an arbitrary precision integer using a sign bit followed by a 383 | * sequence of octets. The most significant bit of the last octet is set to 384 | * zero to indicate sequence termination. Only seven bits per octet are used 385 | * to store the integer's value. 386 | */ 387 | int encodeIntegerBig(bitstream_t* stream, int negative, size_t size, uint8_t* data, size_t len) { 388 | int errn; 389 | /* signalize sign */ 390 | if (negative) { 391 | errn = encodeBoolean(stream, 1); 392 | /* For negative values, the Unsigned Integer holds the 393 | * magnitude of the value minus 1 */ 394 | /* n = (-n) - 1; */ 395 | } else { 396 | errn = encodeBoolean(stream, 0); 397 | } 398 | if (errn == 0) { 399 | errn = encodeUnsignedIntegerBig(stream, size, data, len); 400 | } 401 | return errn; 402 | } 403 | 404 | /** 405 | * The Float datatype representation is two consecutive Integers. 406 | * The first Integer represents the mantissa of the floating point 407 | * number and the second Integer represents the base-10 exponent 408 | * of the floating point number. 409 | */ 410 | int encodeFloat(bitstream_t* stream, exi_float_me_t* f) { 411 | int errn = encodeInteger64(stream, f->mantissa); 412 | if (errn == 0) { 413 | errn = encodeInteger32(stream, f->exponent); 414 | } 415 | return errn; 416 | } 417 | 418 | /** 419 | * Encode a decimal represented as a Boolean sign followed by two Unsigned 420 | * Integers. A sign value of zero (0) is used to represent positive Decimal 421 | * values and a sign value of one (1) is used to represent negative Decimal 422 | * values The first Integer represents the integral portion of the Decimal 423 | * value. The second positive integer represents the fractional portion of 424 | * the decimal with the digits in reverse order to preserve leading zeros. 425 | */ 426 | int encodeDecimal(bitstream_t* stream, exi_decimal_t* d) { 427 | /* sign, integral, reverse fractional */ 428 | int errn = encodeBoolean(stream, d->negative); 429 | if (errn == 0) { 430 | errn = encodeUnsignedInteger(stream, &d->integral); 431 | if (errn == 0) { 432 | errn = encodeUnsignedInteger(stream, &d->reverseFraction); 433 | } 434 | } 435 | return errn; 436 | } 437 | 438 | /** 439 | * Encode a length prefixed sequence of characters. 440 | */ 441 | int encodeString(bitstream_t* stream, exi_string_t* string) { 442 | int errn = encodeUnsignedInteger32(stream, string->len); 443 | if (errn == 0) { 444 | errn = encodeCharacters(stream, string->characters, string->len); 445 | } 446 | return errn; 447 | } 448 | 449 | /** 450 | * Encode a sequence of characters according to a given length. 451 | * Each character is represented by its UCS [ISO/IEC 10646] 452 | * code point encoded as an Unsigned Integer 453 | */ 454 | int encodeCharacters(bitstream_t* stream, exi_string_character_t* chars, size_t len) { 455 | unsigned int i; 456 | int errn = 0; 457 | for (i = 0; i < len && errn == 0; i++) { 458 | #if STRING_REPRESENTATION == STRING_REPRESENTATION_ASCII 459 | errn = encode(stream, (uint8_t)chars[i]); 460 | #endif /* STRING_REPRESENTATION_ASCII */ 461 | #if STRING_REPRESENTATION == STRING_REPRESENTATION_UCS 462 | errn = encodeUnsignedInteger32(stream, chars[i]); 463 | #endif /* STRING_REPRESENTATION_UCS */ 464 | } 465 | return errn; 466 | } 467 | 468 | 469 | int encodeRCSCharacters(bitstream_t* stream, exi_string_character_t* chars, size_t len, size_t rcsCodeLength, size_t rcsSize, const exi_string_character_t rcsSet[]) { 470 | unsigned int i; 471 | unsigned int k; 472 | int errn = 0; 473 | size_t rcsCode = SIZE_MAX; 474 | 475 | for (i = 0; i < len && errn == 0; i++) { 476 | /* try to find short code */ 477 | rcsCode = SIZE_MAX; 478 | for(k=0; klen); 507 | 508 | if(errn == 0) { 509 | errn = encodeBytes(stream, bytes->data, bytes->len); 510 | } 511 | 512 | return errn; 513 | } 514 | 515 | int encodeBytes(bitstream_t* stream, uint8_t* data, size_t len) { 516 | unsigned int i; 517 | int errn = 0; 518 | 519 | for (i = 0; i < len && errn == 0; i++) { 520 | errn = encode(stream, data[i]); 521 | } 522 | return errn; 523 | } 524 | 525 | /** 526 | * Encode a datetime representation which is a sequence of values 527 | * representing the individual components of the Date-Time 528 | */ 529 | int encodeDateTime(bitstream_t* stream, exi_datetime_t* datetime) { 530 | int errn = 0; 531 | switch (datetime->type) { 532 | case EXI_DATETIME_GYEAR: /* Year, [Time-Zone] */ 533 | errn = encodeInteger32(stream, datetime->year - DATETIME_YEAR_OFFSET); 534 | break; 535 | case EXI_DATETIME_GYEARMONTH: /* Year, MonthDay, [TimeZone] */ 536 | case EXI_DATETIME_DATE: /* Year, MonthDay, [TimeZone] */ 537 | errn = encodeInteger32(stream, datetime->year - DATETIME_YEAR_OFFSET); 538 | if (errn == 0) { 539 | errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, 540 | datetime->monthDay); 541 | } 542 | break; 543 | case EXI_DATETIME_DATETIME: /* Year, MonthDay, Time, [FractionalSecs], [TimeZone] */ 544 | errn = encodeInteger32(stream, datetime->year - DATETIME_YEAR_OFFSET); 545 | if (errn == 0) { 546 | errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, 547 | datetime->monthDay); 548 | if (errn != 0) { 549 | break; 550 | } 551 | } 552 | /* no break */ 553 | case EXI_DATETIME_TIME: /* Time, [FractionalSecs], [TimeZone] */ 554 | errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_TIME, 555 | datetime->time); 556 | if (errn == 0) { 557 | if (datetime->presenceFractionalSecs) { 558 | errn = encodeBoolean(stream, 1); 559 | if (errn == 0) { 560 | errn = encodeUnsignedInteger32(stream, datetime->fractionalSecs); 561 | } 562 | } else { 563 | errn = encodeBoolean(stream, 0); 564 | } 565 | } 566 | break; 567 | case EXI_DATETIME_GMONTH: /* MonthDay, [TimeZone] */ 568 | case EXI_DATETIME_GMONTHDAY: /* MonthDay, [TimeZone] */ 569 | case EXI_DATETIME_GDAY: /* MonthDay, [TimeZone] */ 570 | errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, 571 | datetime->monthDay); 572 | break; 573 | default: 574 | errn = EXI_UNSUPPORTED_DATETIME_TYPE; 575 | break; 576 | } 577 | if (errn == 0) { 578 | /* [TimeZone] */ 579 | if (datetime->presenceTimezone) { 580 | errn = encodeBoolean(stream, 1); 581 | if (errn == 0) { 582 | errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_TIMEZONE, 583 | datetime->timezone + DATETIME_TIMEZONE_OFFSET_IN_MINUTES); 584 | } 585 | } else { 586 | errn = encodeBoolean(stream, 0); 587 | } 588 | } 589 | 590 | return errn; 591 | } 592 | 593 | 594 | 595 | 596 | int encode(bitstream_t* stream, uint8_t b) { 597 | #if EXI_OPTION_ALIGNMENT == BIT_PACKED 598 | return writeBits(stream, 8, b); 599 | #endif /* EXI_OPTION_ALIGNMENT == BIT_PACKED */ 600 | #if EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT 601 | int errn = 0; 602 | #if EXI_STREAM == BYTE_ARRAY 603 | if ( (*stream->pos) < stream->size ) { 604 | stream->data[(*stream->pos)++] = b; 605 | } else { 606 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 607 | } 608 | #endif /* EXI_STREAM == BYTE_ARRAY */ 609 | #if EXI_STREAM == FILE_STREAM 610 | if ( putc(b, stream->file) == EOF ) { 611 | errn = EXI_ERROR_OUTPUT_STREAM_EOF; 612 | } 613 | #endif /* EXI_STREAM == FILE_STREAM */ 614 | return errn; 615 | #endif /* EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT */ 616 | } 617 | 618 | /** 619 | * Encode a single boolean value. A false value is encoded as bit 0 and true 620 | * value is encode as bit 1. 621 | */ 622 | int encodeBoolean(bitstream_t* stream, int b) { 623 | #if EXI_OPTION_ALIGNMENT == BIT_PACKED 624 | uint8_t val = b ? 1 : 0; 625 | return writeBits(stream, 1, val); 626 | #endif /* EXI_OPTION_ALIGNMENT == BIT_PACKED */ 627 | #if EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT 628 | uint8_t val = b ? 1 : 0; 629 | return encode(stream, val); 630 | #endif /* EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT */ 631 | } 632 | 633 | 634 | /** 635 | * Encode n-bit unsigned integer. The n least significant bits of parameter 636 | * b starting with the most significant, i.e. from left to right. 637 | */ 638 | int encodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint32_t val) { 639 | #if EXI_OPTION_ALIGNMENT == BIT_PACKED 640 | int errn = 0; 641 | if (nbits > 0) { 642 | errn = writeBits(stream, nbits, val); 643 | } 644 | return errn; 645 | #endif /* EXI_OPTION_ALIGNMENT == BIT_PACKED */ 646 | #if EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT 647 | int errn = 0; 648 | if (nbits > 0) { 649 | if (nbits < 9) { 650 | /* 1 byte */ 651 | errn = encode(stream, val & 0xff); 652 | } else if (nbits < 17) { 653 | /* 2 bytes */ 654 | errn = encode(stream, val & 0x00ff); 655 | if(errn == 0) { 656 | errn = encode(stream, (uint8_t)((val & 0xff00) >> 8)); 657 | } 658 | } else if (nbits < 25) { 659 | /* 3 bytes */ 660 | errn = encode(stream, val & 0x0000ff); 661 | if(errn == 0) { 662 | errn = encode(stream, (uint8_t)((val & 0x00ff00) >> 8)); 663 | if(errn == 0) { 664 | errn = encode(stream, (uint8_t)((val & 0xff0000) >> 16)); 665 | } 666 | } 667 | } else if (nbits < 33) { 668 | /* 4 bytes */ 669 | errn = encode(stream, val & 0x000000ff); 670 | if(errn == 0) { 671 | errn = encode(stream, (uint8_t)((val & 0x0000ff00) >> 8)); 672 | if(errn == 0) { 673 | errn = encode(stream, (uint8_t)((val & 0x00ff0000) >> 16)); 674 | if(errn == 0) { 675 | errn = encode(stream, (uint8_t)((val & 0xff000000) >> 24)); 676 | } 677 | } 678 | } 679 | } else { 680 | /* TODO Currently not more than 4 Bytes allowed for NBitUnsignedInteger */ 681 | errn = EXI_UNSUPPORTED_NBIT_INTEGER_LENGTH; 682 | } 683 | } 684 | return errn; 685 | #endif /* EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT */ 686 | } 687 | 688 | /** 689 | * Flush underlying output stream. 690 | */ 691 | int encodeFinish(bitstream_t* stream) { 692 | #if EXI_OPTION_ALIGNMENT == BIT_PACKED 693 | #endif /* EXI_OPTION_ALIGNMENT == BIT_PACKED */ 694 | return flush(stream); 695 | #if EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT 696 | /* no pending bits in byte-aligned mode */ 697 | return 0; 698 | #endif /* EXI_OPTION_ALIGNMENT == BYTE_ALIGNMENT */ 699 | } 700 | 701 | 702 | 703 | #endif 704 | 705 | -------------------------------------------------------------------------------- /src/codec/EncoderChannel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EncoderChannel.h 34 | * \brief EXI Encoder Channel 35 | * 36 | */ 37 | 38 | #ifndef ENCODER_CHANNEL_H 39 | #define ENCODER_CHANNEL_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "EXITypes.h" 46 | 47 | 48 | /** 49 | * \brief Encode byte value 50 | * 51 | * \param stream Output Stream 52 | * \param b byte 53 | * \return Error-Code <> 0 54 | * 55 | */ 56 | int encode(bitstream_t* stream, uint8_t b); 57 | 58 | 59 | /** 60 | * \brief Encode a single boolean value 61 | * 62 | * A false value is encoded as 0 and true value is encode as 1. 63 | * 64 | * \param stream Output Stream 65 | * \param b boolean 66 | * \return Error-Code <> 0 67 | * 68 | */ 69 | int encodeBoolean(bitstream_t* stream, int b); 70 | 71 | 72 | /** 73 | * \brief Encode n-bit unsigned integer 74 | * 75 | * The n least significant bits of parameter b starting with the 76 | * most significant, i.e. from left to right. 77 | * 78 | * \param stream Output Stream 79 | * \param nbits number of bits 80 | * \param val value 81 | * \return Error-Code <> 0 82 | * 83 | */ 84 | int encodeNBitUnsignedInteger(bitstream_t* stream, size_t nbits, uint32_t val); 85 | 86 | 87 | /** 88 | * \brief Encode unsigned integer 89 | * 90 | * Encode an arbitrary precision non negative integer using 91 | * a sequence of octets. The most significant bit of the last 92 | * octet is set to zero to indicate sequence termination. 93 | * Only seven bits per octet are used to store the integer's value. 94 | * 95 | * \param stream Output Stream 96 | * \param iv Unsigned integer value 97 | * \return Error-Code <> 0 98 | * 99 | */ 100 | int encodeUnsignedInteger(bitstream_t* stream, exi_integer_t* iv); 101 | 102 | 103 | /** 104 | * \brief Encode unsigned integer 105 | * 106 | * Encode an arbitrary precision non negative integer using 107 | * a sequence of octets. The most significant bit of the last 108 | * octet is set to zero to indicate sequence termination. 109 | * Only seven bits per octet are used to store the integer's value. 110 | * 111 | * \param stream Output Stream 112 | * \param n Unsigned integer value 16 bits 113 | * \return Error-Code <> 0 114 | * 115 | */ 116 | int encodeUnsignedInteger16(bitstream_t* stream, uint16_t n); 117 | 118 | 119 | 120 | /** 121 | * \brief Encode unsigned integer 122 | * 123 | * Encode an arbitrary precision non negative integer using 124 | * a sequence of octets. The most significant bit of the last 125 | * octet is set to zero to indicate sequence termination. 126 | * Only seven bits per octet are used to store the integer's value. 127 | * 128 | * \param stream Output Stream 129 | * \param n Unsigned integer value 32 bits 130 | * \return Error-Code <> 0 131 | * 132 | */ 133 | int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n); 134 | 135 | 136 | /** 137 | * \brief Encode unsigned integer 138 | * 139 | * Encode an arbitrary precision non negative integer using 140 | * a sequence of octets. The most significant bit of the last 141 | * octet is set to zero to indicate sequence termination. 142 | * Only seven bits per octet are used to store the integer's value. 143 | * 144 | * \param stream Output Stream 145 | * \param n Unsigned integer value 64 bits 146 | * \return Error-Code <> 0 147 | * 148 | */ 149 | int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n); 150 | 151 | /** 152 | * \brief Encode unsigned integer 153 | * 154 | * Encode an arbitrary precision non negative integer using 155 | * a sequence of octets. The most significant bit of the last 156 | * octet is set to zero to indicate sequence termination. 157 | * Only seven bits per octet are used to store the integer's value. 158 | * 159 | * \param stream Output Stream 160 | * \param size size array 161 | * \param data data array 162 | * \param len length array 163 | * \return Error-Code <> 0 164 | * 165 | */ 166 | int encodeUnsignedIntegerBig(bitstream_t* stream, size_t size, uint8_t* data, size_t len); 167 | 168 | 169 | /** 170 | * \brief Encode integer 171 | * 172 | * Encode an arbitrary precision integer using a sign boolean 173 | * followed by a sequence of octets. The most significant bit 174 | * of the last octet is set to zero to indicate sequence termination. 175 | * Only seven bits per octet are used to store the integer's value. 176 | * 177 | * \param stream Output Stream 178 | * \param iv Integer value 179 | * \return Error-Code <> 0 180 | * 181 | */ 182 | int encodeInteger(bitstream_t* stream, exi_integer_t* iv); 183 | 184 | 185 | /** 186 | * \brief Encode integer 187 | * 188 | * Encode an arbitrary precision integer using a sign boolean 189 | * followed by a sequence of octets. The most significant bit 190 | * of the last octet is set to zero to indicate sequence termination. 191 | * Only seven bits per octet are used to store the integer's value. 192 | * 193 | * \param stream Output Stream 194 | * \param n Integer value 16 bits 195 | * \return Error-Code <> 0 196 | * 197 | */ 198 | int encodeInteger16(bitstream_t* stream, int16_t n); 199 | 200 | /** 201 | * \brief Encode integer 202 | * 203 | * Encode an arbitrary precision integer using a sign boolean 204 | * followed by a sequence of octets. The most significant bit 205 | * of the last octet is set to zero to indicate sequence termination. 206 | * Only seven bits per octet are used to store the integer's value. 207 | * 208 | * \param stream Output Stream 209 | * \param n Integer value 32 bits 210 | * \return Error-Code <> 0 211 | * 212 | */ 213 | int encodeInteger32(bitstream_t* stream, int32_t n); 214 | 215 | 216 | /** 217 | * \brief Encode integer 218 | * 219 | * Encode an arbitrary precision integer using a sign boolean 220 | * followed by a sequence of octets. The most significant bit 221 | * of the last octet is set to zero to indicate sequence termination. 222 | * Only seven bits per octet are used to store the integer's value. 223 | * 224 | * \param stream Output Stream 225 | * \param n Integer value 64 bits 226 | * \return Error-Code <> 0 227 | * 228 | */ 229 | int encodeInteger64(bitstream_t* stream, int64_t n); 230 | 231 | /** 232 | * \brief Encode integer 233 | * 234 | * Encode an arbitrary precision integer using a sign boolean 235 | * followed by a sequence of octets. The most significant bit 236 | * of the last octet is set to zero to indicate sequence termination. 237 | * Only seven bits per octet are used to store the integer's value. 238 | * 239 | * \param stream Output Stream 240 | * \param negative negative integer 241 | * \param size size array 242 | * \param data data array 243 | * \param len length array 244 | * \return Error-Code <> 0 245 | * 246 | */ 247 | int encodeIntegerBig(bitstream_t* stream, int negative, size_t size, uint8_t* data, size_t len); 248 | 249 | /** 250 | * \brief Encode float 251 | * 252 | * Encode a Float datatype as two consecutive Integers. The first 253 | * Integer represents the mantissa of the floating point number 254 | * and the second Integer represents the base-10 exponent of the 255 | * floating point number. 256 | * 257 | * \param stream Output Stream 258 | * \param f Float value 259 | * \return Error-Code <> 0 260 | * 261 | */ 262 | int encodeFloat(bitstream_t* stream, exi_float_me_t* f); 263 | 264 | 265 | /** 266 | * \brief Encode decimal 267 | * 268 | * Encode a decimal represented as a Boolean sign followed by two 269 | * Unsigned Integers. A sign value of zero (0) is used to represent 270 | * positive Decimal values and a sign value of one (1) is used to 271 | * represent negative Decimal values The first Integer represents 272 | * the integral portion of the Decimal value. The second positive 273 | * integer represents the fractional portion of the decimal with 274 | * the digits in reverse order to preserve leading zeros. 275 | * 276 | * \param stream Output Stream 277 | * \param d Decimal value 278 | * \return Error-Code <> 0 279 | * 280 | */ 281 | int encodeDecimal(bitstream_t* stream, exi_decimal_t* d); 282 | 283 | 284 | /** 285 | * \brief Encode string 286 | * 287 | * Encode a length prefixed sequence of characters. 288 | * 289 | * \param stream Output Stream 290 | * \param string String 291 | * \return Error-Code <> 0 292 | * 293 | */ 294 | int encodeString(bitstream_t* stream, exi_string_t* string); 295 | 296 | 297 | /** 298 | * \brief Encode string value 299 | * 300 | * Encode a length prefixed sequence of characters 301 | * in the sense of string tables 302 | * 303 | * \param stream Output Stream 304 | * \param stringTable String Table 305 | * \param namespaceUriID Qualified Namespace ID 306 | * \param localNameID Qualified LocalName ID 307 | * \param string String value 308 | * \return Error-Code <> 0 309 | * 310 | */ 311 | int encodeStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, size_t namespaceUriID, size_t localNameID, 312 | exi_string_value_t* string); 313 | 314 | 315 | /** 316 | * \brief Encode restricted character set value 317 | * 318 | * Encode a length prefixed sequence of characters 319 | * in the sense of string tables 320 | * 321 | * \param stream Output Stream 322 | * \param StringTable StringTable 323 | * \param namespaceUriID Qualified Namespace ID 324 | * \param localNameID Qualified LocalName ID 325 | * \param rcs Restricted character set 326 | * \param string String value 327 | * \return Error-Code <> 0 328 | * 329 | */ 330 | int encodeRCSStringValue(bitstream_t* stream, exi_value_string_table_t* stringTable, 331 | size_t namespaceUriID, size_t localNameID, exi_rcs_t* rcs, exi_string_value_t* string); 332 | 333 | 334 | /** 335 | * \brief Encode characters 336 | * 337 | * Encode a sequence of characters according to a given length. 338 | * Each character is represented by its UCS [ISO/IEC 10646] 339 | * code point encoded as an Unsigned Integer. 340 | * 341 | * \param stream Output Stream 342 | * \param chars Characters 343 | * \param len Numbr of characters 344 | * \return Error-Code <> 0 345 | * 346 | */ 347 | int encodeCharacters(bitstream_t* stream, exi_string_character_t* chars, size_t len); 348 | 349 | 350 | /** 351 | * \brief Encode characters 352 | * 353 | * Encode a sequence of characters according to a given length. 354 | * Each character is represented by its UCS [ISO/IEC 10646] 355 | * code point encoded as an Unsigned Integer. 356 | * 357 | * \param stream Output Stream 358 | * \param chars Characters 359 | * \param len Numbr of characters 360 | * \param rcsCodeLength RCS code-length 361 | * \param rcsCodeLength RCS size 362 | * \param rcsCodeLength RCS set 363 | * \return Error-Code <> 0 364 | * 365 | */ 366 | int encodeRCSCharacters(bitstream_t* stream, exi_string_character_t* chars, size_t len, size_t rcsCodeLength, size_t rcsSize, const exi_string_character_t rcsSet[]); 367 | 368 | 369 | 370 | /** 371 | * \brief Encode binary 372 | * 373 | * Encode a binary value as a length-prefixed sequence of octets. 374 | * 375 | * \param stream Output Stream 376 | * \param bytes Byte values 377 | * \return Error-Code <> 0 378 | * 379 | */ 380 | int encodeBinary(bitstream_t* stream, exi_bytes_t* bytes); 381 | 382 | 383 | /** 384 | * \brief Encode binary data 385 | * 386 | * Encode a sequence of octets. 387 | * 388 | * \param stream Output Stream 389 | * \param data Byte values 390 | * \param len Length 391 | * \return Error-Code <> 0 392 | * 393 | */ 394 | int encodeBytes(bitstream_t* stream, uint8_t* data, size_t len); 395 | 396 | /** 397 | * \brief Encode datetime 398 | * 399 | * Encode a datetime representation which is a sequence of values 400 | * representing the individual components of the Date-Time. 401 | * 402 | * \param stream Output Stream 403 | * \param datetime Datetime values 404 | * \return Error-Code <> 0 405 | * 406 | */ 407 | int encodeDateTime(bitstream_t* stream, exi_datetime_t* datetime); 408 | 409 | 410 | /** 411 | * \brief Flush underlying bit output stream 412 | * 413 | * \param stream Output Stream 414 | * \return Error-Code <> 0 415 | * 416 | */ 417 | int encodeFinish(bitstream_t* stream); 418 | 419 | #ifdef __cplusplus 420 | } 421 | #endif 422 | 423 | #endif 424 | -------------------------------------------------------------------------------- /src/codec/ErrorCodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file ErrorCodes.h 34 | * \brief Error Codes descriptions 35 | * 36 | */ 37 | 38 | #ifndef EXI_ERROR_CODES_H 39 | #define EXI_ERROR_CODES_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #define EXI_ERROR_INPUT_STREAM_EOF -10 46 | #define EXI_ERROR_OUTPUT_STREAM_EOF -11 47 | #define EXI_ERROR_INPUT_FILE_HANDLE -12 48 | #define EXI_ERROR_OUTPUT_FILE -13 49 | 50 | #define EXI_ERROR_OUT_OF_BOUNDS -100 51 | #define EXI_ERROR_OUT_OF_STRING_BUFFER -101 52 | /*#define EXI_ERROR_OUT_OF_ASCII_BUFFER -102 */ 53 | #define EXI_ERROR_OUT_OF_BYTE_BUFFER -103 54 | #define EXI_ERROR_OUT_OF_GRAMMAR_STACK -104 55 | #define EXI_ERROR_OUT_OF_RUNTIME_GRAMMAR_STACK -105 56 | #define EXI_ERROR_OUT_OF_QNAMES -106 57 | 58 | #define EXI_ERROR_UNKOWN_GRAMMAR_ID -108 59 | #define EXI_ERROR_UNKOWN_EVENT -109 60 | #define EXI_ERROR_UNKOWN_EVENT_CODE -110 61 | #define EXI_ERROR_UNEXPECTED_EVENT_LEVEL1 -111 62 | #define EXI_ERROR_UNEXPECTED_EVENT_LEVEL2 -112 63 | 64 | #define EXI_ERROR_UNEXPECTED_START_DOCUMENT -113 65 | #define EXI_ERROR_UNEXPECTED_END_DOCUMENT -114 66 | #define EXI_ERROR_UNEXPECTED_START_ELEMENT -115 67 | #define EXI_ERROR_UNEXPECTED_START_ELEMENT_NS -116 68 | #define EXI_ERROR_UNEXPECTED_START_ELEMENT_GENERIC -117 69 | #define EXI_ERROR_UNEXPECTED_START_ELEMENT_GENERIC_UNDECLARED -118 70 | #define EXI_ERROR_UNEXPECTED_END_ELEMENT -119 71 | #define EXI_ERROR_UNEXPECTED_CHARACTERS -120 72 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE -121 73 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE_NS -122 74 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE_GENERIC -123 75 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE_GENERIC_UNDECLARED -124 76 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE_XSI_TYPE -125 77 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE_XSI_NIL -126 78 | #define EXI_ERROR_UNEXPECTED_GRAMMAR_ID -127 79 | #define EXI_ERROR_UNEXPECTED_ATTRIBUTE_MOVE_TO_CONTENT_RULE -128 80 | 81 | #define EXI_UNSUPPORTED_NBIT_INTEGER_LENGTH -132 82 | #define EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS -133 83 | #define EXI_UNSUPPORTED_INTEGER_VALUE -134 84 | #define EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE -135 85 | #define EXI_UNSUPPORTED_LIST_VALUE_TYPE -136 86 | #define EXI_UNSUPPORTED_HEADER_COOKIE -137 87 | #define EXI_UNSUPPORTED_HEADER_OPTIONS -138 88 | 89 | #define EXI_UNSUPPORTED_GLOBAL_ATTRIBUTE_VALUE_TYPE -139 90 | #define EXI_UNSUPPORTED_DATATYPE -140 91 | #define EXI_UNSUPPORTED_STRING_VALUE_TYPE -141 92 | #define EXI_UNSUPPORTED_INTEGER_VALUE_TYPE -142 93 | #define EXI_UNSUPPORTED_DATETIME_TYPE -143 94 | #define EXI_UNSUPPORTED_FRAGMENT_ELEMENT -144 95 | 96 | #define EXI_UNSUPPORTED_GRAMMAR_LEARNING_CH -150 97 | 98 | /* string values */ 99 | #define EXI_ERROR_STRINGVALUES_NOT_SUPPORTED -160 100 | #define EXI_ERROR_STRINGVALUES_OUT_OF_ENTRIES -161 101 | #define EXI_ERROR_STRINGVALUES_OUT_OF_MEMORY -162 102 | #define EXI_ERROR_STRINGVALUES_OUT_OF_BOUND -163 103 | #define EXI_ERROR_STRINGVALUES_CHARACTER -164 104 | 105 | #define EXI_ERROR_UNEXPECTED_BYTE_VALUE -200 106 | 107 | 108 | #define EXI_ERROR_CONVERSION_NO_ASCII_CHARACTERS -300 109 | #define EXI_ERROR_CONVERSION_TYPE_TO_STRING -301 110 | 111 | 112 | #define EXI_DEVIANT_SUPPORT_NOT_DEPLOYED -500 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | 119 | #endif /* EXI_ERROR_CODES_H */ 120 | 121 | -------------------------------------------------------------------------------- /src/codec/MethodsBag.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #ifndef METHODS_BAG_C 33 | #define METHODS_BAG_C 34 | 35 | #include "MethodsBag.h" 36 | #include "ErrorCodes.h" 37 | 38 | static const uint16_t smallLengths[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 39 | 4, 4, 4 }; 40 | 41 | int exiGetCodingLength(size_t characteristics, size_t* codingLength) { 42 | /* Note: we could use range expressions in switch statements but those are non-standard */ 43 | /* e.g., case 1 ... 5: */ 44 | int errn = 0; 45 | if (characteristics < 17) { 46 | *codingLength = smallLengths[characteristics]; 47 | } else if (characteristics < 33) { 48 | /* 17 .. 32 */ 49 | *codingLength = 5; 50 | } else if (characteristics < 65) { 51 | /* 33 .. 64 */ 52 | *codingLength = 6; 53 | } else if (characteristics < 129) { 54 | /* 65 .. 128 */ 55 | *codingLength = 7; 56 | } else if (characteristics < 257) { 57 | /* 129 .. 256 */ 58 | *codingLength = 8; 59 | } else if (characteristics < 513) { 60 | /* 257 .. 512 */ 61 | *codingLength = 9; 62 | } else if (characteristics < 1025) { 63 | /* 513 .. 1024 */ 64 | *codingLength = 10; 65 | } else if (characteristics < 2049) { 66 | /* 1025 .. 2048 */ 67 | *codingLength = 11; 68 | } else if (characteristics < 4097) { 69 | /* 2049 .. 4096 */ 70 | *codingLength = 12; 71 | } else if (characteristics < 8193) { 72 | /* 4097 .. 8192 */ 73 | *codingLength = 13; 74 | } else if (characteristics < 16385) { 75 | /* 8193 .. 16384 */ 76 | *codingLength = 14; 77 | } else if (characteristics < 32769) { 78 | /* 16385 .. 32768 */ 79 | *codingLength = 15; 80 | } else { 81 | /* 32769 .. 65536 */ 82 | *codingLength = 16; 83 | } 84 | return errn; 85 | } 86 | 87 | 88 | uint8_t numberOf7BitBlocksToRepresent(uint32_t n) { 89 | /* assert (n >= 0); */ 90 | 91 | /* 7 bits */ 92 | if (n < 128) { 93 | return 1; 94 | } 95 | /* 14 bits */ 96 | else if (n < 16384) { 97 | return 2; 98 | } 99 | /* 21 bits */ 100 | else if (n < 2097152) { 101 | return 3; 102 | } 103 | /* 28 bits */ 104 | else if (n < 268435456) { 105 | return 4; 106 | } 107 | /* 35 bits */ 108 | else { 109 | /* int, 32 bits */ 110 | return 5; 111 | } 112 | } 113 | 114 | 115 | 116 | #endif 117 | 118 | -------------------------------------------------------------------------------- /src/codec/MethodsBag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 2017-03-02 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file MethodsBag.h 34 | * \brief Method bag for bit and octet functions 35 | * 36 | */ 37 | 38 | #ifndef METHODS_BAG_H 39 | #define METHODS_BAG_H 40 | 41 | 42 | 43 | #include 44 | #include 45 | 46 | /** 47 | * \brief Returns the number of bits to identify the characteristics. 48 | * 49 | * \param characteristics number of characteristics 50 | * \param codingLength number of bits 51 | * \return Error-Code <> 0 52 | * 53 | */ 54 | int exiGetCodingLength(size_t characteristics, size_t* codingLength); 55 | 56 | 57 | /** 58 | * \brief Returns the least number of 7 bit-blocks that is needed to represent the passed integer value 59 | * 60 | * Note: Returns 1 if passed parameter is 0. 61 | * 62 | * \param n integer value 63 | * \return Error-Code <> 0 64 | * 65 | */ 66 | uint8_t numberOf7BitBlocksToRepresent(uint32_t n); 67 | 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /src/din/dinEXIDatatypesDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesDecoder.h 34 | * \brief Decoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_din_DATATYPES_DECODER_H 39 | #define EXI_din_DATATYPES_DECODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "dinEXIDatatypes.h" 46 | 47 | #if DEPLOY_DIN_CODEC == SUPPORT_YES 48 | 49 | #include 50 | 51 | #include "EXITypes.h" 52 | 53 | int decode_dinExiDocument(bitstream_t* stream, struct dinEXIDocument* exiDoc); 54 | 55 | #if DEPLOY_DIN_CODEC_FRAGMENT == SUPPORT_YES 56 | int decode_dinExiFragment(bitstream_t* stream, struct dinEXIFragment* exiFrag); 57 | #endif /* DEPLOY_DIN_CODEC_FRAGMENT */ 58 | 59 | #endif /* DEPLOY_DIN_CODEC */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/din/dinEXIDatatypesEncoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesEncoder.h 34 | * \brief Encoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_din_DATATYPES_ENCODER_H 39 | #define EXI_din_DATATYPES_ENCODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | #include "dinEXIDatatypes.h" 47 | 48 | #if DEPLOY_DIN_CODEC == SUPPORT_YES 49 | 50 | #include 51 | 52 | #include "EXITypes.h" 53 | 54 | 55 | int encode_dinExiDocument(bitstream_t* stream, struct dinEXIDocument* exiDoc); 56 | 57 | #if DEPLOY_DIN_CODEC_FRAGMENT == SUPPORT_YES 58 | int encode_dinExiFragment(bitstream_t* stream, struct dinEXIFragment* exiFrag); 59 | #endif /* DEPLOY_DIN_CODEC_FRAGMENT */ 60 | 61 | 62 | #endif /* DEPLOY_DIN_CODEC */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/iso1/iso1EXIDatatypesDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesDecoder.h 34 | * \brief Decoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_iso1_DATATYPES_DECODER_H 39 | #define EXI_iso1_DATATYPES_DECODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "iso1EXIDatatypes.h" 46 | 47 | #if DEPLOY_ISO1_CODEC == SUPPORT_YES 48 | 49 | #include 50 | 51 | #include "EXITypes.h" 52 | 53 | int decode_iso1ExiDocument(bitstream_t* stream, struct iso1EXIDocument* exiDoc); 54 | 55 | #if DEPLOY_ISO1_CODEC_FRAGMENT == SUPPORT_YES 56 | int decode_iso1ExiFragment(bitstream_t* stream, struct iso1EXIFragment* exiFrag); 57 | #endif /* DEPLOY_ISO1_CODEC_FRAGMENT */ 58 | 59 | #endif /* DEPLOY_ISO1_CODEC */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/iso1/iso1EXIDatatypesEncoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesEncoder.h 34 | * \brief Encoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_iso1_DATATYPES_ENCODER_H 39 | #define EXI_iso1_DATATYPES_ENCODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | #include "iso1EXIDatatypes.h" 47 | 48 | #if DEPLOY_ISO1_CODEC == SUPPORT_YES 49 | 50 | #include 51 | 52 | #include "EXITypes.h" 53 | 54 | 55 | int encode_iso1ExiDocument(bitstream_t* stream, struct iso1EXIDocument* exiDoc); 56 | 57 | #if DEPLOY_ISO1_CODEC_FRAGMENT == SUPPORT_YES 58 | int encode_iso1ExiFragment(bitstream_t* stream, struct iso1EXIFragment* exiFrag); 59 | #endif /* DEPLOY_ISO1_CODEC_FRAGMENT */ 60 | 61 | 62 | #endif /* DEPLOY_ISO1_CODEC */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/iso2/iso2EXIDatatypesDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesDecoder.h 34 | * \brief Decoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_iso2_DATATYPES_DECODER_H 39 | #define EXI_iso2_DATATYPES_DECODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "iso2EXIDatatypes.h" 46 | 47 | #if DEPLOY_ISO2_CODEC == SUPPORT_YES 48 | 49 | #include 50 | 51 | #include "EXITypes.h" 52 | 53 | int decode_iso2ExiDocument(bitstream_t* stream, struct iso2EXIDocument* exiDoc); 54 | 55 | #if DEPLOY_ISO2_CODEC_FRAGMENT == SUPPORT_YES 56 | int decode_iso2ExiFragment(bitstream_t* stream, struct iso2EXIFragment* exiFrag); 57 | #endif /* DEPLOY_ISO2_CODEC_FRAGMENT */ 58 | 59 | #endif /* DEPLOY_ISO2_CODEC */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/iso2/iso2EXIDatatypesEncoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesEncoder.h 34 | * \brief Encoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_iso2_DATATYPES_ENCODER_H 39 | #define EXI_iso2_DATATYPES_ENCODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | #include "iso2EXIDatatypes.h" 47 | 48 | #if DEPLOY_ISO2_CODEC == SUPPORT_YES 49 | 50 | #include 51 | 52 | #include "EXITypes.h" 53 | 54 | 55 | int encode_iso2ExiDocument(bitstream_t* stream, struct iso2EXIDocument* exiDoc); 56 | 57 | #if DEPLOY_ISO2_CODEC_FRAGMENT == SUPPORT_YES 58 | int encode_iso2ExiFragment(bitstream_t* stream, struct iso2EXIFragment* exiFrag); 59 | #endif /* DEPLOY_ISO2_CODEC_FRAGMENT */ 60 | 61 | 62 | #endif /* DEPLOY_ISO2_CODEC */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/test/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @author Sebastian.Kaebisch@siemens.com 22 | * @version 0.9.4 23 | * @contact Richard.Kuntschke@siemens.com 24 | * 25 | *

Switch for sample programs: EXI codec only or for entire V2G example

26 | * 27 | ********************************************************************/ 28 | 29 | #include 30 | #include 31 | 32 | #include "main.h" 33 | 34 | int main(int argc, char *argv[]) { 35 | /* disable buffering of output, especially when piped or redirected */ 36 | setvbuf(stdout, NULL, _IONBF, 0); 37 | 38 | #if CODE_VERSION == CODE_VERSION_EXI 39 | /* EXI codec only */ 40 | return main_databinder(argc, argv); 41 | #elif CODE_VERSION == CODE_VERSION_SAMPLE 42 | /* V2G client / service example */ 43 | return main_example(argc, argv); 44 | #endif 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/test/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @author Sebastian.Kaebisch@siemens.com 22 | * @version 0.9.4 23 | * @contact Richard.Kuntschke@siemens.com 24 | * 25 | * 26 | ********************************************************************/ 27 | 28 | 29 | #define CODE_VERSION_EXI 1 30 | #define CODE_VERSION_SAMPLE 2 31 | #define CODE_VERSION CODE_VERSION_SAMPLE 32 | 33 | #ifndef MAIN_H_ 34 | #define MAIN_H_ 35 | 36 | #if CODE_VERSION == CODE_VERSION_EXI 37 | int main_databinder(int argc, char *argv[]); 38 | #elif CODE_VERSION == CODE_VERSION_SAMPLE 39 | int main_example(int argc, char *argv[]); 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/test/main_databinder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: V2G_CI_MsgDef.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /******************************************************************* 33 | * 34 | *

Sample program to illustrate how to read an EXI stream and 35 | * directly write it again to an output

36 | * 37 | *

e.g., in.exi out.exi

38 | ********************************************************************/ 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | /* schema-dependent */ 45 | #include "iso1EXIDatatypes.h" 46 | #if DEPLOY_ISO1_CODEC == SUPPORT_YES 47 | #include "iso1EXIDatatypesEncoder.h" 48 | #include "iso1EXIDatatypesDecoder.h" 49 | #endif /* DEPLOY_ISO1_CODEC == SUPPORT_YES */ 50 | #include "iso2EXIDatatypes.h" 51 | #if DEPLOY_ISO2_CODEC == SUPPORT_YES 52 | #include "iso2EXIDatatypesEncoder.h" 53 | #include "iso2EXIDatatypesDecoder.h" 54 | #endif /* DEPLOY_ISO2_CODEC == SUPPORT_YES */ 55 | 56 | #include "ByteStream.h" 57 | 58 | /** EXI Debug mode */ 59 | #define EXI_DEBUG 0 60 | 61 | #define BUFFER_SIZE 4096 62 | uint8_t bufferIn[BUFFER_SIZE]; 63 | uint8_t bufferOut[BUFFER_SIZE]; 64 | 65 | 66 | #if EXI_DEBUG == 1 67 | # define DEBUG_PRINTF(x) printf x 68 | #else 69 | # define DEBUG_PRINTF(x) do {} while (0) 70 | #endif 71 | 72 | 73 | int main_databinder(int argc, char *argv[]) { 74 | 75 | #if DEPLOY_ISO1_CODEC == SUPPORT_YES 76 | struct iso1EXIDocument exi1Doc; 77 | #endif /* DEPLOY_ISO1_CODEC == SUPPORT_YES */ 78 | #if DEPLOY_ISO2_CODEC == SUPPORT_YES 79 | struct iso2EXIDocument exi2Doc; 80 | #endif /* DEPLOY_ISO2_CODEC == SUPPORT_YES */ 81 | int errn = 0; 82 | 83 | bitstream_t iStream, oStream; 84 | 85 | #if EXI_STREAM == BYTE_ARRAY 86 | size_t posDecode; 87 | size_t posEncode; 88 | #endif /* EXI_STREAM == BYTE_ARRAY */ 89 | 90 | 91 | #if EXI_DEBUG == 1 92 | /* The Eclipse console has buffering problems on Windows e.g, Debug mode */ 93 | setvbuf(stdout, NULL, _IONBF, 0); 94 | setvbuf(stderr, NULL, _IONBF, 0); 95 | #endif /*EXI_DEBUG*/ 96 | 97 | if (argc != 3) { 98 | printf("Usage: %s exiInput exiOutput\n", argv[0]); 99 | return -1; 100 | } 101 | 102 | #if EXI_STREAM == BYTE_ARRAY 103 | /* input pos */ 104 | posDecode = 0; 105 | /* parse EXI stream to internal byte structures */ 106 | errn = readBytesFromFile(argv[1], bufferIn, BUFFER_SIZE, &posDecode); 107 | if (errn != 0) { 108 | printf("Problems while reading file into buffer, err==%d\n", errn); 109 | return errn; 110 | } 111 | posDecode = 0; /* reset position */ 112 | #endif /* EXI_STREAM == BYTE_ARRAY */ 113 | 114 | /* setup input stream */ 115 | #if EXI_STREAM == BYTE_ARRAY 116 | iStream.size = BUFFER_SIZE; 117 | iStream.data = bufferIn; 118 | iStream.pos = &posDecode; 119 | #endif /* EXI_STREAM == BYTE_ARRAY */ 120 | 121 | iStream.buffer = 0; 122 | iStream.capacity = 0; 123 | 124 | 125 | printf("Start decoding EXI stream to databinding layer \n"); 126 | #if DEPLOY_ISO1_CODEC == SUPPORT_YES 127 | errn = decode_iso1ExiDocument(&iStream, &exi1Doc); 128 | #endif /* DEPLOY_ISO1_CODEC == SUPPORT_YES */ 129 | #if DEPLOY_ISO2_CODEC == SUPPORT_YES 130 | errn = decode_iso2ExiDocument(&iStream, &exi2Doc); 131 | #endif /* DEPLOY_ISO2_CODEC == SUPPORT_YES */ 132 | if (errn != 0) { 133 | printf("Problems while decoding EXI stream, err==%d\n", errn); 134 | return errn; 135 | } 136 | 137 | #if EXI_STREAM == BYTE_ARRAY 138 | /* setup output stream */ 139 | posEncode = 0; 140 | oStream.size = BUFFER_SIZE; 141 | oStream.data = bufferOut; 142 | oStream.pos = &posEncode; 143 | #endif 144 | 145 | oStream.buffer = 0; 146 | oStream.capacity = 8; 147 | 148 | printf("Start encoding databinding layer to EXI \n"); 149 | #if DEPLOY_ISO1_CODEC == SUPPORT_YES 150 | errn = encode_iso1ExiDocument(&oStream, &exi1Doc); 151 | #endif /* DEPLOY_ISO1_CODEC == SUPPORT_YES */ 152 | #if DEPLOY_ISO2_CODEC == SUPPORT_YES 153 | errn = encode_iso2ExiDocument(&oStream, &exi2Doc); 154 | #endif /* DEPLOY_ISO2_CODEC == SUPPORT_YES */ 155 | if (errn != 0) { 156 | printf("Problems while encoding databinding layer, err==%d\n", errn); 157 | return errn; 158 | } 159 | 160 | printf("EXI roundtrip done with success\n"); 161 | #if EXI_STREAM == BYTE_ARRAY 162 | /* write to file */ 163 | writeBytesToFile(oStream.data, posEncode, argv[2]); 164 | #endif 165 | 166 | 167 | return errn; 168 | } 169 | 170 | 171 | -------------------------------------------------------------------------------- /src/transport/v2gtp.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2007-2018 Siemens AG 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /******************************************************************* 20 | * 21 | * @author Sebastian.Kaebisch@siemens.com 22 | * @author Daniel.Peintner.EXT@siemens.com 23 | * @version 0.9.4 24 | * @contact Richard.Kuntschke@siemens.com 25 | * 26 | ********************************************************************/ 27 | 28 | /* 29 | * This file implements the v2gtp header writer and reader. 30 | * 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #include "v2gtp.h" 41 | 42 | 43 | int write_v2gtpHeader(uint8_t* outStream, uint32_t outStreamLength, uint16_t payloadType) 44 | { 45 | 46 | /* write v2gtp version number 1=byte */ 47 | outStream[0]=V2GTP_VERSION; 48 | 49 | /* write inverse v2gtp version */ 50 | outStream[1]=V2GTP_VERSION_INV; 51 | 52 | 53 | /* write payload type */ 54 | outStream[3] = (uint8_t)(payloadType & 0xFF); 55 | outStream[2] = (uint8_t)(payloadType >> 8 & 0xFF); 56 | 57 | /* write payload length */ 58 | outStream[7] = (uint8_t)(outStreamLength & 0xFF); 59 | outStream[6] = (uint8_t)(outStreamLength>>8 & 0xFF); 60 | outStream[5] = (uint8_t)(outStreamLength>>16 & 0xFF); 61 | outStream[4] = (uint8_t)(outStreamLength>>24 & 0xFF); 62 | 63 | return 0; 64 | } 65 | 66 | int read_v2gtpHeader(uint8_t* inStream, uint32_t* payloadLength) 67 | { 68 | uint16_t payloadType=0; 69 | 70 | 71 | /* check, if we support this v2gtp version */ 72 | if(inStream[0]!=V2GTP_VERSION || inStream[1]!=V2GTP_VERSION_INV) 73 | return -1; 74 | 75 | 76 | /* check, if we support this payload type*/ 77 | payloadType = inStream[2]; 78 | payloadType = (payloadType << 8 | inStream[3]); 79 | 80 | if(payloadType != V2GTP_EXI_TYPE) 81 | return -1; 82 | 83 | 84 | /* determine payload length*/ 85 | *payloadLength = inStream[4]; 86 | *payloadLength = (*payloadLength << 8 | inStream[5]); 87 | *payloadLength = (*payloadLength << 8 | inStream[6]); 88 | *payloadLength = (*payloadLength << 8 | inStream[7]); 89 | 90 | return 0; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/transport/v2gtp.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2007-2018 Siemens AG 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published 7 | * by the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /******************************************************************* 20 | * 21 | * @author Sebastian.Kaebisch@siemens.com 22 | * @author Daniel.Peintner.EXT@siemens.com 23 | * @version 0.9.4 24 | * @contact Richard.Kuntschke@siemens.com 25 | * 26 | ********************************************************************/ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #ifndef V2GTP_H_ 33 | #define V2GTP_H_ 34 | 35 | #include 36 | 37 | /* generic V2GTP header length */ 38 | #define V2GTP_HEADER_LENGTH 8 39 | 40 | /* define V2GTP Version */ 41 | #define V2GTP_VERSION 0x01 42 | #define V2GTP_VERSION_INV 0xFE 43 | 44 | /* define V2GTP payload types*/ 45 | #define V2GTP_EXI_TYPE 0x8001 46 | 47 | int write_v2gtpHeader(uint8_t* outStream, uint32_t outStreamLength, uint16_t payloadType); 48 | 49 | int read_v2gtpHeader(uint8_t* inStream, uint32_t* payloadLength); 50 | 51 | #endif /* V2GTP_H_ */ 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /src/xmldsig/xmldsigEXIDatatypes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: xmldsig-core-schema.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | #include 33 | 34 | #include "xmldsigEXIDatatypes.h" 35 | #include "EXITypes.h" 36 | 37 | 38 | #ifndef EXI_xmldsig_DATATYPES_C 39 | #define EXI_xmldsig_DATATYPES_C 40 | 41 | #if DEPLOY_XMLDSIG_CODEC == SUPPORT_YES 42 | 43 | 44 | void init_xmldsigEXIDocument(struct xmldsigEXIDocument* exiDoc) { 45 | exiDoc->SignatureProperty_isUsed = 0u; 46 | exiDoc->DSAKeyValue_isUsed = 0u; 47 | exiDoc->SignatureProperties_isUsed = 0u; 48 | exiDoc->KeyValue_isUsed = 0u; 49 | exiDoc->Transforms_isUsed = 0u; 50 | exiDoc->DigestMethod_isUsed = 0u; 51 | exiDoc->Signature_isUsed = 0u; 52 | exiDoc->RetrievalMethod_isUsed = 0u; 53 | exiDoc->Manifest_isUsed = 0u; 54 | exiDoc->Reference_isUsed = 0u; 55 | exiDoc->CanonicalizationMethod_isUsed = 0u; 56 | exiDoc->RSAKeyValue_isUsed = 0u; 57 | exiDoc->Transform_isUsed = 0u; 58 | exiDoc->PGPData_isUsed = 0u; 59 | exiDoc->MgmtData_isUsed = 0u; 60 | exiDoc->SignatureMethod_isUsed = 0u; 61 | exiDoc->KeyInfo_isUsed = 0u; 62 | exiDoc->SPKIData_isUsed = 0u; 63 | exiDoc->X509Data_isUsed = 0u; 64 | exiDoc->SignatureValue_isUsed = 0u; 65 | exiDoc->KeyName_isUsed = 0u; 66 | exiDoc->DigestValue_isUsed = 0u; 67 | exiDoc->SignedInfo_isUsed = 0u; 68 | exiDoc->Object_isUsed = 0u; 69 | } 70 | 71 | 72 | #if DEPLOY_XMLDSIG_CODEC_FRAGMENT == SUPPORT_YES 73 | void init_xmldsigEXIFragment(struct xmldsigEXIFragment* exiFrag) { 74 | exiFrag->DigestValue_isUsed = 0u; 75 | exiFrag->X509Data_isUsed = 0u; 76 | exiFrag->KeyValue_isUsed = 0u; 77 | exiFrag->DigestMethod_isUsed = 0u; 78 | exiFrag->SPKISexp_isUsed = 0u; 79 | exiFrag->Transforms_isUsed = 0u; 80 | exiFrag->KeyName_isUsed = 0u; 81 | exiFrag->X509IssuerName_isUsed = 0u; 82 | exiFrag->MgmtData_isUsed = 0u; 83 | exiFrag->Reference_isUsed = 0u; 84 | exiFrag->SignatureProperties_isUsed = 0u; 85 | exiFrag->PGPKeyID_isUsed = 0u; 86 | exiFrag->PGPData_isUsed = 0u; 87 | exiFrag->DSAKeyValue_isUsed = 0u; 88 | exiFrag->SignatureValue_isUsed = 0u; 89 | exiFrag->KeyInfo_isUsed = 0u; 90 | exiFrag->SignatureProperty_isUsed = 0u; 91 | exiFrag->PGPKeyPacket_isUsed = 0u; 92 | exiFrag->PGPKeyPacket_isUsed = 0u; 93 | exiFrag->HMACOutputLength_isUsed = 0u; 94 | exiFrag->Exponent_isUsed = 0u; 95 | exiFrag->Manifest_isUsed = 0u; 96 | exiFrag->P_isUsed = 0u; 97 | exiFrag->CanonicalizationMethod_isUsed = 0u; 98 | exiFrag->Q_isUsed = 0u; 99 | exiFrag->Seed_isUsed = 0u; 100 | exiFrag->X509SubjectName_isUsed = 0u; 101 | exiFrag->X509Certificate_isUsed = 0u; 102 | exiFrag->RSAKeyValue_isUsed = 0u; 103 | exiFrag->X509IssuerSerial_isUsed = 0u; 104 | exiFrag->SPKIData_isUsed = 0u; 105 | exiFrag->G_isUsed = 0u; 106 | exiFrag->J_isUsed = 0u; 107 | exiFrag->SignedInfo_isUsed = 0u; 108 | exiFrag->X509SKI_isUsed = 0u; 109 | exiFrag->Transform_isUsed = 0u; 110 | exiFrag->XPath_isUsed = 0u; 111 | exiFrag->Object_isUsed = 0u; 112 | exiFrag->X509SerialNumber_isUsed = 0u; 113 | exiFrag->RetrievalMethod_isUsed = 0u; 114 | exiFrag->Modulus_isUsed = 0u; 115 | exiFrag->X509CRL_isUsed = 0u; 116 | exiFrag->Signature_isUsed = 0u; 117 | exiFrag->Y_isUsed = 0u; 118 | exiFrag->SignatureMethod_isUsed = 0u; 119 | exiFrag->PgenCounter_isUsed = 0u; 120 | } 121 | #endif /* DEPLOY_XMLDSIG_CODEC_FRAGMENT */ 122 | 123 | void init_xmldsigCanonicalizationMethodType(struct xmldsigCanonicalizationMethodType* xmldsigCanonicalizationMethodType) { 124 | xmldsigCanonicalizationMethodType->ANY_isUsed = 0u; 125 | } 126 | 127 | void init_xmldsigManifestType(struct xmldsigManifestType* xmldsigManifestType) { 128 | xmldsigManifestType->Id_isUsed = 0u; 129 | xmldsigManifestType->Reference.arrayLen = 0u; 130 | } 131 | 132 | void init_xmldsigObjectType(struct xmldsigObjectType* xmldsigObjectType) { 133 | xmldsigObjectType->Id_isUsed = 0u; 134 | xmldsigObjectType->MimeType_isUsed = 0u; 135 | xmldsigObjectType->Encoding_isUsed = 0u; 136 | xmldsigObjectType->ANY_isUsed = 0u; 137 | } 138 | 139 | void init_xmldsigTransformType(struct xmldsigTransformType* xmldsigTransformType) { 140 | xmldsigTransformType->ANY_isUsed = 0u; 141 | xmldsigTransformType->XPath.arrayLen = 0u; 142 | } 143 | 144 | void init_xmldsigSignatureMethodType(struct xmldsigSignatureMethodType* xmldsigSignatureMethodType) { 145 | xmldsigSignatureMethodType->HMACOutputLength_isUsed = 0u; 146 | xmldsigSignatureMethodType->ANY_isUsed = 0u; 147 | } 148 | 149 | void init_xmldsigDigestMethodType(struct xmldsigDigestMethodType* xmldsigDigestMethodType) { 150 | xmldsigDigestMethodType->ANY_isUsed = 0u; 151 | } 152 | 153 | void init_xmldsigRetrievalMethodType(struct xmldsigRetrievalMethodType* xmldsigRetrievalMethodType) { 154 | xmldsigRetrievalMethodType->URI_isUsed = 0u; 155 | xmldsigRetrievalMethodType->Type_isUsed = 0u; 156 | xmldsigRetrievalMethodType->Transforms_isUsed = 0u; 157 | } 158 | 159 | void init_xmldsigSignatureValueType(struct xmldsigSignatureValueType* xmldsigSignatureValueType) { 160 | xmldsigSignatureValueType->Id_isUsed = 0u; 161 | } 162 | 163 | void init_xmldsigX509IssuerSerialType(struct xmldsigX509IssuerSerialType* xmldsigX509IssuerSerialType) { 164 | (void)xmldsigX509IssuerSerialType; /* avoid unused warning */ 165 | } 166 | 167 | void init_xmldsigSignedInfoType(struct xmldsigSignedInfoType* xmldsigSignedInfoType) { 168 | xmldsigSignedInfoType->Id_isUsed = 0u; 169 | xmldsigSignedInfoType->Reference.arrayLen = 0u; 170 | } 171 | 172 | void init_xmldsigSignaturePropertiesType(struct xmldsigSignaturePropertiesType* xmldsigSignaturePropertiesType) { 173 | xmldsigSignaturePropertiesType->Id_isUsed = 0u; 174 | xmldsigSignaturePropertiesType->SignatureProperty.arrayLen = 0u; 175 | } 176 | 177 | void init_xmldsigSignaturePropertyType(struct xmldsigSignaturePropertyType* xmldsigSignaturePropertyType) { 178 | xmldsigSignaturePropertyType->Id_isUsed = 0u; 179 | xmldsigSignaturePropertyType->ANY_isUsed = 0u; 180 | } 181 | 182 | void init_xmldsigKeyValueType(struct xmldsigKeyValueType* xmldsigKeyValueType) { 183 | xmldsigKeyValueType->DSAKeyValue_isUsed = 0u; 184 | xmldsigKeyValueType->RSAKeyValue_isUsed = 0u; 185 | xmldsigKeyValueType->ANY_isUsed = 0u; 186 | } 187 | 188 | void init_xmldsigRSAKeyValueType(struct xmldsigRSAKeyValueType* xmldsigRSAKeyValueType) { 189 | (void)xmldsigRSAKeyValueType; /* avoid unused warning */ 190 | } 191 | 192 | void init_xmldsigPGPDataType(struct xmldsigPGPDataType* xmldsigPGPDataType) { 193 | xmldsigPGPDataType->PGPKeyID_isUsed = 0u; 194 | xmldsigPGPDataType->PGPKeyPacket_isUsed = 0u; 195 | xmldsigPGPDataType->ANY_isUsed = 0u; 196 | } 197 | 198 | void init_xmldsigTransformsType(struct xmldsigTransformsType* xmldsigTransformsType) { 199 | xmldsigTransformsType->Transform.arrayLen = 0u; 200 | } 201 | 202 | void init_xmldsigX509DataType(struct xmldsigX509DataType* xmldsigX509DataType) { 203 | xmldsigX509DataType->X509IssuerSerial.arrayLen = 0u; 204 | xmldsigX509DataType->X509SKI.arrayLen = 0u; 205 | xmldsigX509DataType->X509SubjectName.arrayLen = 0u; 206 | xmldsigX509DataType->X509Certificate.arrayLen = 0u; 207 | xmldsigX509DataType->X509CRL.arrayLen = 0u; 208 | xmldsigX509DataType->ANY_isUsed = 0u; 209 | } 210 | 211 | void init_xmldsigSignatureType(struct xmldsigSignatureType* xmldsigSignatureType) { 212 | xmldsigSignatureType->Id_isUsed = 0u; 213 | xmldsigSignatureType->KeyInfo_isUsed = 0u; 214 | xmldsigSignatureType->Object.arrayLen = 0u; 215 | } 216 | 217 | void init_xmldsigDSAKeyValueType(struct xmldsigDSAKeyValueType* xmldsigDSAKeyValueType) { 218 | xmldsigDSAKeyValueType->P_isUsed = 0u; 219 | xmldsigDSAKeyValueType->Q_isUsed = 0u; 220 | xmldsigDSAKeyValueType->G_isUsed = 0u; 221 | xmldsigDSAKeyValueType->J_isUsed = 0u; 222 | xmldsigDSAKeyValueType->Seed_isUsed = 0u; 223 | xmldsigDSAKeyValueType->PgenCounter_isUsed = 0u; 224 | } 225 | 226 | void init_xmldsigReferenceType(struct xmldsigReferenceType* xmldsigReferenceType) { 227 | xmldsigReferenceType->Id_isUsed = 0u; 228 | xmldsigReferenceType->URI_isUsed = 0u; 229 | xmldsigReferenceType->Type_isUsed = 0u; 230 | xmldsigReferenceType->Transforms_isUsed = 0u; 231 | } 232 | 233 | void init_xmldsigSPKIDataType(struct xmldsigSPKIDataType* xmldsigSPKIDataType) { 234 | xmldsigSPKIDataType->SPKISexp.arrayLen = 0u; 235 | xmldsigSPKIDataType->ANY_isUsed = 0u; 236 | } 237 | 238 | void init_xmldsigKeyInfoType(struct xmldsigKeyInfoType* xmldsigKeyInfoType) { 239 | xmldsigKeyInfoType->Id_isUsed = 0u; 240 | xmldsigKeyInfoType->KeyName.arrayLen = 0u; 241 | xmldsigKeyInfoType->KeyValue.arrayLen = 0u; 242 | xmldsigKeyInfoType->RetrievalMethod.arrayLen = 0u; 243 | xmldsigKeyInfoType->X509Data.arrayLen = 0u; 244 | xmldsigKeyInfoType->PGPData.arrayLen = 0u; 245 | xmldsigKeyInfoType->SPKIData.arrayLen = 0u; 246 | xmldsigKeyInfoType->MgmtData.arrayLen = 0u; 247 | xmldsigKeyInfoType->ANY_isUsed = 0u; 248 | } 249 | 250 | 251 | 252 | #endif /* DEPLOY_XMLDSIG_CODEC */ 253 | 254 | #endif 255 | 256 | -------------------------------------------------------------------------------- /src/xmldsig/xmldsigEXIDatatypesDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: xmldsig-core-schema.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesDecoder.h 34 | * \brief Decoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_xmldsig_DATATYPES_DECODER_H 39 | #define EXI_xmldsig_DATATYPES_DECODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "xmldsigEXIDatatypes.h" 46 | 47 | #if DEPLOY_XMLDSIG_CODEC == SUPPORT_YES 48 | 49 | #include 50 | 51 | #include "EXITypes.h" 52 | 53 | int decode_xmldsigExiDocument(bitstream_t* stream, struct xmldsigEXIDocument* exiDoc); 54 | 55 | #if DEPLOY_XMLDSIG_CODEC_FRAGMENT == SUPPORT_YES 56 | int decode_xmldsigExiFragment(bitstream_t* stream, struct xmldsigEXIFragment* exiFrag); 57 | #endif /* DEPLOY_XMLDSIG_CODEC_FRAGMENT */ 58 | 59 | #endif /* DEPLOY_XMLDSIG_CODEC */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/xmldsig/xmldsigEXIDatatypesEncoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2018 Siemens AG 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /******************************************************************* 19 | * 20 | * @author Daniel.Peintner.EXT@siemens.com 21 | * @version 0.9.4 22 | * @contact Richard.Kuntschke@siemens.com 23 | * 24 | *

Code generated by EXIdizer

25 | *

Schema: xmldsig-core-schema.xsd

26 | * 27 | * 28 | ********************************************************************/ 29 | 30 | 31 | 32 | /** 33 | * \file EXIDatatypesEncoder.h 34 | * \brief Encoder for datatype definitions 35 | * 36 | */ 37 | 38 | #ifndef EXI_xmldsig_DATATYPES_ENCODER_H 39 | #define EXI_xmldsig_DATATYPES_ENCODER_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include "xmldsigEXIDatatypes.h" 46 | 47 | #if DEPLOY_XMLDSIG_CODEC == SUPPORT_YES 48 | 49 | #include 50 | 51 | #include "EXITypes.h" 52 | 53 | int encode_xmldsigExiDocument(bitstream_t* stream, struct xmldsigEXIDocument* exiDoc); 54 | 55 | #if DEPLOY_XMLDSIG_CODEC_FRAGMENT == SUPPORT_YES 56 | int encode_xmldsigExiFragment(bitstream_t* stream, struct xmldsigEXIFragment* exiFrag); 57 | #endif /* DEPLOY_XMLDSIG_CODEC_FRAGMENT */ 58 | 59 | 60 | #endif /* DEPLOY_XMLDSIG_CODEC */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | --------------------------------------------------------------------------------