switched to newest snapshot of jasn1 which was renamed to asn1bean

pull/19/head
Stefan Feuerhahn 6 years ago
parent e37e072144
commit d7d87c6004

@ -4,4 +4,4 @@ cd `dirname $0`
rm ../../src/main/java-gen/com/beanit/josistack/internal/acse/asn1/* rm ../../src/main/java-gen/com/beanit/josistack/internal/acse/asn1/*
jasn1-compiler -o "../../src/main/java-gen/" -p "com.beanit.josistack.internal.acse" -f iso-acse-layer.asn -dv asn1bean-compiler -o "../../src/main/java-gen/" -p "com.beanit.josistack.internal.acse" -f iso-acse-layer.asn -dv

@ -3,4 +3,4 @@
cd `dirname $0` cd `dirname $0`
rm ../../src/main/java-gen/com/beanit/josistack/internal/presentation/asn1/*.java rm ../../src/main/java-gen/com/beanit/josistack/internal/presentation/asn1/*.java
jasn1-compiler -o ../../src/main/java-gen/ -p com.beanit.josistack.internal.presentation -f iso-presentation-layer.asn -dv asn1bean-compiler -o ../../src/main/java-gen/ -p com.beanit.josistack.internal.presentation -f iso-presentation-layer.asn -dv

@ -4,4 +4,4 @@ cd `dirname $0`
rm -r ../../src/main/java-gen/com/beanit/openiec61850/internal/mms/asn1/* rm -r ../../src/main/java-gen/com/beanit/openiec61850/internal/mms/asn1/*
jasn1-compiler -o "../../src/main/java-gen" -p "com.beanit.openiec61850.internal.mms" -f mms.asn -dv asn1bean-compiler -o "../../src/main/java-gen" -p "com.beanit.openiec61850.internal.mms" -f mms.asn -dv

@ -2,4 +2,4 @@
cd `dirname $0` cd `dirname $0`
find ../../ -iname "*.java" | xargs sed -i 's/import com\.beanit\.jasn1\.ber\.types\.BerBoolean/import com\.beanit\.openiec61850\.internal\.BerBoolean/g' find ../../ -iname "*.java" | xargs sed -i 's/import com\.beanit\.asn1bean\.ber\.types\.BerBoolean/import com\.beanit\.openiec61850\.internal\.BerBoolean/g'

@ -31,7 +31,7 @@ val javaProjects: Set<Project> = allprojects
val distributionProjects = javaProjects val distributionProjects = javaProjects
val docProjects = javaProjects val docProjects = javaProjects
val repositoryProjects = javaProjects val repositoryProjects = javaProjects
val cfgModuleName = "com.beanit.jasn1" val cfgModuleName = "com.beanit.openiec61850"
tasks.register<Tar>("tar") { tasks.register<Tar>("tar") {
into(project.name) { into(project.name) {
@ -65,7 +65,7 @@ tasks.register<Tar>("tar") {
//-----java root project configurations //-----java root project configurations
dependencies { dependencies {
implementation("com.beanit:jasn1:1.11.0") implementation("com.beanit:asn1bean:1.11.4-SNAPSHOT")
implementation("com.toedter:jcalendar:1.4") implementation("com.toedter:jcalendar:1.4")
implementation("org.slf4j:slf4j-api:1.7.25") implementation("org.slf4j:slf4j-api:1.7.25")
runtimeOnly("ch.qos.logback:logback-classic:1.2.3") runtimeOnly("ch.qos.logback:logback-classic:1.2.3")
@ -78,7 +78,7 @@ tasks["jar"].withConvention(aQute.bnd.gradle.BundleTaskConvention::class) {
Bundle-Name: OpenIEC61850 Bundle-Name: OpenIEC61850
Bundle-SymbolicName: ${project.extra["cfgModuleName"]} Bundle-SymbolicName: ${project.extra["cfgModuleName"]}
-exportcontents: !*.internal.*,* -exportcontents: !*.internal.*,*
Import-Package: com.beanit.jasn1.*,javax.net,*;resolution:=optional Import-Package: com.beanit.asn1bean.*,javax.net,*;resolution:=optional
""") """)
} }
@ -138,6 +138,7 @@ configure(javaProjects) {
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal()
} }
java { java {

@ -15,7 +15,7 @@ After extracting the distribution tar file, the OpenIEC61850 library can be foun
Besides the OpenIEC61850 library the folder *build/libs-all/* contains the following external libraries: Besides the OpenIEC61850 library the folder *build/libs-all/* contains the following external libraries:
* *jasn1* - the ASN.1 BER encoding/decoding library by beanit, license: Apache 2.0, https://www.beanit.com * *asn1bean* - the ASN.1 BER encoding/decoding library by beanit, license: Apache 2.0, https://www.beanit.com
* *slf4j-api* - a popular logging API. It is only needed if openiec61850 is used to implement a server. The client part does not log anything. License: MIT, http://www.slf4j.org * *slf4j-api* - a popular logging API. It is only needed if openiec61850 is used to implement a server. The client part does not log anything. License: MIT, http://www.slf4j.org

@ -1,12 +1,12 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -16,7 +16,7 @@ public class AAREApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1); public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerBitString protocolVersion = null; private BerBitString protocolVersion = null;
private BerObjectIdentifier applicationContextName = null; private BerObjectIdentifier applicationContextName = null;
private AssociateResult result = null; private AssociateResult result = null;
@ -152,6 +152,7 @@ public class AAREApdu implements BerType, Serializable {
this.userInformation = userInformation; this.userInformation = userInformation;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -159,9 +160,7 @@ public class AAREApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -288,160 +287,174 @@ public class AAREApdu implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new BerBitString(); protocolVersion = new BerBitString();
subCodeLength += protocolVersion.decode(is, false); vByteCount += protocolVersion.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
applicationContextName = new BerObjectIdentifier(); applicationContextName = new BerObjectIdentifier();
subCodeLength += applicationContextName.decode(is, true); vByteCount += applicationContextName.decode(is, true);
subCodeLength += berTag.decode(is); vByteCount += length.readEocIfIndefinite(is);
vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
result = new AssociateResult(); result = new AssociateResult();
subCodeLength += result.decode(is, true); vByteCount += result.decode(is, true);
subCodeLength += berTag.decode(is); vByteCount += length.readEocIfIndefinite(is);
vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
resultSourceDiagnostic = new AssociateSourceDiagnostic(); resultSourceDiagnostic = new AssociateSourceDiagnostic();
subCodeLength += resultSourceDiagnostic.decode(is, null); vByteCount += resultSourceDiagnostic.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
respondingAPTitle = new APTitle(); respondingAPTitle = new APTitle();
subCodeLength += respondingAPTitle.decode(is, null); vByteCount += respondingAPTitle.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
respondingAEQualifier = new AEQualifier(); respondingAEQualifier = new AEQualifier();
subCodeLength += respondingAEQualifier.decode(is, null); vByteCount += respondingAEQualifier.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
respondingAPInvocationIdentifier = new APInvocationIdentifier(); respondingAPInvocationIdentifier = new APInvocationIdentifier();
subCodeLength += respondingAPInvocationIdentifier.decode(is, true); vByteCount += respondingAPInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
respondingAEInvocationIdentifier = new AEInvocationIdentifier(); respondingAEInvocationIdentifier = new AEInvocationIdentifier();
subCodeLength += respondingAEInvocationIdentifier.decode(is, true); vByteCount += respondingAEInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
responderAcseRequirements = new ACSERequirements(); responderAcseRequirements = new ACSERequirements();
subCodeLength += responderAcseRequirements.decode(is, false); vByteCount += responderAcseRequirements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
mechanismName = new MechanismName(); mechanismName = new MechanismName();
subCodeLength += mechanismName.decode(is, false); vByteCount += mechanismName.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
respondingAuthenticationValue = new AuthenticationValue(); respondingAuthenticationValue = new AuthenticationValue();
subCodeLength += respondingAuthenticationValue.decode(is, null); vByteCount += respondingAuthenticationValue.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) {
applicationContextNameList = new ApplicationContextNameList(); applicationContextNameList = new ApplicationContextNameList();
subCodeLength += applicationContextNameList.decode(is, false); vByteCount += applicationContextNameList.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 29)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 29)) {
implementationInformation = new ImplementationData(); implementationInformation = new ImplementationData();
subCodeLength += implementationInformation.decode(is, false); vByteCount += implementationInformation.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation(); userInformation = new AssociationInformation();
subCodeLength += userInformation.decode(is, false); vByteCount += userInformation.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -450,6 +463,7 @@ public class AAREApdu implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,12 +1,12 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -16,7 +16,7 @@ public class AARQApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 0); public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 0);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerBitString protocolVersion = null; private BerBitString protocolVersion = null;
private BerObjectIdentifier applicationContextName = null; private BerObjectIdentifier applicationContextName = null;
private APTitle calledAPTitle = null; private APTitle calledAPTitle = null;
@ -170,6 +170,7 @@ public class AARQApdu implements BerType, Serializable {
this.userInformation = userInformation; this.userInformation = userInformation;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -177,9 +178,7 @@ public class AARQApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -328,182 +327,198 @@ public class AARQApdu implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new BerBitString(); protocolVersion = new BerBitString();
subCodeLength += protocolVersion.decode(is, false); vByteCount += protocolVersion.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
applicationContextName = new BerObjectIdentifier(); applicationContextName = new BerObjectIdentifier();
subCodeLength += applicationContextName.decode(is, true); vByteCount += applicationContextName.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
calledAPTitle = new APTitle(); calledAPTitle = new APTitle();
subCodeLength += calledAPTitle.decode(is, null); vByteCount += calledAPTitle.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
calledAEQualifier = new AEQualifier(); calledAEQualifier = new AEQualifier();
subCodeLength += calledAEQualifier.decode(is, null); vByteCount += calledAEQualifier.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
calledAPInvocationIdentifier = new APInvocationIdentifier(); calledAPInvocationIdentifier = new APInvocationIdentifier();
subCodeLength += calledAPInvocationIdentifier.decode(is, true); vByteCount += calledAPInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
calledAEInvocationIdentifier = new AEInvocationIdentifier(); calledAEInvocationIdentifier = new AEInvocationIdentifier();
subCodeLength += calledAEInvocationIdentifier.decode(is, true); vByteCount += calledAEInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
callingAPTitle = new APTitle(); callingAPTitle = new APTitle();
subCodeLength += callingAPTitle.decode(is, null); vByteCount += callingAPTitle.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
callingAEQualifier = new AEQualifier(); callingAEQualifier = new AEQualifier();
subCodeLength += callingAEQualifier.decode(is, null); vByteCount += callingAEQualifier.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
callingAPInvocationIdentifier = new APInvocationIdentifier(); callingAPInvocationIdentifier = new APInvocationIdentifier();
subCodeLength += callingAPInvocationIdentifier.decode(is, true); vByteCount += callingAPInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
callingAEInvocationIdentifier = new AEInvocationIdentifier(); callingAEInvocationIdentifier = new AEInvocationIdentifier();
subCodeLength += callingAEInvocationIdentifier.decode(is, true); vByteCount += callingAEInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
senderAcseRequirements = new ACSERequirements(); senderAcseRequirements = new ACSERequirements();
subCodeLength += senderAcseRequirements.decode(is, false); vByteCount += senderAcseRequirements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) {
mechanismName = new MechanismName(); mechanismName = new MechanismName();
subCodeLength += mechanismName.decode(is, false); vByteCount += mechanismName.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
callingAuthenticationValue = new AuthenticationValue(); callingAuthenticationValue = new AuthenticationValue();
subCodeLength += callingAuthenticationValue.decode(is, null); vByteCount += callingAuthenticationValue.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
applicationContextNameList = new ApplicationContextNameList(); applicationContextNameList = new ApplicationContextNameList();
subCodeLength += applicationContextNameList.decode(is, false); vByteCount += applicationContextNameList.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 29)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 29)) {
implementationInformation = new ImplementationData(); implementationInformation = new ImplementationData();
subCodeLength += implementationInformation.decode(is, false); vByteCount += implementationInformation.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation(); userInformation = new AssociationInformation();
subCodeLength += userInformation.decode(is, false); vByteCount += userInformation.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -512,6 +527,7 @@ public class AARQApdu implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class ACSEApdu implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private AARQApdu aarq = null; private AARQApdu aarq = null;
private AAREApdu aare = null; private AAREApdu aare = null;
private RLRQApdu rlrq = null; private RLRQApdu rlrq = null;
@ -57,12 +57,11 @@ public class ACSEApdu implements BerType, Serializable {
this.rlre = rlre; this.rlre = rlre;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -90,45 +89,46 @@ public class ACSEApdu implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(AARQApdu.tag)) { if (berTag.equals(AARQApdu.tag)) {
aarq = new AARQApdu(); aarq = new AARQApdu();
codeLength += aarq.decode(is, false); tlvByteCount += aarq.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(AAREApdu.tag)) { if (berTag.equals(AAREApdu.tag)) {
aare = new AAREApdu(); aare = new AAREApdu();
codeLength += aare.decode(is, false); tlvByteCount += aare.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(RLRQApdu.tag)) { if (berTag.equals(RLRQApdu.tag)) {
rlrq = new RLRQApdu(); rlrq = new RLRQApdu();
codeLength += rlrq.decode(is, false); tlvByteCount += rlrq.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(RLREApdu.tag)) { if (berTag.equals(RLREApdu.tag)) {
rlre = new RLREApdu(); rlre = new RLREApdu();
codeLength += rlre.decode(is, false); tlvByteCount += rlre.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -141,6 +141,7 @@ public class ACSEApdu implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
public class ACSERequirements extends BerBitString { public class ACSERequirements extends BerBitString {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class AEInvocationIdentifier extends BerInteger { public class AEInvocationIdentifier extends BerInteger {

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class AEQualifier implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private AEQualifierForm2 aeQualifierForm2 = null; private AEQualifierForm2 aeQualifierForm2 = null;
public AEQualifier() {} public AEQualifier() {}
@ -30,12 +30,11 @@ public class AEQualifier implements BerType, Serializable {
this.aeQualifierForm2 = aeQualifierForm2; this.aeQualifierForm2 = aeQualifierForm2;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -48,27 +47,28 @@ public class AEQualifier implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(AEQualifierForm2.tag)) { if (berTag.equals(AEQualifierForm2.tag)) {
aeQualifierForm2 = new AEQualifierForm2(); aeQualifierForm2 = new AEQualifierForm2();
codeLength += aeQualifierForm2.decode(is, false); tlvByteCount += aeQualifierForm2.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -81,6 +81,7 @@ public class AEQualifier implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class AEQualifierForm2 extends BerInteger { public class AEQualifierForm2 extends BerInteger {

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class AETitle implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private AETitleForm2 aeTitleForm2 = null; private AETitleForm2 aeTitleForm2 = null;
public AETitle() {} public AETitle() {}
@ -30,12 +30,11 @@ public class AETitle implements BerType, Serializable {
this.aeTitleForm2 = aeTitleForm2; this.aeTitleForm2 = aeTitleForm2;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -48,27 +47,28 @@ public class AETitle implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(AETitleForm2.tag)) { if (berTag.equals(AETitleForm2.tag)) {
aeTitleForm2 = new AETitleForm2(); aeTitleForm2 = new AETitleForm2();
codeLength += aeTitleForm2.decode(is, false); tlvByteCount += aeTitleForm2.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -81,6 +81,7 @@ public class AETitle implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public class AETitleForm2 extends BerObjectIdentifier { public class AETitleForm2 extends BerObjectIdentifier {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class APInvocationIdentifier extends BerInteger { public class APInvocationIdentifier extends BerInteger {

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class APTitle implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private APTitleForm2 apTitleForm2 = null; private APTitleForm2 apTitleForm2 = null;
public APTitle() {} public APTitle() {}
@ -30,12 +30,11 @@ public class APTitle implements BerType, Serializable {
this.apTitleForm2 = apTitleForm2; this.apTitleForm2 = apTitleForm2;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -48,27 +47,28 @@ public class APTitle implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(APTitleForm2.tag)) { if (berTag.equals(APTitleForm2.tag)) {
apTitleForm2 = new APTitleForm2(); apTitleForm2 = new APTitleForm2();
codeLength += apTitleForm2.decode(is, false); tlvByteCount += apTitleForm2.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -81,6 +81,7 @@ public class APTitle implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public class APTitleForm2 extends BerObjectIdentifier { public class APTitleForm2 extends BerObjectIdentifier {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public class ApplicationContextName extends BerObjectIdentifier { public class ApplicationContextName extends BerObjectIdentifier {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,7 +17,7 @@ public class ApplicationContextNameList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<ApplicationContextName> seqOf = null; private List<ApplicationContextName> seqOf = null;
public ApplicationContextNameList() { public ApplicationContextNameList() {
@ -35,6 +35,7 @@ public class ApplicationContextNameList implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -42,9 +43,7 @@ public class ApplicationContextNameList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -65,36 +64,46 @@ public class ApplicationContextNameList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) { if (!berTag.equals(ApplicationContextName.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
ApplicationContextName element = new ApplicationContextName(); ApplicationContextName element = new ApplicationContextName();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -103,6 +112,7 @@ public class ApplicationContextNameList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class AssociateResult extends BerInteger { public class AssociateResult extends BerInteger {

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -15,7 +15,7 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerInteger acseServiceUser = null; private BerInteger acseServiceUser = null;
private BerInteger acseServiceProvider = null; private BerInteger acseServiceProvider = null;
@ -41,12 +41,11 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
this.acseServiceProvider = acseServiceProvider; this.acseServiceProvider = acseServiceProvider;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -76,35 +75,40 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
acseServiceUser = new BerInteger(); acseServiceUser = new BerInteger();
codeLength += acseServiceUser.decode(is, true); tlvByteCount += acseServiceUser.decode(is, true);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
acseServiceProvider = new BerInteger(); acseServiceProvider = new BerInteger();
codeLength += acseServiceProvider.decode(is, true); tlvByteCount += acseServiceProvider.decode(is, true);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -117,6 +121,7 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,7 +17,7 @@ public class AssociationInformation implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<Myexternal> seqOf = null; private List<Myexternal> seqOf = null;
public AssociationInformation() { public AssociationInformation() {
@ -35,6 +35,7 @@ public class AssociationInformation implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -42,9 +43,7 @@ public class AssociationInformation implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -65,36 +64,46 @@ public class AssociationInformation implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) { if (!berTag.equals(Myexternal.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
Myexternal element = new Myexternal(); Myexternal element = new Myexternal();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -103,6 +112,7 @@ public class AssociationInformation implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.types.string.BerGraphicString; import com.beanit.asn1bean.ber.types.string.BerGraphicString;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -15,7 +15,7 @@ public class AuthenticationValue implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerGraphicString charstring = null; private BerGraphicString charstring = null;
private BerBitString bitstring = null; private BerBitString bitstring = null;
private Myexternal2 external = null; private Myexternal2 external = null;
@ -50,12 +50,11 @@ public class AuthenticationValue implements BerType, Serializable {
this.external = external; this.external = external;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -87,39 +86,40 @@ public class AuthenticationValue implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
charstring = new BerGraphicString(); charstring = new BerGraphicString();
codeLength += charstring.decode(is, false); tlvByteCount += charstring.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
bitstring = new BerBitString(); bitstring = new BerBitString();
codeLength += bitstring.decode(is, false); tlvByteCount += bitstring.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
external = new Myexternal2(); external = new Myexternal2();
codeLength += external.decode(is, false); tlvByteCount += external.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -132,6 +132,7 @@ public class AuthenticationValue implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.string.BerGraphicString; import com.beanit.asn1bean.ber.types.string.BerGraphicString;
public class ImplementationData extends BerGraphicString { public class ImplementationData extends BerGraphicString {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public class MechanismName extends BerObjectIdentifier { public class MechanismName extends BerObjectIdentifier {

@ -1,15 +1,15 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerAny; import com.beanit.asn1bean.ber.types.BerAny;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -19,11 +19,10 @@ public class Myexternal implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 8); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 8);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerObjectIdentifier directReference = null; private BerObjectIdentifier directReference = null;
private BerInteger indirectReference = null; private BerInteger indirectReference = null;
private Encoding encoding = null; private Encoding encoding = null;
public Myexternal() {} public Myexternal() {}
public Myexternal(byte[] code) { public Myexternal(byte[] code) {
@ -54,6 +53,7 @@ public class Myexternal implements BerType, Serializable {
this.encoding = encoding; this.encoding = encoding;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -61,9 +61,7 @@ public class Myexternal implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -90,48 +88,59 @@ public class Myexternal implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerObjectIdentifier.tag)) { if (berTag.equals(BerObjectIdentifier.tag)) {
directReference = new BerObjectIdentifier(); directReference = new BerObjectIdentifier();
subCodeLength += directReference.decode(is, false); vByteCount += directReference.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerInteger.tag)) { if (berTag.equals(BerInteger.tag)) {
indirectReference = new BerInteger(); indirectReference = new BerInteger();
subCodeLength += indirectReference.decode(is, false); vByteCount += indirectReference.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
encoding = new Encoding(); encoding = new Encoding();
subCodeLength += encoding.decode(is, berTag); numDecodedBytes = encoding.decode(is, berTag);
if (subCodeLength == totalLength) { if (numDecodedBytes != 0) {
return codeLength; vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -140,6 +149,7 @@ public class Myexternal implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -194,7 +204,7 @@ public class Myexternal implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerAny singleASN1Type = null; private BerAny singleASN1Type = null;
private BerOctetString octetAligned = null; private BerOctetString octetAligned = null;
private BerBitString arbitrary = null; private BerBitString arbitrary = null;
@ -229,12 +239,11 @@ public class Myexternal implements BerType, Serializable {
this.arbitrary = arbitrary; this.arbitrary = arbitrary;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -270,40 +279,43 @@ public class Myexternal implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
singleASN1Type = new BerAny(); singleASN1Type = new BerAny();
codeLength += singleASN1Type.decode(is, null); tlvByteCount += singleASN1Type.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
octetAligned = new BerOctetString(); octetAligned = new BerOctetString();
codeLength += octetAligned.decode(is, false); tlvByteCount += octetAligned.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
arbitrary = new BerBitString(); arbitrary = new BerBitString();
codeLength += arbitrary.decode(is, false); tlvByteCount += arbitrary.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -316,6 +328,7 @@ public class Myexternal implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,15 +1,15 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerAny; import com.beanit.asn1bean.ber.types.BerAny;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -19,11 +19,10 @@ public class Myexternal2 implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 8); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 8);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerObjectIdentifier directReference = null; private BerObjectIdentifier directReference = null;
private BerInteger indirectReference = null; private BerInteger indirectReference = null;
private Encoding encoding = null; private Encoding encoding = null;
public Myexternal2() {} public Myexternal2() {}
public Myexternal2(byte[] code) { public Myexternal2(byte[] code) {
@ -54,6 +53,7 @@ public class Myexternal2 implements BerType, Serializable {
this.encoding = encoding; this.encoding = encoding;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -61,9 +61,7 @@ public class Myexternal2 implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -90,48 +88,59 @@ public class Myexternal2 implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerObjectIdentifier.tag)) { if (berTag.equals(BerObjectIdentifier.tag)) {
directReference = new BerObjectIdentifier(); directReference = new BerObjectIdentifier();
subCodeLength += directReference.decode(is, false); vByteCount += directReference.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerInteger.tag)) { if (berTag.equals(BerInteger.tag)) {
indirectReference = new BerInteger(); indirectReference = new BerInteger();
subCodeLength += indirectReference.decode(is, false); vByteCount += indirectReference.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
encoding = new Encoding(); encoding = new Encoding();
subCodeLength += encoding.decode(is, berTag); numDecodedBytes = encoding.decode(is, berTag);
if (subCodeLength == totalLength) { if (numDecodedBytes != 0) {
return codeLength; vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -140,6 +149,7 @@ public class Myexternal2 implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -194,7 +204,7 @@ public class Myexternal2 implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerAny singleASN1Type = null; private BerAny singleASN1Type = null;
private BerOctetString octetAligned = null; private BerOctetString octetAligned = null;
private BerBitString arbitrary = null; private BerBitString arbitrary = null;
@ -229,12 +239,11 @@ public class Myexternal2 implements BerType, Serializable {
this.arbitrary = arbitrary; this.arbitrary = arbitrary;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -270,40 +279,43 @@ public class Myexternal2 implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
singleASN1Type = new BerAny(); singleASN1Type = new BerAny();
codeLength += singleASN1Type.decode(is, null); tlvByteCount += singleASN1Type.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
octetAligned = new BerOctetString(); octetAligned = new BerOctetString();
codeLength += octetAligned.decode(is, false); tlvByteCount += octetAligned.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
arbitrary = new BerBitString(); arbitrary = new BerBitString();
codeLength += arbitrary.decode(is, false); tlvByteCount += arbitrary.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -316,6 +328,7 @@ public class Myexternal2 implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public final class OidValues { public final class OidValues {
public static final BerObjectIdentifier aCSEId = public static final BerObjectIdentifier aCSEId =

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class RLREApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 3); public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 3);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ReleaseResponseReason reason = null; private ReleaseResponseReason reason = null;
private AssociationInformation userInformation = null; private AssociationInformation userInformation = null;
@ -40,6 +40,7 @@ public class RLREApdu implements BerType, Serializable {
this.userInformation = userInformation; this.userInformation = userInformation;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class RLREApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -80,50 +79,56 @@ public class RLREApdu implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; if (lengthVal == 0) {
codeLength += totalLength; return tlByteCount;
if (totalLength == 0) {
return codeLength;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
reason = new ReleaseResponseReason(); reason = new ReleaseResponseReason();
subCodeLength += reason.decode(is, false); vByteCount += reason.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation(); userInformation = new AssociationInformation();
subCodeLength += userInformation.decode(is, false); vByteCount += userInformation.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -132,6 +137,7 @@ public class RLREApdu implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class RLRQApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 2); public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 2);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ReleaseRequestReason reason = null; private ReleaseRequestReason reason = null;
private AssociationInformation userInformation = null; private AssociationInformation userInformation = null;
@ -40,6 +40,7 @@ public class RLRQApdu implements BerType, Serializable {
this.userInformation = userInformation; this.userInformation = userInformation;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class RLRQApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -80,50 +79,56 @@ public class RLRQApdu implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; if (lengthVal == 0) {
codeLength += totalLength; return tlByteCount;
if (totalLength == 0) {
return codeLength;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
reason = new ReleaseRequestReason(); reason = new ReleaseRequestReason();
subCodeLength += reason.decode(is, false); vByteCount += reason.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation(); userInformation = new AssociationInformation();
subCodeLength += userInformation.decode(is, false); vByteCount += userInformation.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -132,6 +137,7 @@ public class RLRQApdu implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class ReleaseRequestReason extends BerInteger { public class ReleaseRequestReason extends BerInteger {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1; package com.beanit.josistack.internal.acse.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class ReleaseResponseReason extends BerInteger { public class ReleaseResponseReason extends BerInteger {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public class AbstractSyntaxName extends BerObjectIdentifier { public class AbstractSyntaxName extends BerObjectIdentifier {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,10 +14,9 @@ public class CPAPPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ModeSelector modeSelector = null; private ModeSelector modeSelector = null;
private NormalModeParameters normalModeParameters = null; private NormalModeParameters normalModeParameters = null;
public CPAPPDU() {} public CPAPPDU() {}
public CPAPPDU(byte[] code) { public CPAPPDU(byte[] code) {
@ -40,6 +39,7 @@ public class CPAPPDU implements BerType, Serializable {
this.normalModeParameters = normalModeParameters; this.normalModeParameters = normalModeParameters;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +47,7 @@ public class CPAPPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -78,43 +76,47 @@ public class CPAPPDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; while (vByteCount < lengthVal || lengthVal < 0) {
while (subCodeLength < totalLength) { vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
modeSelector = new ModeSelector(); modeSelector = new ModeSelector();
subCodeLength += modeSelector.decode(is, false); vByteCount += modeSelector.decode(is, false);
} else if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { } else if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
normalModeParameters = new NormalModeParameters(); normalModeParameters = new NormalModeParameters();
subCodeLength += normalModeParameters.decode(is, false); vByteCount += normalModeParameters.decode(is, false);
} else if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} else {
throw new IOException("Tag does not match any set component: " + berTag);
} }
} }
if (subCodeLength != totalLength) { if (vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Length of set does not match length tag, length tag: " "Length of set does not match length tag, length tag: "
+ totalLength + lengthVal
+ ", actual set length: " + ", actual set length: "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -123,6 +125,7 @@ public class CPAPPDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -163,7 +166,7 @@ public class CPAPPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ProtocolVersion protocolVersion = null; private ProtocolVersion protocolVersion = null;
private RespondingPresentationSelector respondingPresentationSelector = null; private RespondingPresentationSelector respondingPresentationSelector = null;
private PresentationContextDefinitionResultList presentationContextDefinitionResultList = null; private PresentationContextDefinitionResultList presentationContextDefinitionResultList = null;
@ -227,6 +230,7 @@ public class CPAPPDU implements BerType, Serializable {
this.userData = userData; this.userData = userData;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -234,9 +238,7 @@ public class CPAPPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -292,85 +294,98 @@ public class CPAPPDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; if (lengthVal == 0) {
codeLength += totalLength; return tlByteCount;
if (totalLength == 0) {
return codeLength;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new ProtocolVersion(); protocolVersion = new ProtocolVersion();
subCodeLength += protocolVersion.decode(is, false); vByteCount += protocolVersion.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
respondingPresentationSelector = new RespondingPresentationSelector(); respondingPresentationSelector = new RespondingPresentationSelector();
subCodeLength += respondingPresentationSelector.decode(is, false); vByteCount += respondingPresentationSelector.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
presentationContextDefinitionResultList = new PresentationContextDefinitionResultList(); presentationContextDefinitionResultList = new PresentationContextDefinitionResultList();
subCodeLength += presentationContextDefinitionResultList.decode(is, false); vByteCount += presentationContextDefinitionResultList.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
presentationRequirements = new PresentationRequirements(); presentationRequirements = new PresentationRequirements();
subCodeLength += presentationRequirements.decode(is, false); vByteCount += presentationRequirements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
userSessionRequirements = new UserSessionRequirements(); userSessionRequirements = new UserSessionRequirements();
subCodeLength += userSessionRequirements.decode(is, false); vByteCount += userSessionRequirements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
userData = new UserData(); userData = new UserData();
int choiceDecodeLength = userData.decode(is, berTag); numDecodedBytes = userData.decode(is, berTag);
subCodeLength += choiceDecodeLength; if (numDecodedBytes != 0) {
if (subCodeLength == totalLength) { vByteCount += numDecodedBytes;
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
userData = null;
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -379,6 +394,7 @@ public class CPAPPDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,10 +14,9 @@ public class CPType implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ModeSelector modeSelector = null; private ModeSelector modeSelector = null;
private NormalModeParameters normalModeParameters = null; private NormalModeParameters normalModeParameters = null;
public CPType() {} public CPType() {}
public CPType(byte[] code) { public CPType(byte[] code) {
@ -40,6 +39,7 @@ public class CPType implements BerType, Serializable {
this.normalModeParameters = normalModeParameters; this.normalModeParameters = normalModeParameters;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +47,7 @@ public class CPType implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -78,43 +76,47 @@ public class CPType implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; while (vByteCount < lengthVal || lengthVal < 0) {
while (subCodeLength < totalLength) { vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
modeSelector = new ModeSelector(); modeSelector = new ModeSelector();
subCodeLength += modeSelector.decode(is, false); vByteCount += modeSelector.decode(is, false);
} else if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { } else if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
normalModeParameters = new NormalModeParameters(); normalModeParameters = new NormalModeParameters();
subCodeLength += normalModeParameters.decode(is, false); vByteCount += normalModeParameters.decode(is, false);
} else if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} else {
throw new IOException("Tag does not match any set component: " + berTag);
} }
} }
if (subCodeLength != totalLength) { if (vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Length of set does not match length tag, length tag: " "Length of set does not match length tag, length tag: "
+ totalLength + lengthVal
+ ", actual set length: " + ", actual set length: "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -123,6 +125,7 @@ public class CPType implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -163,7 +166,7 @@ public class CPType implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ProtocolVersion protocolVersion = null; private ProtocolVersion protocolVersion = null;
private CallingPresentationSelector callingPresentationSelector = null; private CallingPresentationSelector callingPresentationSelector = null;
private CalledPresentationSelector calledPresentationSelector = null; private CalledPresentationSelector calledPresentationSelector = null;
@ -246,6 +249,7 @@ public class CPType implements BerType, Serializable {
this.userData = userData; this.userData = userData;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -253,9 +257,7 @@ public class CPType implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -325,103 +327,116 @@ public class CPType implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; if (lengthVal == 0) {
codeLength += totalLength; return tlByteCount;
if (totalLength == 0) {
return codeLength;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new ProtocolVersion(); protocolVersion = new ProtocolVersion();
subCodeLength += protocolVersion.decode(is, false); vByteCount += protocolVersion.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
callingPresentationSelector = new CallingPresentationSelector(); callingPresentationSelector = new CallingPresentationSelector();
subCodeLength += callingPresentationSelector.decode(is, false); vByteCount += callingPresentationSelector.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
calledPresentationSelector = new CalledPresentationSelector(); calledPresentationSelector = new CalledPresentationSelector();
subCodeLength += calledPresentationSelector.decode(is, false); vByteCount += calledPresentationSelector.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
presentationContextDefinitionList = new PresentationContextDefinitionList(); presentationContextDefinitionList = new PresentationContextDefinitionList();
subCodeLength += presentationContextDefinitionList.decode(is, false); vByteCount += presentationContextDefinitionList.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
defaultContextName = new DefaultContextName(); defaultContextName = new DefaultContextName();
subCodeLength += defaultContextName.decode(is, false); vByteCount += defaultContextName.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
presentationRequirements = new PresentationRequirements(); presentationRequirements = new PresentationRequirements();
subCodeLength += presentationRequirements.decode(is, false); vByteCount += presentationRequirements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
userSessionRequirements = new UserSessionRequirements(); userSessionRequirements = new UserSessionRequirements();
subCodeLength += userSessionRequirements.decode(is, false); vByteCount += userSessionRequirements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
userData = new UserData(); userData = new UserData();
int choiceDecodeLength = userData.decode(is, berTag); numDecodedBytes = userData.decode(is, berTag);
subCodeLength += choiceDecodeLength; if (numDecodedBytes != 0) {
if (subCodeLength == totalLength) { vByteCount += numDecodedBytes;
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
userData = null;
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -430,6 +445,7 @@ public class CPType implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
public class CalledPresentationSelector extends PresentationSelector { public class CalledPresentationSelector extends PresentationSelector {

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
public class CallingPresentationSelector extends PresentationSelector { public class CallingPresentationSelector extends PresentationSelector {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,9 +17,8 @@ public class ContextList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<SEQUENCE> seqOf = null; private List<SEQUENCE> seqOf = null;
public ContextList() { public ContextList() {
seqOf = new ArrayList<SEQUENCE>(); seqOf = new ArrayList<SEQUENCE>();
} }
@ -35,6 +34,7 @@ public class ContextList implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -42,9 +42,7 @@ public class ContextList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -65,36 +63,46 @@ public class ContextList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
while (subCodeLength < totalLength) { if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(SEQUENCE.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
SEQUENCE element = new SEQUENCE(); SEQUENCE element = new SEQUENCE();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -103,6 +111,7 @@ public class ContextList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -142,11 +151,10 @@ public class ContextList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private PresentationContextIdentifier presentationContextIdentifier = null; private PresentationContextIdentifier presentationContextIdentifier = null;
private AbstractSyntaxName abstractSyntaxName = null; private AbstractSyntaxName abstractSyntaxName = null;
private TransferSyntaxNameList transferSyntaxNameList = null; private TransferSyntaxNameList transferSyntaxNameList = null;
public SEQUENCE() {} public SEQUENCE() {}
public SEQUENCE(byte[] code) { public SEQUENCE(byte[] code) {
@ -178,6 +186,7 @@ public class ContextList implements BerType, Serializable {
this.transferSyntaxNameList = transferSyntaxNameList; this.transferSyntaxNameList = transferSyntaxNameList;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -185,9 +194,7 @@ public class ContextList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -210,54 +217,65 @@ public class ContextList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(PresentationContextIdentifier.tag)) { if (berTag.equals(PresentationContextIdentifier.tag)) {
presentationContextIdentifier = new PresentationContextIdentifier(); presentationContextIdentifier = new PresentationContextIdentifier();
subCodeLength += presentationContextIdentifier.decode(is, false); vByteCount += presentationContextIdentifier.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(AbstractSyntaxName.tag)) { if (berTag.equals(AbstractSyntaxName.tag)) {
abstractSyntaxName = new AbstractSyntaxName(); abstractSyntaxName = new AbstractSyntaxName();
subCodeLength += abstractSyntaxName.decode(is, false); vByteCount += abstractSyntaxName.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(TransferSyntaxNameList.tag)) { if (berTag.equals(TransferSyntaxNameList.tag)) {
transferSyntaxNameList = new TransferSyntaxNameList(); transferSyntaxNameList = new TransferSyntaxNameList();
subCodeLength += transferSyntaxNameList.decode(is, false); vByteCount += transferSyntaxNameList.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -266,6 +284,7 @@ public class ContextList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -317,7 +336,7 @@ public class ContextList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<TransferSyntaxName> seqOf = null; private List<TransferSyntaxName> seqOf = null;
public TransferSyntaxNameList() { public TransferSyntaxNameList() {
@ -335,6 +354,7 @@ public class ContextList implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -342,9 +362,7 @@ public class ContextList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -365,36 +383,46 @@ public class ContextList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (subCodeLength < totalLength) { while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(TransferSyntaxName.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
TransferSyntaxName element = new TransferSyntaxName(); TransferSyntaxName element = new TransferSyntaxName();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -404,6 +432,7 @@ public class ContextList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class DefaultContextName implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private AbstractSyntaxName abstractSyntaxName = null; private AbstractSyntaxName abstractSyntaxName = null;
private TransferSyntaxName transferSyntaxName = null; private TransferSyntaxName transferSyntaxName = null;
@ -40,6 +40,7 @@ public class DefaultContextName implements BerType, Serializable {
this.transferSyntaxName = transferSyntaxName; this.transferSyntaxName = transferSyntaxName;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class DefaultContextName implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -76,46 +75,54 @@ public class DefaultContextName implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
abstractSyntaxName = new AbstractSyntaxName(); abstractSyntaxName = new AbstractSyntaxName();
subCodeLength += abstractSyntaxName.decode(is, false); vByteCount += abstractSyntaxName.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
transferSyntaxName = new TransferSyntaxName(); transferSyntaxName = new TransferSyntaxName();
subCodeLength += transferSyntaxName.decode(is, false); vByteCount += transferSyntaxName.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -124,6 +131,7 @@ public class DefaultContextName implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,7 +17,7 @@ public class FullyEncodedData implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<PDVList> seqOf = null; private List<PDVList> seqOf = null;
public FullyEncodedData() { public FullyEncodedData() {
@ -35,6 +35,7 @@ public class FullyEncodedData implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -42,9 +43,7 @@ public class FullyEncodedData implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -65,36 +64,46 @@ public class FullyEncodedData implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) { if (!berTag.equals(PDVList.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
PDVList element = new PDVList(); PDVList element = new PDVList();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -103,6 +112,7 @@ public class FullyEncodedData implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -15,7 +15,7 @@ public class ModeSelector implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerInteger modeValue = null; private BerInteger modeValue = null;
public ModeSelector() {} public ModeSelector() {}
@ -32,6 +32,7 @@ public class ModeSelector implements BerType, Serializable {
this.modeValue = modeValue; this.modeValue = modeValue;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -39,9 +40,7 @@ public class ModeSelector implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -63,40 +62,44 @@ public class ModeSelector implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; while (vByteCount < lengthVal || lengthVal < 0) {
while (subCodeLength < totalLength) { vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
modeValue = new BerInteger(); modeValue = new BerInteger();
subCodeLength += modeValue.decode(is, false); vByteCount += modeValue.decode(is, false);
} else if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} else {
throw new IOException("Tag does not match any set component: " + berTag);
} }
} }
if (subCodeLength != totalLength) { if (vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Length of set does not match length tag, length tag: " "Length of set does not match length tag, length tag: "
+ totalLength + lengthVal
+ ", actual set length: " + ", actual set length: "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -105,6 +108,7 @@ public class ModeSelector implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,13 +1,13 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerAny; import com.beanit.asn1bean.ber.types.BerAny;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,11 +17,10 @@ public class PDVList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private TransferSyntaxName transferSyntaxName = null; private TransferSyntaxName transferSyntaxName = null;
private PresentationContextIdentifier presentationContextIdentifier = null; private PresentationContextIdentifier presentationContextIdentifier = null;
private PresentationDataValues presentationDataValues = null; private PresentationDataValues presentationDataValues = null;
public PDVList() {} public PDVList() {}
public PDVList(byte[] code) { public PDVList(byte[] code) {
@ -53,6 +52,7 @@ public class PDVList implements BerType, Serializable {
this.presentationDataValues = presentationDataValues; this.presentationDataValues = presentationDataValues;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -60,9 +60,7 @@ public class PDVList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -87,50 +85,61 @@ public class PDVList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(TransferSyntaxName.tag)) { if (berTag.equals(TransferSyntaxName.tag)) {
transferSyntaxName = new TransferSyntaxName(); transferSyntaxName = new TransferSyntaxName();
subCodeLength += transferSyntaxName.decode(is, false); vByteCount += transferSyntaxName.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(PresentationContextIdentifier.tag)) { if (berTag.equals(PresentationContextIdentifier.tag)) {
presentationContextIdentifier = new PresentationContextIdentifier(); presentationContextIdentifier = new PresentationContextIdentifier();
subCodeLength += presentationContextIdentifier.decode(is, false); vByteCount += presentationContextIdentifier.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
presentationDataValues = new PresentationDataValues(); presentationDataValues = new PresentationDataValues();
subCodeLength += presentationDataValues.decode(is, berTag); numDecodedBytes = presentationDataValues.decode(is, berTag);
if (subCodeLength == totalLength) { if (numDecodedBytes != 0) {
return codeLength; vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -139,6 +148,7 @@ public class PDVList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -192,7 +202,7 @@ public class PDVList implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerAny singleASN1Type = null; private BerAny singleASN1Type = null;
private BerOctetString octetAligned = null; private BerOctetString octetAligned = null;
private BerBitString arbitrary = null; private BerBitString arbitrary = null;
@ -227,12 +237,11 @@ public class PDVList implements BerType, Serializable {
this.arbitrary = arbitrary; this.arbitrary = arbitrary;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -268,40 +277,43 @@ public class PDVList implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
singleASN1Type = new BerAny(); singleASN1Type = new BerAny();
codeLength += singleASN1Type.decode(is, null); tlvByteCount += singleASN1Type.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
octetAligned = new BerOctetString(); octetAligned = new BerOctetString();
codeLength += octetAligned.decode(is, false); tlvByteCount += octetAligned.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
arbitrary = new BerBitString(); arbitrary = new BerBitString();
codeLength += arbitrary.decode(is, false); tlvByteCount += arbitrary.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -314,6 +326,7 @@ public class PDVList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
public class PresentationContextDefinitionList extends ContextList { public class PresentationContextDefinitionList extends ContextList {

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
public class PresentationContextDefinitionResultList extends ResultList { public class PresentationContextDefinitionResultList extends ResultList {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class PresentationContextIdentifier extends BerInteger { public class PresentationContextIdentifier extends BerInteger {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
public class PresentationRequirements extends BerBitString { public class PresentationRequirements extends BerBitString {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
public class PresentationSelector extends BerOctetString { public class PresentationSelector extends BerOctetString {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
public class ProtocolVersion extends BerBitString { public class ProtocolVersion extends BerBitString {

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
public class RespondingPresentationSelector extends PresentationSelector { public class RespondingPresentationSelector extends PresentationSelector {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class Result extends BerInteger { public class Result extends BerInteger {

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -18,9 +18,8 @@ public class ResultList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<SEQUENCE> seqOf = null; private List<SEQUENCE> seqOf = null;
public ResultList() { public ResultList() {
seqOf = new ArrayList<SEQUENCE>(); seqOf = new ArrayList<SEQUENCE>();
} }
@ -36,6 +35,7 @@ public class ResultList implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -43,9 +43,7 @@ public class ResultList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -66,36 +64,46 @@ public class ResultList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
while (subCodeLength < totalLength) { if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(SEQUENCE.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
SEQUENCE element = new SEQUENCE(); SEQUENCE element = new SEQUENCE();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -104,6 +112,7 @@ public class ResultList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -143,7 +152,7 @@ public class ResultList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Result result = null; private Result result = null;
private TransferSyntaxName transferSyntaxName = null; private TransferSyntaxName transferSyntaxName = null;
private BerInteger providerReason = null; private BerInteger providerReason = null;
@ -178,6 +187,7 @@ public class ResultList implements BerType, Serializable {
this.providerReason = providerReason; this.providerReason = providerReason;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -185,9 +195,7 @@ public class ResultList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -223,58 +231,67 @@ public class ResultList implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
result = new Result(); result = new Result();
subCodeLength += result.decode(is, false); vByteCount += result.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
transferSyntaxName = new TransferSyntaxName(); transferSyntaxName = new TransferSyntaxName();
subCodeLength += transferSyntaxName.decode(is, false); vByteCount += transferSyntaxName.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
providerReason = new BerInteger(); providerReason = new BerInteger();
subCodeLength += providerReason.decode(is, false); vByteCount += providerReason.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -283,6 +300,7 @@ public class ResultList implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
public class SimplyEncodedData extends BerOctetString { public class SimplyEncodedData extends BerOctetString {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerObjectIdentifier; import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
public class TransferSyntaxName extends BerObjectIdentifier { public class TransferSyntaxName extends BerObjectIdentifier {

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class UserData implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private SimplyEncodedData simplyEncodedData = null; private SimplyEncodedData simplyEncodedData = null;
private FullyEncodedData fullyEncodedData = null; private FullyEncodedData fullyEncodedData = null;
@ -39,12 +39,11 @@ public class UserData implements BerType, Serializable {
this.fullyEncodedData = fullyEncodedData; this.fullyEncodedData = fullyEncodedData;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -68,33 +67,34 @@ public class UserData implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.APPLICATION_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.APPLICATION_CLASS, BerTag.PRIMITIVE, 0)) {
simplyEncodedData = new SimplyEncodedData(); simplyEncodedData = new SimplyEncodedData();
codeLength += simplyEncodedData.decode(is, false); tlvByteCount += simplyEncodedData.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1)) {
fullyEncodedData = new FullyEncodedData(); fullyEncodedData = new FullyEncodedData();
codeLength += fullyEncodedData.decode(is, false); tlvByteCount += fullyEncodedData.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -107,6 +107,7 @@ public class UserData implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1; package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
public class UserSessionRequirements extends BerBitString { public class UserSessionRequirements extends BerBitString {

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class AccessResult implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private DataAccessError failure = null; private DataAccessError failure = null;
private Data success = null; private Data success = null;
@ -39,12 +39,11 @@ public class AccessResult implements BerType, Serializable {
this.success = success; this.success = success;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -65,35 +64,38 @@ public class AccessResult implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
int numDecodedBytes;
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
failure = new DataAccessError(); failure = new DataAccessError();
codeLength += failure.decode(is, false); tlvByteCount += failure.decode(is, false);
return codeLength; return tlvByteCount;
} }
success = new Data(); success = new Data();
int choiceDecodeLength = success.decode(is, berTag); numDecodedBytes = success.decode(is, berTag);
if (choiceDecodeLength != 0) { if (numDecodedBytes != 0) {
return codeLength + choiceDecodeLength; return tlvByteCount + numDecodedBytes;
} else { } else {
success = null; success = null;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -106,6 +108,7 @@ public class AccessResult implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,9 +17,8 @@ public class AlternateAccess implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<CHOICE> seqOf = null; private List<CHOICE> seqOf = null;
public AlternateAccess() { public AlternateAccess() {
seqOf = new ArrayList<CHOICE>(); seqOf = new ArrayList<CHOICE>();
} }
@ -35,6 +34,7 @@ public class AlternateAccess implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -42,9 +42,7 @@ public class AlternateAccess implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -65,36 +63,48 @@ public class AlternateAccess implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) {
CHOICE element = new CHOICE(); CHOICE element = new CHOICE();
subCodeLength += element.decode(is, null); numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -103,6 +113,7 @@ public class AlternateAccess implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -142,7 +153,7 @@ public class AlternateAccess implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private AlternateAccessSelection unnamed = null; private AlternateAccessSelection unnamed = null;
public CHOICE() {} public CHOICE() {}
@ -159,12 +170,11 @@ public class AlternateAccess implements BerType, Serializable {
this.unnamed = unnamed; this.unnamed = unnamed;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -177,29 +187,32 @@ public class AlternateAccess implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
int numDecodedBytes;
unnamed = new AlternateAccessSelection(); unnamed = new AlternateAccessSelection();
int choiceDecodeLength = unnamed.decode(is, berTag); numDecodedBytes = unnamed.decode(is, berTag);
if (choiceDecodeLength != 0) { if (numDecodedBytes != 0) {
return codeLength + choiceDecodeLength; return tlvByteCount + numDecodedBytes;
} else { } else {
unnamed = null; unnamed = null;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -212,6 +225,7 @@ public class AlternateAccess implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerNull; import com.beanit.asn1bean.ber.types.BerNull;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -15,12 +15,11 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private SelectAlternateAccess selectAlternateAccess = null; private SelectAlternateAccess selectAlternateAccess = null;
private SelectAccess selectAccess = null; private SelectAccess selectAccess = null;
public AlternateAccessSelection() {} public AlternateAccessSelection() {}
public AlternateAccessSelection(byte[] code) { public AlternateAccessSelection(byte[] code) {
this.code = code; this.code = code;
} }
@ -41,12 +40,11 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.selectAccess = selectAccess; this.selectAccess = selectAccess;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -67,35 +65,38 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
int numDecodedBytes;
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
selectAlternateAccess = new SelectAlternateAccess(); selectAlternateAccess = new SelectAlternateAccess();
codeLength += selectAlternateAccess.decode(is, false); tlvByteCount += selectAlternateAccess.decode(is, false);
return codeLength; return tlvByteCount;
} }
selectAccess = new SelectAccess(); selectAccess = new SelectAccess();
int choiceDecodeLength = selectAccess.decode(is, berTag); numDecodedBytes = selectAccess.decode(is, berTag);
if (choiceDecodeLength != 0) { if (numDecodedBytes != 0) {
return codeLength + choiceDecodeLength; return tlvByteCount + numDecodedBytes;
} else { } else {
selectAccess = null; selectAccess = null;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -108,6 +109,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -135,10 +137,9 @@ public class AlternateAccessSelection implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private AccessSelection accessSelection = null; private AccessSelection accessSelection = null;
private AlternateAccess alternateAccess = null; private AlternateAccess alternateAccess = null;
public SelectAlternateAccess() {} public SelectAlternateAccess() {}
public SelectAlternateAccess(byte[] code) { public SelectAlternateAccess(byte[] code) {
@ -161,6 +162,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.alternateAccess = alternateAccess; this.alternateAccess = alternateAccess;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -168,9 +170,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -191,42 +191,58 @@ public class AlternateAccessSelection implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
accessSelection = new AccessSelection(); accessSelection = new AccessSelection();
subCodeLength += accessSelection.decode(is, berTag); numDecodedBytes = accessSelection.decode(is, berTag);
subCodeLength += berTag.decode(is); if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(AlternateAccess.tag)) { if (berTag.equals(AlternateAccess.tag)) {
alternateAccess = new AlternateAccess(); alternateAccess = new AlternateAccess();
subCodeLength += alternateAccess.decode(is, false); vByteCount += alternateAccess.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -235,6 +251,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -277,14 +294,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Component component = null; private Component component = null;
private Unsigned32 index = null; private Unsigned32 index = null;
private IndexRange indexRange = null; private IndexRange indexRange = null;
private BerNull allElements = null; private BerNull allElements = null;
public AccessSelection() {} public AccessSelection() {}
public AccessSelection(byte[] code) { public AccessSelection(byte[] code) {
this.code = code; this.code = code;
} }
@ -321,12 +336,11 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.allElements = allElements; this.allElements = allElements;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -370,46 +384,49 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
component = new Component(); component = new Component();
codeLength += component.decode(is, null); tlvByteCount += component.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
index = new Unsigned32(); index = new Unsigned32();
codeLength += index.decode(is, false); tlvByteCount += index.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
indexRange = new IndexRange(); indexRange = new IndexRange();
codeLength += indexRange.decode(is, false); tlvByteCount += indexRange.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
allElements = new BerNull(); allElements = new BerNull();
codeLength += allElements.decode(is, false); tlvByteCount += allElements.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -423,6 +440,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -460,7 +478,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BasicIdentifier basic = null; private BasicIdentifier basic = null;
public Component() {} public Component() {}
@ -477,12 +495,11 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.basic = basic; this.basic = basic;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -495,27 +512,28 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BasicIdentifier.tag)) { if (berTag.equals(BasicIdentifier.tag)) {
basic = new BasicIdentifier(); basic = new BasicIdentifier();
codeLength += basic.decode(is, false); tlvByteCount += basic.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -529,6 +547,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -550,7 +569,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 lowIndex = null; private Unsigned32 lowIndex = null;
private Unsigned32 numberOfElements = null; private Unsigned32 numberOfElements = null;
@ -576,6 +595,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.numberOfElements = numberOfElements; this.numberOfElements = numberOfElements;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -583,9 +603,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -612,46 +630,57 @@ public class AlternateAccessSelection implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
lowIndex = new Unsigned32(); lowIndex = new Unsigned32();
subCodeLength += lowIndex.decode(is, false); vByteCount += lowIndex.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
numberOfElements = new Unsigned32(); numberOfElements = new Unsigned32();
subCodeLength += numberOfElements.decode(is, false); vByteCount += numberOfElements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -661,6 +690,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -704,14 +734,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Component component = null; private Component component = null;
private Unsigned32 index = null; private Unsigned32 index = null;
private IndexRange indexRange = null; private IndexRange indexRange = null;
private BerNull allElements = null; private BerNull allElements = null;
public SelectAccess() {} public SelectAccess() {}
public SelectAccess(byte[] code) { public SelectAccess(byte[] code) {
this.code = code; this.code = code;
} }
@ -748,12 +776,11 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.allElements = allElements; this.allElements = allElements;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -797,46 +824,49 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
component = new Component(); component = new Component();
codeLength += component.decode(is, null); tlvByteCount += component.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
index = new Unsigned32(); index = new Unsigned32();
codeLength += index.decode(is, false); tlvByteCount += index.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
indexRange = new IndexRange(); indexRange = new IndexRange();
codeLength += indexRange.decode(is, false); tlvByteCount += indexRange.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
allElements = new BerNull(); allElements = new BerNull();
codeLength += allElements.decode(is, false); tlvByteCount += allElements.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -849,6 +879,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -886,7 +917,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BasicIdentifier basic = null; private BasicIdentifier basic = null;
public Component() {} public Component() {}
@ -903,12 +934,11 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.basic = basic; this.basic = basic;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -921,27 +951,28 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BasicIdentifier.tag)) { if (berTag.equals(BasicIdentifier.tag)) {
basic = new BasicIdentifier(); basic = new BasicIdentifier();
codeLength += basic.decode(is, false); tlvByteCount += basic.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -955,6 +986,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -976,7 +1008,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 lowIndex = null; private Unsigned32 lowIndex = null;
private Unsigned32 numberOfElements = null; private Unsigned32 numberOfElements = null;
@ -1002,6 +1034,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.numberOfElements = numberOfElements; this.numberOfElements = numberOfElements;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -1009,9 +1042,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -1038,46 +1069,57 @@ public class AlternateAccessSelection implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
lowIndex = new Unsigned32(); lowIndex = new Unsigned32();
subCodeLength += lowIndex.decode(is, false); vByteCount += lowIndex.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
numberOfElements = new Unsigned32(); numberOfElements = new Unsigned32();
subCodeLength += numberOfElements.decode(is, false); vByteCount += numberOfElements.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -1087,6 +1129,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.string.BerVisibleString; import com.beanit.asn1bean.ber.types.string.BerVisibleString;
public class BasicIdentifier extends BerVisibleString { public class BasicIdentifier extends BerVisibleString {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerNull; import com.beanit.asn1bean.ber.types.BerNull;
public class ConcludeRequestPDU extends BerNull { public class ConcludeRequestPDU extends BerNull {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 invokeID = null; private Unsigned32 invokeID = null;
private Unsigned32 modifierPosition = null; private Unsigned32 modifierPosition = null;
private ServiceError serviceError = null; private ServiceError serviceError = null;
@ -49,6 +49,7 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
this.serviceError = serviceError; this.serviceError = serviceError;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -56,9 +57,7 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -92,52 +91,60 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
invokeID = new Unsigned32(); invokeID = new Unsigned32();
subCodeLength += invokeID.decode(is, false); vByteCount += invokeID.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
modifierPosition = new Unsigned32(); modifierPosition = new Unsigned32();
subCodeLength += modifierPosition.decode(is, false); vByteCount += modifierPosition.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
serviceError = new ServiceError(); serviceError = new ServiceError();
subCodeLength += serviceError.decode(is, false); vByteCount += serviceError.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -146,6 +153,7 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 invokeID = null; private Unsigned32 invokeID = null;
private ConfirmedServiceRequest service = null; private ConfirmedServiceRequest service = null;
@ -40,6 +40,7 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
this.service = service; this.service = service;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -70,44 +69,55 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(Unsigned32.tag)) { if (berTag.equals(Unsigned32.tag)) {
invokeID = new Unsigned32(); invokeID = new Unsigned32();
subCodeLength += invokeID.decode(is, false); vByteCount += invokeID.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
service = new ConfirmedServiceRequest(); service = new ConfirmedServiceRequest();
subCodeLength += service.decode(is, berTag); numDecodedBytes = service.decode(is, berTag);
if (subCodeLength == totalLength) { if (numDecodedBytes != 0) {
return codeLength; vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -116,6 +126,7 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 invokeID = null; private Unsigned32 invokeID = null;
private ConfirmedServiceResponse service = null; private ConfirmedServiceResponse service = null;
@ -40,6 +40,7 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
this.service = service; this.service = service;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -70,44 +69,55 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(Unsigned32.tag)) { if (berTag.equals(Unsigned32.tag)) {
invokeID = new Unsigned32(); invokeID = new Unsigned32();
subCodeLength += invokeID.decode(is, false); vByteCount += invokeID.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
service = new ConfirmedServiceResponse(); service = new ConfirmedServiceResponse();
subCodeLength += service.decode(is, berTag); numDecodedBytes = service.decode(is, berTag);
if (subCodeLength == totalLength) { if (numDecodedBytes != 0) {
return codeLength; vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -116,6 +126,7 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private GetNameListRequest getNameList = null; private GetNameListRequest getNameList = null;
private ReadRequest read = null; private ReadRequest read = null;
private WriteRequest write = null; private WriteRequest write = null;
@ -132,12 +132,11 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
this.fileDirectory = fileDirectory; this.fileDirectory = fileDirectory;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -252,95 +251,100 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
getNameList = new GetNameListRequest(); getNameList = new GetNameListRequest();
codeLength += getNameList.decode(is, false); tlvByteCount += getNameList.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
read = new ReadRequest(); read = new ReadRequest();
codeLength += read.decode(is, false); tlvByteCount += read.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
write = new WriteRequest(); write = new WriteRequest();
codeLength += write.decode(is, false); tlvByteCount += write.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
getVariableAccessAttributes = new GetVariableAccessAttributesRequest(); getVariableAccessAttributes = new GetVariableAccessAttributesRequest();
codeLength += getVariableAccessAttributes.decode(is, null); tlvByteCount += getVariableAccessAttributes.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) {
defineNamedVariableList = new DefineNamedVariableListRequest(); defineNamedVariableList = new DefineNamedVariableListRequest();
codeLength += defineNamedVariableList.decode(is, false); tlvByteCount += defineNamedVariableList.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
getNamedVariableListAttributes = new GetNamedVariableListAttributesRequest(); getNamedVariableListAttributes = new GetNamedVariableListAttributesRequest();
codeLength += getNamedVariableListAttributes.decode(is, null); tlvByteCount += getNamedVariableListAttributes.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
deleteNamedVariableList = new DeleteNamedVariableListRequest(); deleteNamedVariableList = new DeleteNamedVariableListRequest();
codeLength += deleteNamedVariableList.decode(is, false); tlvByteCount += deleteNamedVariableList.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 72)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 72)) {
fileOpen = new FileOpenRequest(); fileOpen = new FileOpenRequest();
codeLength += fileOpen.decode(is, false); tlvByteCount += fileOpen.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 73)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 73)) {
fileRead = new FileReadRequest(); fileRead = new FileReadRequest();
codeLength += fileRead.decode(is, false); tlvByteCount += fileRead.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 74)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 74)) {
fileClose = new FileCloseRequest(); fileClose = new FileCloseRequest();
codeLength += fileClose.decode(is, false); tlvByteCount += fileClose.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 76)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 76)) {
fileDelete = new FileDeleteRequest(); fileDelete = new FileDeleteRequest();
codeLength += fileDelete.decode(is, false); tlvByteCount += fileDelete.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 77)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 77)) {
fileDirectory = new FileDirectoryRequest(); fileDirectory = new FileDirectoryRequest();
codeLength += fileDirectory.decode(is, false); tlvByteCount += fileDirectory.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -353,6 +357,7 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,9 +1,9 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -13,7 +13,7 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private GetNameListResponse getNameList = null; private GetNameListResponse getNameList = null;
private ReadResponse read = null; private ReadResponse read = null;
private WriteResponse write = null; private WriteResponse write = null;
@ -131,12 +131,11 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
this.fileDirectory = fileDirectory; this.fileDirectory = fileDirectory;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -245,93 +244,94 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
getNameList = new GetNameListResponse(); getNameList = new GetNameListResponse();
codeLength += getNameList.decode(is, false); tlvByteCount += getNameList.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
read = new ReadResponse(); read = new ReadResponse();
codeLength += read.decode(is, false); tlvByteCount += read.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
write = new WriteResponse(); write = new WriteResponse();
codeLength += write.decode(is, false); tlvByteCount += write.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
getVariableAccessAttributes = new GetVariableAccessAttributesResponse(); getVariableAccessAttributes = new GetVariableAccessAttributesResponse();
codeLength += getVariableAccessAttributes.decode(is, false); tlvByteCount += getVariableAccessAttributes.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) {
defineNamedVariableList = new DefineNamedVariableListResponse(); defineNamedVariableList = new DefineNamedVariableListResponse();
codeLength += defineNamedVariableList.decode(is, false); tlvByteCount += defineNamedVariableList.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
getNamedVariableListAttributes = new GetNamedVariableListAttributesResponse(); getNamedVariableListAttributes = new GetNamedVariableListAttributesResponse();
codeLength += getNamedVariableListAttributes.decode(is, false); tlvByteCount += getNamedVariableListAttributes.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
deleteNamedVariableList = new DeleteNamedVariableListResponse(); deleteNamedVariableList = new DeleteNamedVariableListResponse();
codeLength += deleteNamedVariableList.decode(is, false); tlvByteCount += deleteNamedVariableList.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 72)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 72)) {
fileOpen = new FileOpenResponse(); fileOpen = new FileOpenResponse();
codeLength += fileOpen.decode(is, false); tlvByteCount += fileOpen.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 73)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 73)) {
fileRead = new FileReadResponse(); fileRead = new FileReadResponse();
codeLength += fileRead.decode(is, false); tlvByteCount += fileRead.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 74)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 74)) {
fileClose = new FileCloseResponse(); fileClose = new FileCloseResponse();
codeLength += fileClose.decode(is, false); tlvByteCount += fileClose.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 76)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 76)) {
fileDelete = new FileDeleteResponse(); fileDelete = new FileDeleteResponse();
codeLength += fileDelete.decode(is, false); tlvByteCount += fileDelete.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 77)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 77)) {
fileDirectory = new FileDirectoryResponse(); fileDirectory = new FileDirectoryResponse();
codeLength += fileDirectory.decode(is, false); tlvByteCount += fileDirectory.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -344,6 +344,7 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,14 +1,14 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString; import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.types.string.BerVisibleString; import com.beanit.asn1bean.ber.types.string.BerVisibleString;
import com.beanit.openiec61850.internal.BerBoolean; import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -22,7 +22,7 @@ public class Data implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Array array = null; private Array array = null;
private Structure structure = null; private Structure structure = null;
private BerBoolean bool = null; private BerBoolean bool = null;
@ -35,9 +35,7 @@ public class Data implements BerType, Serializable {
private TimeOfDay binaryTime = null; private TimeOfDay binaryTime = null;
private MMSString mMSString = null; private MMSString mMSString = null;
private UtcTime utcTime = null; private UtcTime utcTime = null;
public Data() {} public Data() {}
public Data(byte[] code) { public Data(byte[] code) {
this.code = code; this.code = code;
} }
@ -138,12 +136,11 @@ public class Data implements BerType, Serializable {
this.utcTime = utcTime; this.utcTime = utcTime;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -247,93 +244,94 @@ public class Data implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
array = new Array(); array = new Array();
codeLength += array.decode(is, false); tlvByteCount += array.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
structure = new Structure(); structure = new Structure();
codeLength += structure.decode(is, false); tlvByteCount += structure.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
bool = new BerBoolean(); bool = new BerBoolean();
codeLength += bool.decode(is, false); tlvByteCount += bool.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
bitString = new BerBitString(); bitString = new BerBitString();
codeLength += bitString.decode(is, false); tlvByteCount += bitString.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
integer = new BerInteger(); integer = new BerInteger();
codeLength += integer.decode(is, false); tlvByteCount += integer.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
unsigned = new BerInteger(); unsigned = new BerInteger();
codeLength += unsigned.decode(is, false); tlvByteCount += unsigned.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
floatingPoint = new FloatingPoint(); floatingPoint = new FloatingPoint();
codeLength += floatingPoint.decode(is, false); tlvByteCount += floatingPoint.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
octetString = new BerOctetString(); octetString = new BerOctetString();
codeLength += octetString.decode(is, false); tlvByteCount += octetString.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
visibleString = new BerVisibleString(); visibleString = new BerVisibleString();
codeLength += visibleString.decode(is, false); tlvByteCount += visibleString.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 12)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 12)) {
binaryTime = new TimeOfDay(); binaryTime = new TimeOfDay();
codeLength += binaryTime.decode(is, false); tlvByteCount += binaryTime.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 16)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 16)) {
mMSString = new MMSString(); mMSString = new MMSString();
codeLength += mMSString.decode(is, false); tlvByteCount += mMSString.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 17)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 17)) {
utcTime = new UtcTime(); utcTime = new UtcTime();
codeLength += utcTime.decode(is, false); tlvByteCount += utcTime.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -346,6 +344,7 @@ public class Data implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -423,7 +422,7 @@ public class Data implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<Data> seqOf = null; private List<Data> seqOf = null;
public Array() { public Array() {
@ -441,6 +440,7 @@ public class Data implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -448,9 +448,7 @@ public class Data implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -471,36 +469,48 @@ public class Data implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) {
Data element = new Data(); Data element = new Data();
subCodeLength += element.decode(is, null); numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -509,6 +519,7 @@ public class Data implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -549,7 +560,7 @@ public class Data implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<Data> seqOf = null; private List<Data> seqOf = null;
public Structure() { public Structure() {
@ -567,6 +578,7 @@ public class Data implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -574,9 +586,7 @@ public class Data implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -597,36 +607,48 @@ public class Data implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) {
Data element = new Data(); Data element = new Data();
subCodeLength += element.decode(is, null); numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -635,6 +657,7 @@ public class Data implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class DataAccessError extends BerInteger { public class DataAccessError extends BerInteger {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class DefineNamedVariableListRequest implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ObjectName variableListName = null; private ObjectName variableListName = null;
private VariableDefs listOfVariable = null; private VariableDefs listOfVariable = null;
@ -40,6 +40,7 @@ public class DefineNamedVariableListRequest implements BerType, Serializable {
this.listOfVariable = listOfVariable; this.listOfVariable = listOfVariable;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class DefineNamedVariableListRequest implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -73,42 +72,55 @@ public class DefineNamedVariableListRequest implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
variableListName = new ObjectName(); variableListName = new ObjectName();
subCodeLength += variableListName.decode(is, berTag); numDecodedBytes = variableListName.decode(is, berTag);
subCodeLength += berTag.decode(is); if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
listOfVariable = new VariableDefs(); listOfVariable = new VariableDefs();
subCodeLength += listOfVariable.decode(is, false); vByteCount += listOfVariable.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -117,6 +129,7 @@ public class DefineNamedVariableListRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerNull; import com.beanit.asn1bean.ber.types.BerNull;
public class DefineNamedVariableListResponse extends BerNull { public class DefineNamedVariableListResponse extends BerNull {

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -18,13 +18,11 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerInteger scopeOfDelete = null; private BerInteger scopeOfDelete = null;
private ListOfVariableListName listOfVariableListName = null; private ListOfVariableListName listOfVariableListName = null;
private DomainName domainName = null; private DomainName domainName = null;
public DeleteNamedVariableListRequest() {} public DeleteNamedVariableListRequest() {}
public DeleteNamedVariableListRequest(byte[] code) { public DeleteNamedVariableListRequest(byte[] code) {
this.code = code; this.code = code;
} }
@ -53,6 +51,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
this.domainName = domainName; this.domainName = domainName;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -60,9 +59,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -104,60 +101,67 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; if (lengthVal == 0) {
codeLength += totalLength; return tlByteCount;
if (totalLength == 0) {
return codeLength;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
scopeOfDelete = new BerInteger(); scopeOfDelete = new BerInteger();
subCodeLength += scopeOfDelete.decode(is, false); vByteCount += scopeOfDelete.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
listOfVariableListName = new ListOfVariableListName(); listOfVariableListName = new ListOfVariableListName();
subCodeLength += listOfVariableListName.decode(is, false); vByteCount += listOfVariableListName.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
domainName = new DomainName(); domainName = new DomainName();
subCodeLength += domainName.decode(is, null); vByteCount += domainName.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -166,6 +170,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -220,7 +225,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<ObjectName> seqOf = null; private List<ObjectName> seqOf = null;
public ListOfVariableListName() { public ListOfVariableListName() {
@ -238,6 +243,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -245,9 +251,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -268,36 +272,48 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) {
ObjectName element = new ObjectName(); ObjectName element = new ObjectName();
subCodeLength += element.decode(is, null); numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -306,6 +322,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -346,7 +363,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BasicIdentifier basic = null; private BasicIdentifier basic = null;
public DomainName() {} public DomainName() {}
@ -363,12 +380,11 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
this.basic = basic; this.basic = basic;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -381,27 +397,28 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BasicIdentifier.tag)) { if (berTag.equals(BasicIdentifier.tag)) {
basic = new BasicIdentifier(); basic = new BasicIdentifier();
codeLength += basic.decode(is, false); tlvByteCount += basic.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -414,6 +431,7 @@ public class DeleteNamedVariableListRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class DeleteNamedVariableListResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 numberMatched = null; private Unsigned32 numberMatched = null;
private Unsigned32 numberDeleted = null; private Unsigned32 numberDeleted = null;
@ -40,6 +40,7 @@ public class DeleteNamedVariableListResponse implements BerType, Serializable {
this.numberDeleted = numberDeleted; this.numberDeleted = numberDeleted;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class DeleteNamedVariableListResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -76,46 +75,54 @@ public class DeleteNamedVariableListResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
numberMatched = new Unsigned32(); numberMatched = new Unsigned32();
subCodeLength += numberMatched.decode(is, false); vByteCount += numberMatched.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
numberDeleted = new Unsigned32(); numberDeleted = new Unsigned32();
subCodeLength += numberDeleted.decode(is, false); vByteCount += numberDeleted.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -124,6 +131,7 @@ public class DeleteNamedVariableListResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class DirectoryEntry implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private FileName fileName = null; private FileName fileName = null;
private FileAttributes fileAttributes = null; private FileAttributes fileAttributes = null;
@ -40,6 +40,7 @@ public class DirectoryEntry implements BerType, Serializable {
this.fileAttributes = fileAttributes; this.fileAttributes = fileAttributes;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class DirectoryEntry implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -76,46 +75,54 @@ public class DirectoryEntry implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
fileName = new FileName(); fileName = new FileName();
subCodeLength += fileName.decode(is, false); vByteCount += fileName.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
fileAttributes = new FileAttributes(); fileAttributes = new FileAttributes();
subCodeLength += fileAttributes.decode(is, false); vByteCount += fileAttributes.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -124,6 +131,7 @@ public class DirectoryEntry implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerGeneralizedTime; import com.beanit.asn1bean.ber.types.BerGeneralizedTime;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -15,7 +15,7 @@ public class FileAttributes implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Unsigned32 sizeOfFile = null; private Unsigned32 sizeOfFile = null;
private BerGeneralizedTime lastModified = null; private BerGeneralizedTime lastModified = null;
@ -41,6 +41,7 @@ public class FileAttributes implements BerType, Serializable {
this.lastModified = lastModified; this.lastModified = lastModified;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -48,9 +49,7 @@ public class FileAttributes implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -79,49 +78,55 @@ public class FileAttributes implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
sizeOfFile = new Unsigned32(); sizeOfFile = new Unsigned32();
subCodeLength += sizeOfFile.decode(is, false); vByteCount += sizeOfFile.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
lastModified = new BerGeneralizedTime(); lastModified = new BerGeneralizedTime();
subCodeLength += lastModified.decode(is, false); vByteCount += lastModified.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -130,6 +135,7 @@ public class FileAttributes implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import java.math.BigInteger; import java.math.BigInteger;

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerNull; import com.beanit.asn1bean.ber.types.BerNull;
public class FileCloseResponse extends BerNull { public class FileCloseResponse extends BerNull {

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
public class FileDeleteRequest extends FileName { public class FileDeleteRequest extends FileName {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerNull; import com.beanit.asn1bean.ber.types.BerNull;
public class FileDeleteResponse extends BerNull { public class FileDeleteResponse extends BerNull {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class FileDirectoryRequest implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private FileName fileSpecification = null; private FileName fileSpecification = null;
private FileName continueAfter = null; private FileName continueAfter = null;
@ -40,6 +40,7 @@ public class FileDirectoryRequest implements BerType, Serializable {
this.continueAfter = continueAfter; this.continueAfter = continueAfter;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class FileDirectoryRequest implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -80,50 +79,56 @@ public class FileDirectoryRequest implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; if (lengthVal == 0) {
codeLength += totalLength; return tlByteCount;
if (totalLength == 0) {
return codeLength;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
fileSpecification = new FileName(); fileSpecification = new FileName();
subCodeLength += fileSpecification.decode(is, false); vByteCount += fileSpecification.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
continueAfter = new FileName(); continueAfter = new FileName();
subCodeLength += continueAfter.decode(is, false); vByteCount += continueAfter.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -132,6 +137,7 @@ public class FileDirectoryRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.openiec61850.internal.BerBoolean; import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -18,10 +18,9 @@ public class FileDirectoryResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ListOfDirectoryEntry listOfDirectoryEntry = null; private ListOfDirectoryEntry listOfDirectoryEntry = null;
private BerBoolean moreFollows = null; private BerBoolean moreFollows = null;
public FileDirectoryResponse() {} public FileDirectoryResponse() {}
public FileDirectoryResponse(byte[] code) { public FileDirectoryResponse(byte[] code) {
@ -44,6 +43,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
this.moreFollows = moreFollows; this.moreFollows = moreFollows;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -51,9 +51,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -86,50 +84,57 @@ public class FileDirectoryResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
listOfDirectoryEntry = new ListOfDirectoryEntry(); listOfDirectoryEntry = new ListOfDirectoryEntry();
subCodeLength += listOfDirectoryEntry.decode(is, true); vByteCount += listOfDirectoryEntry.decode(is, true);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
moreFollows = new BerBoolean(); moreFollows = new BerBoolean();
subCodeLength += moreFollows.decode(is, false); vByteCount += moreFollows.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -138,6 +143,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -177,7 +183,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<DirectoryEntry> seqOf = null; private List<DirectoryEntry> seqOf = null;
public ListOfDirectoryEntry() { public ListOfDirectoryEntry() {
@ -195,6 +201,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -202,9 +209,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -225,36 +230,46 @@ public class FileDirectoryResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) { if (!berTag.equals(DirectoryEntry.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
DirectoryEntry element = new DirectoryEntry(); DirectoryEntry element = new DirectoryEntry();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -263,6 +278,7 @@ public class FileDirectoryResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.types.string.BerGraphicString; import com.beanit.asn1bean.ber.types.string.BerGraphicString;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -18,7 +18,7 @@ public class FileName implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<BerGraphicString> seqOf = null; private List<BerGraphicString> seqOf = null;
public FileName() { public FileName() {
@ -36,6 +36,7 @@ public class FileName implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -43,9 +44,7 @@ public class FileName implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -66,36 +65,46 @@ public class FileName implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) { if (!berTag.equals(BerGraphicString.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
BerGraphicString element = new BerGraphicString(); BerGraphicString element = new BerGraphicString();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -104,6 +113,7 @@ public class FileName implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class FileOpenRequest implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private FileName fileName = null; private FileName fileName = null;
private Unsigned32 initialPosition = null; private Unsigned32 initialPosition = null;
@ -40,6 +40,7 @@ public class FileOpenRequest implements BerType, Serializable {
this.initialPosition = initialPosition; this.initialPosition = initialPosition;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class FileOpenRequest implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -76,46 +75,54 @@ public class FileOpenRequest implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
fileName = new FileName(); fileName = new FileName();
subCodeLength += fileName.decode(is, false); vByteCount += fileName.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
initialPosition = new Unsigned32(); initialPosition = new Unsigned32();
subCodeLength += initialPosition.decode(is, false); vByteCount += initialPosition.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -124,6 +131,7 @@ public class FileOpenRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class FileOpenResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Integer32 frsmID = null; private Integer32 frsmID = null;
private FileAttributes fileAttributes = null; private FileAttributes fileAttributes = null;
@ -40,6 +40,7 @@ public class FileOpenResponse implements BerType, Serializable {
this.fileAttributes = fileAttributes; this.fileAttributes = fileAttributes;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -47,9 +48,7 @@ public class FileOpenResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -76,46 +75,54 @@ public class FileOpenResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
frsmID = new Integer32(); frsmID = new Integer32();
subCodeLength += frsmID.decode(is, false); vByteCount += frsmID.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
fileAttributes = new FileAttributes(); fileAttributes = new FileAttributes();
subCodeLength += fileAttributes.decode(is, false); vByteCount += fileAttributes.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -124,6 +131,7 @@ public class FileOpenResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import java.math.BigInteger; import java.math.BigInteger;

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.openiec61850.internal.BerBoolean; import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -16,7 +16,7 @@ public class FileReadResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerOctetString fileData = null; private BerOctetString fileData = null;
private BerBoolean moreFollows = null; private BerBoolean moreFollows = null;
@ -42,6 +42,7 @@ public class FileReadResponse implements BerType, Serializable {
this.moreFollows = moreFollows; this.moreFollows = moreFollows;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -49,9 +50,7 @@ public class FileReadResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -80,49 +79,55 @@ public class FileReadResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
fileData = new BerOctetString(); fileData = new BerOctetString();
subCodeLength += fileData.decode(is, false); vByteCount += fileData.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
moreFollows = new BerBoolean(); moreFollows = new BerBoolean();
subCodeLength += moreFollows.decode(is, false); vByteCount += moreFollows.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -131,6 +136,7 @@ public class FileReadResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerOctetString; import com.beanit.asn1bean.ber.types.BerOctetString;
public class FloatingPoint extends BerOctetString { public class FloatingPoint extends BerOctetString {

@ -1,11 +1,11 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerNull; import com.beanit.asn1bean.ber.types.BerNull;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -15,11 +15,10 @@ public class GetNameListRequest implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ObjectClass objectClass = null; private ObjectClass objectClass = null;
private ObjectScope objectScope = null; private ObjectScope objectScope = null;
private Identifier continueAfter = null; private Identifier continueAfter = null;
public GetNameListRequest() {} public GetNameListRequest() {}
public GetNameListRequest(byte[] code) { public GetNameListRequest(byte[] code) {
@ -50,6 +49,7 @@ public class GetNameListRequest implements BerType, Serializable {
this.continueAfter = continueAfter; this.continueAfter = continueAfter;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -57,9 +57,7 @@ public class GetNameListRequest implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -99,59 +97,67 @@ public class GetNameListRequest implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
objectClass = new ObjectClass(); objectClass = new ObjectClass();
subCodeLength += objectClass.decode(is, null); vByteCount += objectClass.decode(is, null);
subCodeLength += berTag.decode(is); vByteCount += length.readEocIfIndefinite(is);
vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
objectScope = new ObjectScope(); objectScope = new ObjectScope();
subCodeLength += objectScope.decode(is, null); vByteCount += objectScope.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
continueAfter = new Identifier(); continueAfter = new Identifier();
subCodeLength += continueAfter.decode(is, false); vByteCount += continueAfter.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -160,6 +166,7 @@ public class GetNameListRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -210,7 +217,7 @@ public class GetNameListRequest implements BerType, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerNull vmdSpecific = null; private BerNull vmdSpecific = null;
private Identifier domainSpecific = null; private Identifier domainSpecific = null;
private BerNull aaSpecific = null; private BerNull aaSpecific = null;
@ -245,12 +252,11 @@ public class GetNameListRequest implements BerType, Serializable {
this.aaSpecific = aaSpecific; this.aaSpecific = aaSpecific;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -282,39 +288,40 @@ public class GetNameListRequest implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
vmdSpecific = new BerNull(); vmdSpecific = new BerNull();
codeLength += vmdSpecific.decode(is, false); tlvByteCount += vmdSpecific.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
domainSpecific = new Identifier(); domainSpecific = new Identifier();
codeLength += domainSpecific.decode(is, false); tlvByteCount += domainSpecific.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
aaSpecific = new BerNull(); aaSpecific = new BerNull();
codeLength += aaSpecific.decode(is, false); tlvByteCount += aaSpecific.decode(is, false);
return codeLength; return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -327,6 +334,7 @@ public class GetNameListRequest implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.openiec61850.internal.BerBoolean; import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -18,10 +18,9 @@ public class GetNameListResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ListOfIdentifier listOfIdentifier = null; private ListOfIdentifier listOfIdentifier = null;
private BerBoolean moreFollows = null; private BerBoolean moreFollows = null;
public GetNameListResponse() {} public GetNameListResponse() {}
public GetNameListResponse(byte[] code) { public GetNameListResponse(byte[] code) {
@ -44,6 +43,7 @@ public class GetNameListResponse implements BerType, Serializable {
this.moreFollows = moreFollows; this.moreFollows = moreFollows;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -51,9 +51,7 @@ public class GetNameListResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -82,49 +80,55 @@ public class GetNameListResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
int totalLength = length.val; vByteCount += berTag.decode(is);
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
listOfIdentifier = new ListOfIdentifier(); listOfIdentifier = new ListOfIdentifier();
subCodeLength += listOfIdentifier.decode(is, false); vByteCount += listOfIdentifier.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
moreFollows = new BerBoolean(); moreFollows = new BerBoolean();
subCodeLength += moreFollows.decode(is, false); vByteCount += moreFollows.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -133,6 +137,7 @@ public class GetNameListResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -172,7 +177,7 @@ public class GetNameListResponse implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<Identifier> seqOf = null; private List<Identifier> seqOf = null;
public ListOfIdentifier() { public ListOfIdentifier() {
@ -190,6 +195,7 @@ public class GetNameListResponse implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -197,9 +203,7 @@ public class GetNameListResponse implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -220,36 +224,46 @@ public class GetNameListResponse implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) { if (!berTag.equals(Identifier.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
Identifier element = new Identifier(); Identifier element = new Identifier();
subCodeLength += element.decode(is, true); vByteCount += element.decode(is, false);
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -258,6 +272,7 @@ public class GetNameListResponse implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
public class GetNamedVariableListAttributesRequest extends ObjectName { public class GetNamedVariableListAttributesRequest extends ObjectName {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.openiec61850.internal.BerBoolean; import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -15,7 +15,7 @@ public class GetNamedVariableListAttributesResponse implements BerType, Serializ
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerBoolean mmsDeletable = null; private BerBoolean mmsDeletable = null;
private VariableDefs listOfVariable = null; private VariableDefs listOfVariable = null;
@ -41,6 +41,7 @@ public class GetNamedVariableListAttributesResponse implements BerType, Serializ
this.listOfVariable = listOfVariable; this.listOfVariable = listOfVariable;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -48,9 +49,7 @@ public class GetNamedVariableListAttributesResponse implements BerType, Serializ
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -77,46 +76,54 @@ public class GetNamedVariableListAttributesResponse implements BerType, Serializ
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
mmsDeletable = new BerBoolean(); mmsDeletable = new BerBoolean();
subCodeLength += mmsDeletable.decode(is, false); vByteCount += mmsDeletable.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
listOfVariable = new VariableDefs(); listOfVariable = new VariableDefs();
subCodeLength += listOfVariable.decode(is, false); vByteCount += listOfVariable.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -125,6 +132,7 @@ public class GetNamedVariableListAttributesResponse implements BerType, Serializ
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,7 +14,7 @@ public class GetVariableAccessAttributesRequest implements BerType, Serializable
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private ObjectName name = null; private ObjectName name = null;
public GetVariableAccessAttributesRequest() {} public GetVariableAccessAttributesRequest() {}
@ -31,12 +31,11 @@ public class GetVariableAccessAttributesRequest implements BerType, Serializable
this.name = name; this.name = name;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
return code.length; return code.length;
} }
@ -56,28 +55,31 @@ public class GetVariableAccessAttributesRequest implements BerType, Serializable
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected."); throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, null); return decode(is, null);
} }
public int decode(InputStream is, BerTag berTag) throws IOException { public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0; int tlvByteCount = 0;
BerTag passedTag = berTag; boolean tagWasPassed = (berTag != null);
if (berTag == null) { if (berTag == null) {
berTag = new BerTag(); berTag = new BerTag();
codeLength += berTag.decode(is); tlvByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
codeLength += BerLength.skip(is); BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
name = new ObjectName(); name = new ObjectName();
codeLength += name.decode(is, null); tlvByteCount += name.decode(is, null);
return codeLength; tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
} }
if (passedTag != null) { if (tagWasPassed) {
return 0; return 0;
} }
@ -90,6 +92,7 @@ public class GetVariableAccessAttributesRequest implements BerType, Serializable
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.openiec61850.internal.BerBoolean; import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -15,7 +15,7 @@ public class GetVariableAccessAttributesResponse implements BerType, Serializabl
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private BerBoolean mmsDeletable = null; private BerBoolean mmsDeletable = null;
private TypeDescription typeDescription = null; private TypeDescription typeDescription = null;
@ -41,6 +41,7 @@ public class GetVariableAccessAttributesResponse implements BerType, Serializabl
this.typeDescription = typeDescription; this.typeDescription = typeDescription;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -48,9 +49,7 @@ public class GetVariableAccessAttributesResponse implements BerType, Serializabl
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -81,47 +80,56 @@ public class GetVariableAccessAttributesResponse implements BerType, Serializabl
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
mmsDeletable = new BerBoolean(); mmsDeletable = new BerBoolean();
subCodeLength += mmsDeletable.decode(is, false); vByteCount += mmsDeletable.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
subCodeLength += length.decode(is); vByteCount += length.decode(is);
typeDescription = new TypeDescription(); typeDescription = new TypeDescription();
subCodeLength += typeDescription.decode(is, null); vByteCount += typeDescription.decode(is, null);
if (subCodeLength == totalLength) { vByteCount += length.readEocIfIndefinite(is);
return codeLength; if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -130,6 +138,7 @@ public class GetVariableAccessAttributesResponse implements BerType, Serializabl
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.string.BerVisibleString; import com.beanit.asn1bean.ber.types.string.BerVisibleString;
public class Identifier extends BerVisibleString { public class Identifier extends BerVisibleString {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,10 +17,9 @@ public class InformationReport implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private VariableAccessSpecification variableAccessSpecification = null; private VariableAccessSpecification variableAccessSpecification = null;
private ListOfAccessResult listOfAccessResult = null; private ListOfAccessResult listOfAccessResult = null;
public InformationReport() {} public InformationReport() {}
public InformationReport(byte[] code) { public InformationReport(byte[] code) {
@ -44,6 +43,7 @@ public class InformationReport implements BerType, Serializable {
this.listOfAccessResult = listOfAccessResult; this.listOfAccessResult = listOfAccessResult;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -51,9 +51,7 @@ public class InformationReport implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -77,42 +75,55 @@ public class InformationReport implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
variableAccessSpecification = new VariableAccessSpecification(); variableAccessSpecification = new VariableAccessSpecification();
subCodeLength += variableAccessSpecification.decode(is, berTag); numDecodedBytes = variableAccessSpecification.decode(is, berTag);
subCodeLength += berTag.decode(is); if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
listOfAccessResult = new ListOfAccessResult(); listOfAccessResult = new ListOfAccessResult();
subCodeLength += listOfAccessResult.decode(is, false); vByteCount += listOfAccessResult.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -121,6 +132,7 @@ public class InformationReport implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -163,7 +175,7 @@ public class InformationReport implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private List<AccessResult> seqOf = null; private List<AccessResult> seqOf = null;
public ListOfAccessResult() { public ListOfAccessResult() {
@ -181,6 +193,7 @@ public class InformationReport implements BerType, Serializable {
return seqOf; return seqOf;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -188,9 +201,7 @@ public class InformationReport implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -211,36 +222,48 @@ public class InformationReport implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int totalLength = length.val; int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
while (subCodeLength < totalLength) {
AccessResult element = new AccessResult(); AccessResult element = new AccessResult();
subCodeLength += element.decode(is, null); numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
seqOf.add(element); seqOf.add(element);
} }
if (subCodeLength != totalLength) { if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException( throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected " "Decoded SequenceOf or SetOf has wrong length. Expected "
+ totalLength + lengthVal
+ " but has " + " but has "
+ subCodeLength); + vByteCount);
} }
codeLength += subCodeLength; return tlByteCount + vByteCount;
return codeLength;
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -249,6 +272,7 @@ public class InformationReport implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,4 +1,4 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
public class InitiateErrorPDU extends ServiceError { public class InitiateErrorPDU extends ServiceError {

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,13 +14,12 @@ public class InitiateRequestPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Integer32 localDetailCalling = null; private Integer32 localDetailCalling = null;
private Integer16 proposedMaxServOutstandingCalling = null; private Integer16 proposedMaxServOutstandingCalling = null;
private Integer16 proposedMaxServOutstandingCalled = null; private Integer16 proposedMaxServOutstandingCalled = null;
private Integer8 proposedDataStructureNestingLevel = null; private Integer8 proposedDataStructureNestingLevel = null;
private InitRequestDetail initRequestDetail = null; private InitRequestDetail initRequestDetail = null;
public InitiateRequestPDU() {} public InitiateRequestPDU() {}
public InitiateRequestPDU(byte[] code) { public InitiateRequestPDU(byte[] code) {
@ -67,6 +66,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
this.initRequestDetail = initRequestDetail; this.initRequestDetail = initRequestDetail;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -74,9 +74,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -122,66 +120,74 @@ public class InitiateRequestPDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
localDetailCalling = new Integer32(); localDetailCalling = new Integer32();
subCodeLength += localDetailCalling.decode(is, false); vByteCount += localDetailCalling.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
proposedMaxServOutstandingCalling = new Integer16(); proposedMaxServOutstandingCalling = new Integer16();
subCodeLength += proposedMaxServOutstandingCalling.decode(is, false); vByteCount += proposedMaxServOutstandingCalling.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
proposedMaxServOutstandingCalled = new Integer16(); proposedMaxServOutstandingCalled = new Integer16();
subCodeLength += proposedMaxServOutstandingCalled.decode(is, false); vByteCount += proposedMaxServOutstandingCalled.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
proposedDataStructureNestingLevel = new Integer8(); proposedDataStructureNestingLevel = new Integer8();
subCodeLength += proposedDataStructureNestingLevel.decode(is, false); vByteCount += proposedDataStructureNestingLevel.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
initRequestDetail = new InitRequestDetail(); initRequestDetail = new InitRequestDetail();
subCodeLength += initRequestDetail.decode(is, false); vByteCount += initRequestDetail.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -190,6 +196,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -261,7 +268,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Integer16 proposedVersionNumber = null; private Integer16 proposedVersionNumber = null;
private ParameterSupportOptions proposedParameterCBB = null; private ParameterSupportOptions proposedParameterCBB = null;
private ServiceSupportOptions servicesSupportedCalling = null; private ServiceSupportOptions servicesSupportedCalling = null;
@ -296,6 +303,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
this.servicesSupportedCalling = servicesSupportedCalling; this.servicesSupportedCalling = servicesSupportedCalling;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -303,9 +311,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -337,54 +343,65 @@ public class InitiateRequestPDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
proposedVersionNumber = new Integer16(); proposedVersionNumber = new Integer16();
subCodeLength += proposedVersionNumber.decode(is, false); vByteCount += proposedVersionNumber.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
proposedParameterCBB = new ParameterSupportOptions(); proposedParameterCBB = new ParameterSupportOptions();
subCodeLength += proposedParameterCBB.decode(is, false); vByteCount += proposedParameterCBB.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
servicesSupportedCalling = new ServiceSupportOptions(); servicesSupportedCalling = new ServiceSupportOptions();
subCodeLength += servicesSupportedCalling.decode(is, false); vByteCount += servicesSupportedCalling.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -393,6 +410,7 @@ public class InitiateRequestPDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,10 +1,10 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength; import com.beanit.asn1bean.ber.BerLength;
import com.beanit.jasn1.ber.BerTag; import com.beanit.asn1bean.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream; import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType; import com.beanit.asn1bean.ber.types.BerType;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -14,13 +14,12 @@ public class InitiateResponsePDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Integer32 localDetailCalled = null; private Integer32 localDetailCalled = null;
private Integer16 negotiatedMaxServOutstandingCalling = null; private Integer16 negotiatedMaxServOutstandingCalling = null;
private Integer16 negotiatedMaxServOutstandingCalled = null; private Integer16 negotiatedMaxServOutstandingCalled = null;
private Integer8 negotiatedDataStructureNestingLevel = null; private Integer8 negotiatedDataStructureNestingLevel = null;
private InitResponseDetail initResponseDetail = null; private InitResponseDetail initResponseDetail = null;
public InitiateResponsePDU() {} public InitiateResponsePDU() {}
public InitiateResponsePDU(byte[] code) { public InitiateResponsePDU(byte[] code) {
@ -68,6 +67,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
this.initResponseDetail = initResponseDetail; this.initResponseDetail = initResponseDetail;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -75,9 +75,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -123,66 +121,74 @@ public class InitiateResponsePDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
localDetailCalled = new Integer32(); localDetailCalled = new Integer32();
subCodeLength += localDetailCalled.decode(is, false); vByteCount += localDetailCalled.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
negotiatedMaxServOutstandingCalling = new Integer16(); negotiatedMaxServOutstandingCalling = new Integer16();
subCodeLength += negotiatedMaxServOutstandingCalling.decode(is, false); vByteCount += negotiatedMaxServOutstandingCalling.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
negotiatedMaxServOutstandingCalled = new Integer16(); negotiatedMaxServOutstandingCalled = new Integer16();
subCodeLength += negotiatedMaxServOutstandingCalled.decode(is, false); vByteCount += negotiatedMaxServOutstandingCalled.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
negotiatedDataStructureNestingLevel = new Integer8(); negotiatedDataStructureNestingLevel = new Integer8();
subCodeLength += negotiatedDataStructureNestingLevel.decode(is, false); vByteCount += negotiatedDataStructureNestingLevel.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
initResponseDetail = new InitResponseDetail(); initResponseDetail = new InitResponseDetail();
subCodeLength += initResponseDetail.decode(is, false); vByteCount += initResponseDetail.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
} }
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
} }
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -191,6 +197,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);
@ -264,7 +271,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public byte[] code = null; private byte[] code = null;
private Integer16 negotiatedVersionNumber = null; private Integer16 negotiatedVersionNumber = null;
private ParameterSupportOptions negotiatedParameterCBB = null; private ParameterSupportOptions negotiatedParameterCBB = null;
private ServiceSupportOptions servicesSupportedCalled = null; private ServiceSupportOptions servicesSupportedCalled = null;
@ -299,6 +306,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
this.servicesSupportedCalled = servicesSupportedCalled; this.servicesSupportedCalled = servicesSupportedCalled;
} }
@Override
public int encode(OutputStream reverseOS) throws IOException { public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true); return encode(reverseOS, true);
} }
@ -306,9 +314,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException { public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) { if (code != null) {
for (int i = code.length - 1; i >= 0; i--) { reverseOS.write(code);
reverseOS.write(code[i]);
}
if (withTag) { if (withTag) {
return tag.encode(reverseOS) + code.length; return tag.encode(reverseOS) + code.length;
} }
@ -340,54 +346,65 @@ public class InitiateResponsePDU implements BerType, Serializable {
return codeLength; return codeLength;
} }
@Override
public int decode(InputStream is) throws IOException { public int decode(InputStream is) throws IOException {
return decode(is, true); return decode(is, true);
} }
public int decode(InputStream is, boolean withTag) throws IOException { public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0; int tlByteCount = 0;
int subCodeLength = 0; int vByteCount = 0;
BerTag berTag = new BerTag(); BerTag berTag = new BerTag();
if (withTag) { if (withTag) {
codeLength += tag.decodeAndCheck(is); tlByteCount += tag.decodeAndCheck(is);
} }
BerLength length = new BerLength(); BerLength length = new BerLength();
codeLength += length.decode(is); tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
negotiatedVersionNumber = new Integer16(); negotiatedVersionNumber = new Integer16();
subCodeLength += negotiatedVersionNumber.decode(is, false); vByteCount += negotiatedVersionNumber.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
negotiatedParameterCBB = new ParameterSupportOptions(); negotiatedParameterCBB = new ParameterSupportOptions();
subCodeLength += negotiatedParameterCBB.decode(is, false); vByteCount += negotiatedParameterCBB.decode(is, false);
subCodeLength += berTag.decode(is); vByteCount += berTag.decode(is);
} else { } else {
throw new IOException("Tag does not match the mandatory sequence element tag."); throw new IOException("Tag does not match mandatory sequence component.");
} }
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
servicesSupportedCalled = new ServiceSupportOptions(); servicesSupportedCalled = new ServiceSupportOptions();
subCodeLength += servicesSupportedCalled.decode(is, false); vByteCount += servicesSupportedCalled.decode(is, false);
if (subCodeLength == totalLength) { if (lengthVal >= 0 && vByteCount == lengthVal) {
return codeLength; return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
} }
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} }
throw new IOException( throw new IOException(
"Unexpected end of sequence, length tag: " "Unexpected end of sequence, length tag: "
+ totalLength + lengthVal
+ ", actual sequence length: " + ", bytes decoded: "
+ subCodeLength); + vByteCount);
} }
public void encodeAndSave(int encodingSizeGuess) throws IOException { public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -396,6 +413,7 @@ public class InitiateResponsePDU implements BerType, Serializable {
code = reverseOS.getArray(); code = reverseOS.getArray();
} }
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
appendAsString(sb, 0); appendAsString(sb, 0);

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class Integer16 extends BerInteger { public class Integer16 extends BerInteger {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class Integer32 extends BerInteger { public class Integer32 extends BerInteger {

@ -1,7 +1,7 @@
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */ /** This class file was automatically generated by ASN1bean (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1; package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.types.BerInteger; import com.beanit.asn1bean.ber.types.BerInteger;
import java.math.BigInteger; import java.math.BigInteger;
public class Integer8 extends BerInteger { public class Integer8 extends BerInteger {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save