diff --git a/javasrc/codec/org/etsi/codec/ITciCDWrapper.java b/javasrc/codec/org/etsi/codec/ITciCDWrapper.java index c645fcc8b16fe0bed122f33bea88dc1681ea7cf4..2c017e4abf2db283b8559b98f4a8ee7ac05acd14 100644 --- a/javasrc/codec/org/etsi/codec/ITciCDWrapper.java +++ b/javasrc/codec/org/etsi/codec/ITciCDWrapper.java @@ -138,5 +138,9 @@ public interface ITciCDWrapper { */ public Type getTypeForName(final String type); + void logDebug(String debugMessage); + + void logError(String errorMessage); + // FIXME To be continued } // End of interface ITciCDWrapper diff --git a/javasrc/codec/org/etsi/ttcn/codec/CodecFactory.java b/javasrc/codec/org/etsi/ttcn/codec/CodecFactory.java index a341cb2bf0ef081ad254da96609f273d81e4f2ba..515d744ad2d191201abf8a170f18a8658bd39efa 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/CodecFactory.java +++ b/javasrc/codec/org/etsi/ttcn/codec/CodecFactory.java @@ -9,9 +9,9 @@ import java.lang.reflect.Constructor; import java.util.Map; import java.util.TreeMap; -import org.etsi.adapter.TERFactory; import org.etsi.ttcn.tci.TciCDProvided; import org.etsi.ttcn.tci.TciTypeClass; +import org.etsi.codec.TciCDWrapperFactory; import org.etsi.ttcn.codec.generic.Bitstring; import org.etsi.ttcn.codec.generic.Boolean; import org.etsi.ttcn.codec.generic.Charstring; @@ -77,11 +77,11 @@ public class CodecFactory { return null; } -// TERFactory.getInstance().logDebug("getExternalCodec: Search external codec for " + encoding); +// TciCDWrapper.getInstance().logDebug("getExternalCodec: Search external codec for " + encoding); codec = externalCodecs.get(encoding); if(codec != null) { - TERFactory.getInstance().logDebug(String.format("%50s", encoding)); - TERFactory.getInstance().logDebug(" ==> " + codec.getClass().getName()); + TciCDWrapperFactory.getTciCDInstance().logDebug(String.format("%50s", encoding)); + TciCDWrapperFactory.getTciCDInstance().logDebug(" ==> " + codec.getClass().getName()); return codec; } return null; @@ -89,11 +89,11 @@ public class CodecFactory { public ICodec getCodec(MainCodec mainCodec, int classType, String encoding, String typeName) { - TERFactory.getInstance().logDebug(String.format("%50s", typeName + "(" + encoding + ")")); + TciCDWrapperFactory.getTciCDInstance().logDebug(String.format("%50s", typeName + "(" + encoding + ")")); Class cls = null; Class[] ctorParams = {MainCodec.class}; - TERFactory.getInstance().logDebug("getCodec: Search internal codec for " + classType + '/' + encoding + '/' + typeName); + TciCDWrapperFactory.getTciCDInstance().logDebug("getCodec: Search internal codec for " + classType + '/' + encoding + '/' + typeName); cls = codecs.get(classType + '/' + encoding + '/' + typeName); if(cls == null) { cls = codecs.get(classType + '/' + encoding + '/'); @@ -103,7 +103,7 @@ public class CodecFactory { } if(cls != null) { - TERFactory.getInstance().logDebug(" ==> " + cls.getName()); + TciCDWrapperFactory.getTciCDInstance().logDebug(" ==> " + cls.getName()); try { Constructor ctor = cls.getConstructor(ctorParams); return ctor.newInstance(mainCodec); @@ -113,12 +113,12 @@ public class CodecFactory { } } - TERFactory.getInstance().logDebug(" ==> No codec found !"); + TciCDWrapperFactory.getTciCDInstance().logDebug(" ==> No codec found !"); return new Dummy(mainCodec); } public void setCodec(int classType, String encoding, String typeName, Class codec) { -// TERFactory.getInstance().logDebug("setCodec: add " + classType + "/" + encoding + "/" + typeName + "/" + codec); +// TciCDWrapper.getInstance().logDebug("setCodec: add " + classType + "/" + encoding + "/" + typeName + "/" + codec); codecs.put(classType + '/' + encoding + '/' + typeName, codec); } diff --git a/javasrc/codec/org/etsi/ttcn/codec/MainCodec.java b/javasrc/codec/org/etsi/ttcn/codec/MainCodec.java index cbedc08b8f0adda22026ffb68baa8cceb5d64a10..617aaf66a5b087d4e808a7bd8c4fa8d900357714 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/MainCodec.java +++ b/javasrc/codec/org/etsi/ttcn/codec/MainCodec.java @@ -9,7 +9,6 @@ import java.util.Map; import java.util.TreeMap; import org.etsi.codec.ITciCDWrapper; -import org.etsi.ttcn.common.ByteHelper; import org.etsi.ttcn.tci.TciCDProvided; import org.etsi.ttcn.tci.Type; import org.etsi.ttcn.tci.Value; diff --git a/javasrc/codec/org/etsi/ttcn/codec/generic/Record.java b/javasrc/codec/org/etsi/ttcn/codec/generic/Record.java index 2d41c46adde82a0cd5c8a9f61d625f030c101294..282f6aa2f178987c544824e707a2516fd3bd29d6 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/generic/Record.java +++ b/javasrc/codec/org/etsi/ttcn/codec/generic/Record.java @@ -38,7 +38,7 @@ public class Record extends ICodec { if(fv == null) { if(mainCodec.getHint(fields[i] + "IgnoreErrorOnOptionalField") != null) { // Set to omit + warning if optional - TERFactory.getInstance().logDebug("Unable to decode optional field '" + fields[i] + "'. Setting to 'omit'"); + //TERFactory.getInstance().logDebug("Unable to decode optional field '" + fields[i] + "'. Setting to 'omit'"); rv.setFieldOmitted(fields[i]); } else { diff --git a/javasrc/codec/org/etsi/ttcn/codec/generic/Union.java b/javasrc/codec/org/etsi/ttcn/codec/generic/Union.java index 347f9eb11c6344b34739066a6ae0639ea0135353..981dc2098b0bdfd2c1d186889fef09f66e733768 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/generic/Union.java +++ b/javasrc/codec/org/etsi/ttcn/codec/generic/Union.java @@ -25,19 +25,19 @@ public class Union extends ICodec { String variant = ""; variant = mainCodec.getHint(decodingHypothesis.getName()); -// TERFactory.getInstance().logDebug("Union: Looking for variant " + decodingHypothesis.getName() + "/" + variant); + //TERFactory.getInstance().logDebug("Union: Looking for variant " + decodingHypothesis.getName() + "/" + variant); if(variant != null) { Value value = uv.getVariant(variant); if (value == null) { value = mainCodec.getTciCDRequired().getUnionValue(decodingHypothesis, variant); if (value != null) { -// TERFactory.getInstance().logDebug("Union (TCT3): " + value.getType().getName()); + //TERFactory.getInstance().logDebug("Union (TCT3): " + value.getType().getName()); uv.setVariant(variant, mainCodec.decode(buf, value.getType())); return uv; } } else { -// TERFactory.getInstance().logDebug("Union (TTWB): " + value.getType().getName()); + //TERFactory.getInstance().logDebug("Union (TTWB): " + value.getType().getName()); uv.setVariant(variant, mainCodec.decode(buf, value.getType())); return uv; } @@ -57,11 +57,11 @@ public class Union extends ICodec { if (value == null) { value = mainCodec.getTciCDRequired().getUnionValue(decodingHypothesis, mainCodec.getHint(variants[i])); if (value != null) { -// TERFactory.getInstance().logDebug("Union (TCT3): " + value.getType().getName()); + //TERFactory.getInstance().logDebug("Union (TCT3): " + value.getType().getName()); vv = mainCodec.decode(buf, value.getType()); } } else { -// TERFactory.getInstance().logDebug("Union (TTWB): " + value.getType().getName()); + //TERFactory.getInstance().logDebug("Union (TTWB): " + value.getType().getName()); vv = mainCodec.decode(buf, value.getType()); } } else { diff --git a/javasrc/codec/org/etsi/ttcn/codec/its/btp/DecodedBtpPayload.java b/javasrc/codec/org/etsi/ttcn/codec/its/btp/DecodedBtpPayload.java index af35c97865cc5028af2f4dfabc9533f1a5f1643a..6e49b8ebc2a8efdb00f2dfc6fddd6411935767c6 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/its/btp/DecodedBtpPayload.java +++ b/javasrc/codec/org/etsi/ttcn/codec/its/btp/DecodedBtpPayload.java @@ -4,6 +4,8 @@ import org.etsi.ttcn.codec.CodecBuffer; import org.etsi.ttcn.codec.MainCodec; import org.etsi.ttcn.codec.generic.Union; import org.etsi.ttcn.tci.Type; +import org.etsi.ttcn.tci.UnionValue; +import org.etsi.ttcn.tci.Value; public class DecodedBtpPayload extends Union { @@ -19,12 +21,7 @@ public class DecodedBtpPayload extends Union { mainCodec.setHint("spatemPacket", "spatemPacket"); mainCodec.setHint("ivimPacket", "ivimPacket"); mainCodec.setHint("sremPacket", "sremPacket"); - mainCodec.setHint("ssemSsemPacket", "ssemSsemPacket"); + mainCodec.setHint("ssemPacket", "ssemPacket"); } - @Override - protected void preDecode(CodecBuffer buf, Type decodingHypothesis) { -// TERFactory.getInstance().logDebug(">>> DecodedBtpPayload.preDecode: " + decodingHypothesis); - - } } // End of class DecodedBtpPayload diff --git a/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/GnIndReq.java b/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/GnIndReq.java index 025354552ca539ef7b2a0deba55d529a3ecd6fee..c9abff14bfdcacb97f1681270ee3837bb2191625 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/GnIndReq.java +++ b/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/GnIndReq.java @@ -22,10 +22,12 @@ public class GnIndReq extends Record { protected void preDecode(CodecBuffer buf, Type decodingHypothesis) { // TERFactory.getInstance().logDebug(">>> GnIndReq.preDecode: " + decodingHypothesis); - int msgLen = buf.getNbBits() - 48; + int msgLen = buf.getNbBits() - 48 - 128/*SSP*/ - 32/*ItsAid*/; messageBuffer = buf.getBuffer(0, msgLen); macBuffer = buf.getBuffer(msgLen, 48); + sspBuffer = buf.getBuffer(msgLen + 48, 128/*SSP*/); + itsaidBuffer = buf.getBuffer(msgLen + 48 + 128/*SSP*/, 32/*ItsAid*/); } @Override @@ -34,6 +36,10 @@ public class GnIndReq extends Record { if(fieldName.equals("macDestinationAddress")) { buf.overwriteWith(macBuffer); + } else if(fieldName.equals("ssp")) { + buf.overwriteWith(sspBuffer); + } else if(fieldName.equals("its_aid")) { + buf.overwriteWith(itsaidBuffer); } else { buf.overwriteWith(messageBuffer); @@ -55,4 +61,6 @@ public class GnIndReq extends Record { private CodecBuffer messageBuffer = null; private CodecBuffer macBuffer = null; + private CodecBuffer sspBuffer = null; + private CodecBuffer itsaidBuffer = null; } diff --git a/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/Payload.java b/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/Payload.java index d45c6541e6b5c3f32a36f5f7345886a1423accec..df35fd6f7d3f20b8897a39f66af5ca88e968cf88 100644 --- a/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/Payload.java +++ b/javasrc/codec/org/etsi/ttcn/codec/its/geonetworking/Payload.java @@ -20,7 +20,7 @@ public class Payload extends Record { @Override protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) { -// System.out.println(">>> Payload.preDecode" + decodingHypothesis); + //TERFactory.getInstance().logDebug(">>> Payload.preDecode" + decodingHypothesis); if(fieldName.equals("decodedPayload")) { String nhHint = mainCodec.getHint("GnNextHeader"); @@ -54,7 +54,7 @@ public class Payload extends Record { @Override protected void preDecode(CodecBuffer buf, Type decodingHypothesis) { -// TERFactory.getInstance().logDebug(">>> Payload.preDecode: " + decodingHypothesis); + //TERFactory.getInstance().logDebug(">>> Payload.preDecode: " + decodingHypothesis); // Sanity check on pl int pl = java.lang.Integer.parseInt(mainCodec.getHint("payloadLength")); @@ -62,8 +62,7 @@ public class Payload extends Record { String hint = mainCodec.getHint("IsBeacon"); if(pl != remainingBytesForPayload && hint==null) { - TERFactory.getInstance().logDebug("Error: bad payload length or message truncated " - + "(indicated: " + pl + " - real: " + remainingBytesForPayload + ")"); + //TERFactory.getInstance().logDebug("Error: bad payload length or message truncated " + "(indicated: " + pl + " - real: " + remainingBytesForPayload + ")"); pl = Math.min(remainingBytesForPayload, pl); } diff --git a/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java b/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java index 8257a2e906090dee9717affbe2f2347c88b914f8..1f34101344c0e438ceebbdafe1bd8ebeb4392a5a 100644 --- a/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java +++ b/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java @@ -61,25 +61,51 @@ public class LibIts_asn1 implements TciCDProvided { String type = ""; if (decodingHypothesis.getTypeEncoding().equals("per-basic-unaligned:1997")) { - if (decodingHypothesis.getName().equals("CAM")) { - type = String.format("%s.%s", "CAM_PDU_Descriptions", decodingHypothesis.getName()); - } else if (decodingHypothesis.getName().equals("DENM")) { - type = String.format("%s.%s", "DENM_PDU_Descriptions", decodingHypothesis.getName()); - } else if (decodingHypothesis.getName().equals("MAPEM")) { - type = String.format("%s.%s", "MAPEM_PDU_Descriptions", decodingHypothesis.getName()); - } else if (decodingHypothesis.getName().equals("SPATEM")) { - type = String.format("%s.%s", "SPATEM_PDU_Descriptions", decodingHypothesis.getName()); - } else if (decodingHypothesis.getName().equals("IVIM")) { - type = String.format("%s.%s", "IVIM_PDU_Descriptions", decodingHypothesis.getName()); - } else if (decodingHypothesis.getName().equals("SREM")) { - type = String.format("%s.%s", "SREM_PDU_Descriptions", decodingHypothesis.getName()); - } else if (decodingHypothesis.getName().equals("SSEM")) { - type = String.format("%s.%s", "SSEM_PDU_Descriptions", decodingHypothesis.getName()); - } + switch (message.getEncodedMessage()[1]) { // messageID INTEGER{ denm(1), cam(2), poi(3), spatem(4), mapem(5), ivim(6), ev-rsr(7), tistpgtransaction(8), srem(9), ssem(10), evcsn(11) } (0..255), -- Mantis #7209, #7005 + case (byte)0x01: + if (decodingHypothesis.getName().equals("DENM")) { + type = String.format("%s.%s", "DENM_PDU_Descriptions", decodingHypothesis.getName()); + } + break; + case (byte)0x02: + if (decodingHypothesis.getName().equals("CAM")) { + type = String.format("%s.%s", "CAM_PDU_Descriptions", decodingHypothesis.getName()); + } + break; + case (byte)0x05: + if (decodingHypothesis.getName().equals("MAPEM")) { + type = String.format("%s.%s", "MAPEM_PDU_Descriptions", decodingHypothesis.getName()); + } + break; + case (byte)0x04: + if (decodingHypothesis.getName().equals("SPATEM")) { + type = String.format("%s.%s", "SPATEM_PDU_Descriptions", decodingHypothesis.getName()); + } + break; + case (byte)0x06: + if (decodingHypothesis.getName().equals("IVIM")) { + type = String.format("%s.%s", "IVIM_PDU_Descriptions", decodingHypothesis.getName()); + } + case (byte)0x09: + if (decodingHypothesis.getName().equals("SREM")) { + type = String.format("%s.%s", "SREM_PDU_Descriptions", decodingHypothesis.getName()); + } + break; + case (byte)0x0a: + if (decodingHypothesis.getName().equals("SSEM")) { + type = String.format("%s.%s", "SSEM_PDU_Descriptions", decodingHypothesis.getName()); + } + break; + default: + // Nothing to do + } // End of 'switch' statement } else { type = String.format("%s.%s", _encodingName, decodingHypothesis.getName()); } _logger.info("Type: " + type); + if (type.isEmpty()) { + return null; // Abort decoding + } Type asnOriginalType = getTypeForName(type); // Check which type class the decoding hypothesis is of _logger.info("asnOriginalType: " + asnOriginalType.getName()); diff --git a/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java b/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java index 8954309cb2c05136040145d086ca4bd7f3ab95cc..17f0fbfadea597ff015c778aa53b650caf13a6c5 100644 --- a/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java +++ b/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java @@ -112,9 +112,9 @@ public class TciCDWrapper implements ITciCDWrapper { return testVal; } } - TERFactory.getInstance().logError("variantType is null"); +// TERFactory.getInstance().logError("variantType is null"); - TERFactory.getInstance().logDebug("Variant value hasn't been created."); +// TERFactory.getInstance().logDebug("Variant value hasn't been created."); return null; } @@ -133,9 +133,13 @@ public class TciCDWrapper implements ITciCDWrapper { originalType = _tciFactory.getTypeForName("MAPEM_PDU_Descriptions.SPATEM"); } else if (type.endsWith("ivimPacket")) { originalType = _tciFactory.getTypeForName("IVIM_PDU_Descriptions.IVIM"); + } else if (type.endsWith("sremPacket")) { + originalType = _tciFactory.getTypeForName("SREM_PDU_Descriptions.SREM"); + } else if (type.endsWith("ssemPacket")) { + originalType = _tciFactory.getTypeForName("SSEM_PDU_Descriptions.SSEM"); } else { originalType = _tciFactory.getTypeForName(type); - } + } } else { originalType = _tciFactory.getTypeForName(type); }