Commit 617e48c2 authored by garciay's avatar garciay
Browse files

Big fixed in GnIndReq decoding

Comment useless logs
Add a workaround on incorrect decodeHypothesis returned value ("per-basic-unaligned:1997")
parent bce23619
......@@ -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
......@@ -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<? extends ICodec> 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<? extends ICodec> 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<? extends ICodec> 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);
}
......
......@@ -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;
......
......@@ -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 {
......
......@@ -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 {
......
......@@ -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
......@@ -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;
}
......@@ -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);
}
......
......@@ -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());
......
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment