Commit b4b3bc03 authored by garciay's avatar garciay
Browse files

Bug fixed in ItsAid decoding

Remove sysout
parent 59804da6
...@@ -62,8 +62,6 @@ public class CommsigniaLayer extends Layer implements IEthernetSpecific { ...@@ -62,8 +62,6 @@ public class CommsigniaLayer extends Layer implements IEthernetSpecific {
try { try {
itsApplication.connect(1000); itsApplication.connect(1000);
itsApplication.registerBlocking(); itsApplication.registerBlocking();
DeviceInfoResponse deviceInfoResponse = itsApplication.requestDeviceInfoBlocking();
System.out.println(deviceInfoResponse);
itsApplication.setFacilityModuleStatus(FacilityModule.BSM, false); itsApplication.setFacilityModuleStatus(FacilityModule.BSM, false);
itsApplication.setFacilityModuleStatus(FacilityModule.CAM, false); itsApplication.setFacilityModuleStatus(FacilityModule.CAM, false);
itsApplication. gnBindBlocking(BTPType.NONE, 65535); itsApplication. gnBindBlocking(BTPType.NONE, 65535);
......
...@@ -271,7 +271,6 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific ...@@ -271,7 +271,6 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
} }
// ByteHelper.dump("GnPort.send", message); // ByteHelper.dump("GnPort.send", message);
//System.out.println("\n\n");
return send(message, params); return send(message, params);
} }
......
...@@ -100,13 +100,13 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable { ...@@ -100,13 +100,13 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
_certificate = new ByteArrayOutputStream(); _certificate = new ByteArrayOutputStream();
CertificatesIOFactory.getInstance().loadCertificates(_utSecuredRootPath, _utSecuredConfiId); CertificatesIOFactory.getInstance().loadCertificates(_utSecuredRootPath, _utSecuredConfiId);
if (CertificatesIOFactory.getInstance().readCertificate(CertificateId, _certificate)) { if (CertificatesIOFactory.getInstance().readCertificate(CertificateId, _certificate)) {
// System.out.println("UpperTesterPort.UpperTesterPort: _certificate=" + ByteHelper.byteArrayToString(_certificate.toByteArray())); // TERFactory.getInstance().logDebug("UpperTesterPort.UpperTesterPort: _certificate=" + ByteHelper.byteArrayToString(_certificate.toByteArray()));
_hashedId8 = new ByteArrayOutputStream(); _hashedId8 = new ByteArrayOutputStream();
_signingPrivateKey = new ByteArrayOutputStream(); _signingPrivateKey = new ByteArrayOutputStream();
CertificatesIOFactory.getInstance().readCertificateDigest(CertificateId, _hashedId8); CertificatesIOFactory.getInstance().readCertificateDigest(CertificateId, _hashedId8);
// System.out.println("UpperTesterPort.UpperTesterPort: _hashedId8=" + ByteHelper.byteArrayToString(_hashedId8.toByteArray())); // TERFactory.getInstance().logDebug("UpperTesterPort.UpperTesterPort: _hashedId8=" + ByteHelper.byteArrayToString(_hashedId8.toByteArray()));
CertificatesIOFactory.getInstance().readSigningKey(CertificateId, _signingPrivateKey); CertificatesIOFactory.getInstance().readSigningKey(CertificateId, _signingPrivateKey);
// System.out.println("UpperTesterPort.UpperTesterPort: _signingPrivateKey=" + ByteHelper.byteArrayToString(_signingPrivateKey.toByteArray())); // TERFactory.getInstance().logDebug("UpperTesterPort.UpperTesterPort: _signingPrivateKey=" + ByteHelper.byteArrayToString(_signingPrivateKey.toByteArray()));
_isSecuredMode = true; _isSecuredMode = true;
} }
...@@ -561,20 +561,20 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable { ...@@ -561,20 +561,20 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
16, // Set position at the beginning of the public keys 16, // Set position at the beginning of the public keys
32 32
); );
// System.out.println("UpperTesterPort.DispatchMessage: aaSigningPublicKeyX:" + ByteHelper.byteArrayToString(aaSigningPublicKeyX)); // TERFactory.getInstance().logDebug("UpperTesterPort.DispatchMessage: aaSigningPublicKeyX:" + ByteHelper.byteArrayToString(aaSigningPublicKeyX));
byte[] aaSigningPublicKeyY = ByteHelper.extract( byte[] aaSigningPublicKeyY = ByteHelper.extract(
_certificate.toByteArray(), _certificate.toByteArray(),
16 + 32, 16 + 32,
32 32
); );
// System.out.println("UpperTesterPort.DispatchMessage: aaSigningPublicKeyY:" + ByteHelper.byteArrayToString(aaSigningPublicKeyY)); // TERFactory.getInstance().logDebug("UpperTesterPort.DispatchMessage: aaSigningPublicKeyY:" + ByteHelper.byteArrayToString(aaSigningPublicKeyY));
// Build the generation time value // Build the generation time value
byte[] generationTime = ByteHelper.longToByteArray( byte[] generationTime = ByteHelper.longToByteArray(
System.currentTimeMillis(), System.currentTimeMillis(),
Long.SIZE / Byte.SIZE Long.SIZE / Byte.SIZE
); // In microseconds ); // In microseconds
// System.out.println("UpperTesterPort.buildToBeSignedData: generationTime=" + ByteHelper.byteArrayToString(generationTime)); // TERFactory.getInstance().logDebug("UpperTesterPort.buildToBeSignedData: generationTime=" + ByteHelper.byteArrayToString(generationTime));
byte[] headersField = ByteHelper.concat( byte[] headersField = ByteHelper.concat(
ByteHelper.concat( // SecuredMessage HeaderFields ByteHelper.concat( // SecuredMessage HeaderFields
signerInfo, // signerInfo signerInfo, // signerInfo
...@@ -600,7 +600,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable { ...@@ -600,7 +600,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
b b
); );
byte[] headersFieldLength = SecurityHelper.getInstance().size2tls(headersField.length); byte[] headersFieldLength = SecurityHelper.getInstance().size2tls(headersField.length);
// System.out.println("UpperTesterPort.buildToBeSignedData: headersField=" + ByteHelper.byteArrayToString(headersField)); // TERFactory.getInstance().logDebug("UpperTesterPort.buildToBeSignedData: headersField=" + ByteHelper.byteArrayToString(headersField));
byte[] payload = p_securedData.toByteArray(); byte[] payload = p_securedData.toByteArray();
byte[] toBeSignedData = ByteHelper.concat( byte[] toBeSignedData = ByteHelper.concat(
new byte[] { // SecuredMessage version new byte[] { // SecuredMessage version
...@@ -616,20 +616,20 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable { ...@@ -616,20 +616,20 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
new byte[] { (byte)0x43 }, // Signature length new byte[] { (byte)0x43 }, // Signature length
new byte[] { (byte)0x01 } // Signature new byte[] { (byte)0x01 } // Signature
); );
// System.out.println("UpperTesterPort.buildToBeSignedData: toBeSignedData=" + ByteHelper.byteArrayToString(toBeSignedData)); // TERFactory.getInstance().logDebug("UpperTesterPort.buildToBeSignedData: toBeSignedData=" + ByteHelper.byteArrayToString(toBeSignedData));
p_toBeSignedData.write(toBeSignedData); p_toBeSignedData.write(toBeSignedData);
} }
private void signSecuredMessage(final ByteArrayOutputStream p_toBeSignedData, final ByteArrayOutputStream p_securedMessage) throws Exception { private void signSecuredMessage(final ByteArrayOutputStream p_toBeSignedData, final ByteArrayOutputStream p_securedMessage) throws Exception {
// System.out.println("UpperTesterPort.signSecuredMessage: toBeSignedData: " + ByteHelper.byteArrayToString(p_toBeSignedData.toByteArray())); // TERFactory.getInstance().logDebug("UpperTesterPort.signSecuredMessage: toBeSignedData: " + ByteHelper.byteArrayToString(p_toBeSignedData.toByteArray()));
// Calculate the hash // Calculate the hash
byte[] hash = CryptoLib.hashWithSha256(p_toBeSignedData.toByteArray()); byte[] hash = CryptoLib.hashWithSha256(p_toBeSignedData.toByteArray());
// System.out.println("UpperTesterPort.signSecuredMessage: hash=" + ByteHelper.byteArrayToString(hash)); // TERFactory.getInstance().logDebug("UpperTesterPort.signSecuredMessage: hash=" + ByteHelper.byteArrayToString(hash));
byte[] securedBeaconHeader = null; byte[] securedBeaconHeader = null;
// Signed the hash // Signed the hash
byte[] signatureBytes = CryptoLib.signWithEcdsaNistp256WithSha256(hash, new BigInteger(_signingPrivateKey.toByteArray())); byte[] signatureBytes = CryptoLib.signWithEcdsaNistp256WithSha256(hash, new BigInteger(_signingPrivateKey.toByteArray()));
// System.out.println("UpperTesterPort.signSecuredMessage: signatureBytes=" + ByteHelper.byteArrayToString(signatureBytes)); // TERFactory.getInstance().logDebug("UpperTesterPort.signSecuredMessage: signatureBytes=" + ByteHelper.byteArrayToString(signatureBytes));
// Add signature // Add signature
securedBeaconHeader = ByteHelper.concat( securedBeaconHeader = ByteHelper.concat(
p_toBeSignedData.toByteArray(), p_toBeSignedData.toByteArray(),
...@@ -640,7 +640,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable { ...@@ -640,7 +640,7 @@ public class UpperTesterPort extends AdapterPort implements IPort, IObservable {
ByteHelper.extract(signatureBytes, 2, signatureBytes.length - 2) ByteHelper.extract(signatureBytes, 2, signatureBytes.length - 2)
); );
p_securedMessage.write(securedBeaconHeader); p_securedMessage.write(securedBeaconHeader);
// System.out.println("<<< UpperTesterPort.signSecuredMessage: sendBeacon: " + ByteHelper.byteArrayToString(p_securedMessage.toByteArray())); // TERFactory.getInstance().logDebug("<<< UpperTesterPort.signSecuredMessage: sendBeacon: " + ByteHelper.byteArrayToString(p_securedMessage.toByteArray()));
} }
} // End of class UpperTesterPort } // End of class UpperTesterPort
...@@ -149,7 +149,7 @@ public class CertificatesIO implements ICertificatesIO { ...@@ -149,7 +149,7 @@ public class CertificatesIO implements ICertificatesIO {
*/ */
@Override @Override
public boolean readCertificate(final String key, final ByteArrayOutputStream certificate) { public boolean readCertificate(final String key, final ByteArrayOutputStream certificate) {
// System.out.println(">>> CertificatesIO.readCertificate: " + key); // TERFactory.getInstance().logDebug(">>> CertificatesIO.readCertificate: " + key);
String certKey; String certKey;
if (_cachedReverseCertificatesDigest.containsKey(key)) { if (_cachedReverseCertificatesDigest.containsKey(key)) {
...@@ -173,7 +173,7 @@ public class CertificatesIO implements ICertificatesIO { ...@@ -173,7 +173,7 @@ public class CertificatesIO implements ICertificatesIO {
@Override @Override
public boolean readCertificateDigest(final String certificateId, final ByteArrayOutputStream digest) { public boolean readCertificateDigest(final String certificateId, final ByteArrayOutputStream digest) {
// System.out.println(">>> CertificatesIO.readCertificateDigest: " + certificateId); // TERFactory.getInstance().logDebug(">>> CertificatesIO.readCertificateDigest: " + certificateId);
// Sanity check // Sanity check
if (!_cachedCertificatesDigest.containsKey(certificateId)) { if (!_cachedCertificatesDigest.containsKey(certificateId)) {
...@@ -199,7 +199,7 @@ public class CertificatesIO implements ICertificatesIO { ...@@ -199,7 +199,7 @@ public class CertificatesIO implements ICertificatesIO {
*/ */
@Override @Override
public boolean readSigningKey(final String keyName, final ByteArrayOutputStream key) { public boolean readSigningKey(final String keyName, final ByteArrayOutputStream key) {
// System.out.println(">>> CertificatesIO.readSigningKey: " + keyName); // TERFactory.getInstance().logDebug(">>> CertificatesIO.readSigningKey: " + keyName);
try { try {
String certKey; String certKey;
...@@ -305,11 +305,11 @@ public class CertificatesIO implements ICertificatesIO { ...@@ -305,11 +305,11 @@ public class CertificatesIO implements ICertificatesIO {
return; return;
} }
_cachedCertificatesDigest.put(certName, bytes); _cachedCertificatesDigest.put(certName, bytes);
// System.out.println("CertificatesIO.addDigestItem: Store digest: " + ByteHelper.byteArrayToString(bytes) + " - " + certName); // TERFactory.getInstance().logDebug("CertificatesIO.addDigestItem: Store digest: " + ByteHelper.byteArrayToString(bytes) + " - " + certName);
} }
private void addCertItem(final File p_certFile) throws FileNotFoundException, IOException { private void addCertItem(final File p_certFile) throws FileNotFoundException, IOException {
// System.out.println(">>> CertificatesIO.addItem: " + p_certFile); // TERFactory.getInstance().logDebug(">>> CertificatesIO.addItem: " + p_certFile);
// Load the keys file name // Load the keys file name
String filename = p_certFile.getName(); String filename = p_certFile.getName();
...@@ -322,14 +322,14 @@ public class CertificatesIO implements ICertificatesIO { ...@@ -322,14 +322,14 @@ public class CertificatesIO implements ICertificatesIO {
fsKeys.close(); fsKeys.close();
bytes = ByteHelper.hexStringToByteArray(new String(bytes)); bytes = ByteHelper.hexStringToByteArray(new String(bytes));
_cachedCertificates.put(certName, bytes); _cachedCertificates.put(certName, bytes);
// System.out.println("CertificatesIO.addItem: Store cert " + certName + " - " + ByteHelper.byteArrayToString(bytes)); // TERFactory.getInstance().logDebug("CertificatesIO.addItem: Store cert " + certName + " - " + ByteHelper.byteArrayToString(bytes));
// calculate digest // calculate digest
bytes = calculateDigestFromCertificate(bytes); bytes = calculateDigestFromCertificate(bytes);
_cachedCertificatesDigest.put(certName, bytes); _cachedCertificatesDigest.put(certName, bytes);
// System.out.println("CertificatesIO.addItem: Store digest: " + ByteHelper.byteArrayToString(bytes) + " - " + certName); // TERFactory.getInstance().logDebug("CertificatesIO.addItem: Store digest: " + ByteHelper.byteArrayToString(bytes) + " - " + certName);
_cachedReverseCertificatesDigest.put(ByteHelper.byteArrayToString(bytes), certName); _cachedReverseCertificatesDigest.put(ByteHelper.byteArrayToString(bytes), certName);
// System.out.println("CertificatesIO.addItem: Store reverse digest " + ByteHelper.byteArrayToString(bytes) + " - " + certName); // TERFactory.getInstance().logDebug("CertificatesIO.addItem: Store reverse digest " + ByteHelper.byteArrayToString(bytes) + " - " + certName);
// Load Private Keys // Load Private Keys
filename = p_certFile.getPath(); filename = p_certFile.getPath();
......
...@@ -132,10 +132,10 @@ public class CodecBuffer { ...@@ -132,10 +132,10 @@ public class CodecBuffer {
* @see setMarkers() * @see setMarkers()
*/ */
public void runCallbacks() { public void runCallbacks() {
// System.out.println("Running callbacks..."); // TERFactory.getInstance().logDebug("Running callbacks...");
for(Map.Entry<String, Marker> entry : markers.entrySet()) { for(Map.Entry<String, Marker> entry : markers.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
// System.out.println("Running callback: " + key); // TERFactory.getInstance().logDebug("Running callback: " + key);
Marker marker = entry.getValue(); Marker marker = entry.getValue();
IMarkerCallback callback = marker.getCallback(); IMarkerCallback callback = marker.getCallback();
if(callback != null) { if(callback != null) {
......
...@@ -9,6 +9,7 @@ import java.util.Map; ...@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.etsi.codec.ITciCDWrapper; import org.etsi.codec.ITciCDWrapper;
import org.etsi.common.ByteHelper;
import org.etsi.ttcn.tci.TciCDProvided; import org.etsi.ttcn.tci.TciCDProvided;
import org.etsi.ttcn.tci.Type; import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value; import org.etsi.ttcn.tci.Value;
...@@ -34,28 +35,30 @@ public class MainCodec extends ICodec { ...@@ -34,28 +35,30 @@ public class MainCodec extends ICodec {
@Override @Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) { public Value decode(CodecBuffer buf, Type decodingHypothesis) {
// TERFactory.getInstance().logDebug(">>> MainCodec.decode: " + decodingHypothesis.getName()); // TERFactory.getInstance().logDebug(">>> MainCodec.decode: " + decodingHypothesis.getName());
// ByteHelper.dump(">>> MainCodec.decode: ", buf.getBytes()); ByteHelper.dump(">>> MainCodec.decode: ", buf.getBytes());
CodecFactory cf = CodecFactory.getInstance(); CodecFactory cf = CodecFactory.getInstance();
try { try {
TciCDProvided extCodec = cf.getExternalCodec(decodingHypothesis.getTypeEncoding()); TciCDProvided extCodec = cf.getExternalCodec(decodingHypothesis.getTypeEncoding());
if(extCodec != null) { if(extCodec != null) {
return extCodec.decode(new TriMessageImpl(buf.getBytes()), decodingHypothesis); Value v = extCodec.decode(new TriMessageImpl(buf.getBytes()), decodingHypothesis);
} else { if (v != null) {
ICodec codec = cf.getCodec( return v;//extCodec.decode(new TriMessageImpl(buf.getBytes()), decodingHypothesis);
this, } // else continue
decodingHypothesis.getTypeClass(), }
decodingHypothesis.getTypeEncoding(), ICodec codec = cf.getCodec(
decodingHypothesis.getName() this,
); decodingHypothesis.getTypeClass(),
codec.preDecode(buf, decodingHypothesis); decodingHypothesis.getTypeEncoding(),
decodingHypothesis.getName()
// TODO To be removed, for debug purpose only );
codec.preDecode(buf, decodingHypothesis);
// TODO To be removed, for debug purpose only
// Value decValue = codec.decode(buf, decodingHypothesis); // Value decValue = codec.decode(buf, decodingHypothesis);
// TERFactory.getInstance().logDebug("<<< MainCodec.decode: " + decValue); // TERFactory.getInstance().logDebug("<<< MainCodec.decode: " + decValue);
// return decValue; // return decValue;
return codec.decode(buf, decodingHypothesis); return codec.decode(buf, decodingHypothesis);
}
} catch(Throwable e) { } catch(Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
...@@ -68,25 +71,26 @@ public class MainCodec extends ICodec { ...@@ -68,25 +71,26 @@ public class MainCodec extends ICodec {
CodecFactory cf = CodecFactory.getInstance(); CodecFactory cf = CodecFactory.getInstance();
TciCDProvided extCodec = cf.getExternalCodec(value.getValueEncoding()); TciCDProvided extCodec = cf.getExternalCodec(value.getValueEncoding());
if(extCodec != null) { if(extCodec != null) {
return new CodecBuffer(extCodec.encode(value).getEncodedMessage()); TriMessage enc = extCodec.encode(value);
if (enc != null) {
return new CodecBuffer(enc.getEncodedMessage()/*extCodec.encode(value).getEncodedMessage()*/);
} // else continue
} }
else { ICodec codec = CodecFactory.getInstance().getCodec(
ICodec codec = CodecFactory.getInstance().getCodec( this,
this, value.getType().getTypeClass(),
value.getType().getTypeClass(), value.getValueEncoding(),
value.getValueEncoding(), value.getType().getName()
value.getType().getName() );
); CodecBuffer preBuf = codec.preEncode(value);
CodecBuffer preBuf = codec.preEncode(value); CodecBuffer buf = codec.encode(value);
CodecBuffer buf = codec.encode(value); if(preBuf != null) {
if(preBuf != null) { preBuf.append(buf);
preBuf.append(buf); buf = preBuf;
buf = preBuf;
}
// ByteHelper.dump("<<< MainCodec.encode: ", buf.getBytes());
return buf;
} }
//ByteHelper.dump("<<< MainCodec.encode: ", buf.getBytes());
return buf;
} }
public String getHint(String key) { public String getHint(String key) {
......
...@@ -27,7 +27,7 @@ public class Integer extends ICodec { ...@@ -27,7 +27,7 @@ public class Integer extends ICodec {
@Override @Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) { public Value decode(CodecBuffer buf, Type decodingHypothesis) {
// System.out.println(">>> Integer.decode: " + decodingHypothesis.getName()); //TERFactory.getInstance().logDebug(">>> Integer.decode: " + decodingHypothesis.getName());
IntegerValue iv = null; IntegerValue iv = null;
int lengthInBits; int lengthInBits;
...@@ -65,7 +65,7 @@ public class Integer extends ICodec { ...@@ -65,7 +65,7 @@ public class Integer extends ICodec {
} }
} }
catch(Exception e) { catch(Exception e) {
// System.out.println("Integer.encode: " + decodingHypothesis.getTypeEncoding() + ", " + decodingHypothesis.getTypeEncodingVariant()); // TERFactory.getInstance().logDebug("Integer.encode: " + decodingHypothesis.getTypeEncoding() + ", " + decodingHypothesis.getTypeEncodingVariant());
// Assume unsigned integer // Assume unsigned integer
if(lengthInBits >= java.lang.Integer.SIZE) { if(lengthInBits >= java.lang.Integer.SIZE) {
iv = mainCodec.getTciCDRequired().setInteger(new BigInteger(1, value)); iv = mainCodec.getTciCDRequired().setInteger(new BigInteger(1, value));
...@@ -80,7 +80,7 @@ public class Integer extends ICodec { ...@@ -80,7 +80,7 @@ public class Integer extends ICodec {
@Override @Override
public CodecBuffer encode(Value value) { public CodecBuffer encode(Value value) {
// System.out.println(">>> Integer.encode: " + value.getType().getName()); // TERFactory.getInstance().logDebug(">>> Integer.encode: " + value.getType().getName());
IntegerValue iv = (IntegerValue)value; IntegerValue iv = (IntegerValue)value;
byte[] encoded = null; byte[] encoded = null;
......
...@@ -20,7 +20,7 @@ public class FacilitiesInd extends Record { ...@@ -20,7 +20,7 @@ public class FacilitiesInd extends Record {
@Override @Override
protected void preDecode(CodecBuffer buf, Type decodingHypothesis) { protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
// System.out.println(">>> FacilitiesInd.preDecode: " + decodingHypothesis); // TERFactory.getInstance().logDebug(">>> FacilitiesInd.preDecode: " + decodingHypothesis);
int msgLen = buf.getNbBits() - 8 - 8 - 8 - 32 - 8 - 16 - 16 - 256 - 32; // FIXME Add support of SSP (Bit256) & ITS-AID (UInt32) extra fields: fixed size (256) is not nice! int msgLen = buf.getNbBits() - 8 - 8 - 8 - 32 - 8 - 16 - 16 - 256 - 32; // FIXME Add support of SSP (Bit256) & ITS-AID (UInt32) extra fields: fixed size (256) is not nice!
int offset = 0; int offset = 0;
......
...@@ -32,7 +32,7 @@ public class CommonHeader extends Record implements IMarkerCallback { ...@@ -32,7 +32,7 @@ public class CommonHeader extends Record implements IMarkerCallback {
@Override @Override
protected void postEncodeField(String fieldName, CodecBuffer buf) { protected void postEncodeField(String fieldName, CodecBuffer buf) {
// System.out.println(">>> CommonHeader.postEncodeField: " + fieldName); // TERFactory.getInstance().logDebug(">>> CommonHeader.postEncodeField: " + fieldName);
if(fieldName.equals("nextHeader")) { if(fieldName.equals("nextHeader")) {
int nh = buf.getBits(buf.getNbBits() - 4, 4)[0]; int nh = buf.getBits(buf.getNbBits() - 4, 4)[0];
...@@ -44,12 +44,12 @@ public class CommonHeader extends Record implements IMarkerCallback { ...@@ -44,12 +44,12 @@ public class CommonHeader extends Record implements IMarkerCallback {
@Override @Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) { protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
// System.out.println(">>> CommonHeader.preDecodeField: " + fieldName + ", " + decodingHypothesis); // TERFactory.getInstance().logDebug(">>> CommonHeader.preDecodeField: " + fieldName + ", " + decodingHypothesis);
} }
@Override @Override
protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) { protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
// System.out.println(">>> CommonHeader.postDecodeField: " + fieldName + ", " + decodingHypothesis); // TERFactory.getInstance().logDebug(">>> CommonHeader.postDecodeField: " + fieldName + ", " + decodingHypothesis);
if(fieldName.equals("nextHeader")) { if(fieldName.equals("nextHeader")) {
int nh = ((EnumeratedValue)(rv.getField(fieldName))).getInt(); int nh = ((EnumeratedValue)(rv.getField(fieldName))).getInt();
...@@ -72,7 +72,7 @@ public class CommonHeader extends Record implements IMarkerCallback { ...@@ -72,7 +72,7 @@ public class CommonHeader extends Record implements IMarkerCallback {
@Override @Override
public void run(String markerName, CodecBuffer leftBuf, CodecBuffer rightBuf) { public void run(String markerName, CodecBuffer leftBuf, CodecBuffer rightBuf) {
// System.out.println(">>> CommonHeader.run"); // TERFactory.getInstance().logDebug(">>> CommonHeader.run");
if(markerName.equals("plLength")) { if(markerName.equals("plLength")) {
int pl = java.lang.Integer.parseInt(mainCodec.getHint("payloadLength")); int pl = java.lang.Integer.parseInt(mainCodec.getHint("payloadLength"));
......
...@@ -61,7 +61,7 @@ public class GeoNetworkingPacket extends Record { ...@@ -61,7 +61,7 @@ public class GeoNetworkingPacket extends Record {
packetValue = null; // Reset value packetValue = null; // Reset value
Value result = super.decode(buf, decodingHypothesis); // Normal decoding Value result = super.decode(buf, decodingHypothesis); // Normal decoding
// TERFactory.getInstance().logDebug("GeoNetworkingPacket.decode: Normal decoding=" + result); // TERFactory.getInstance().logDebug("GeoNetworkingPacket.decode: Normal decoding=" + result);
if(isSecuredMode) { if(isSecuredMode && (result != null)) {
// Override 'packet' field // Override 'packet' field
RecordValue rv = (RecordValue) result; RecordValue rv = (RecordValue) result;
rv.setField("packet", packetValue); rv.setField("packet", packetValue);
......
...@@ -23,12 +23,12 @@ public class GeoNetworkingPdu extends Record { ...@@ -23,12 +23,12 @@ public class GeoNetworkingPdu extends Record {
@Override @Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) { protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
// System.out.println(">>> GeoNetworkingPdu.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName()); // TERFactory.getInstance().logDebug(">>> GeoNetworkingPdu.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
} }
@Override @Override
protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) { protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
// System.out.println(">>> GeoNetworkingPdu.postDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName()); // TERFactory.getInstance().logDebug(">>> GeoNetworkingPdu.postDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
} }
} // End of class GeoNetworkingPdu } // End of class GeoNetworkingPdu
...@@ -19,7 +19,7 @@ public class GeographicRegionContainer extends Union { ...@@ -19,7 +19,7 @@ public class GeographicRegionContainer extends Union {
@Override @Override
protected void preEncode(CodecBuffer buf, UnionValue uv) { protected void preEncode(CodecBuffer buf, UnionValue uv) {
// System.out.println(">>> GeographicRegionContainer.preEncode: " + uv.getType().getName() + ", " + uv.getPresentVariantName()); // TERFactory.getInstance().logDebug(">>> GeographicRegionContainer.preEncode: " + uv.getType().getName() + ", " + uv.getPresentVariantName());
if (uv.getPresentVariantName().equals("other_region")) { if (uv.getPresentVariantName().equals("other_region")) {
// FIXME Check for opaque<var> length encoding depending of the length value : <= 127 or > 127 // FIXME Check for opaque<var> length encoding depending of the length value : <= 127 or > 127
......
...@@ -51,6 +51,7 @@ public class HeaderField extends Record { ...@@ -51,6 +51,7 @@ public class HeaderField extends Record {
@Override @Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) { protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
// TERFactory.getInstance().logDebug(">>> HeaderField.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName()); // TERFactory.getInstance().logDebug(">>> HeaderField.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
if (fieldName.equals("type_")) { if (fieldName.equals("type_")) {
byte type_ = buf.getBytes(0, 1)[0]; byte type_ = buf.getBytes(0, 1)[0];
switch (type_) { switch (type_) {
......
...@@ -37,6 +37,7 @@ public class IntX extends Integer { ...@@ -37,6 +37,7 @@ public class IntX extends Integer {
byte msb = buf.getBytes(0, 1)[0]; byte msb = buf.getBytes(0, 1)[0];
if ((msb & 0x80) == 0x00) { // Integer < 128 if ((msb & 0x80) == 0x00) { // Integer < 128
mainCodec.setHint("IntXLen", "8"); mainCodec.setHint("IntXLen", "8");
mainCodec.setHint("HeaderFieldContainer.its_aidLen", "8"); // TCT3 workaround, i don't know how to abstract this :-(
return super.decode(buf, decodingHypothesis); return super.decode(buf, decodingHypothesis);
} else { } else {
// Decode the length. The encoding of the length shall use at most 7 bits set to 1 (see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.1 IntX) // Decode the length. The encoding of the length shall use at most 7 bits set to 1 (see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.1 IntX)
...@@ -47,6 +48,7 @@ public class IntX extends Integer { ...@@ -47,6 +48,7 @@ public class IntX extends Integer {
} while (bit != 0x00); } while (bit != 0x00);
// Set the IntX length // Set the IntX length
mainCodec.setHint(decodingHypothesis.getName() + "Len", String.valueOf(byteLen * Byte.SIZE )); mainCodec.setHint(decodingHypothesis.getName() + "Len", String.valueOf(byteLen * Byte.SIZE ));
mainCodec.setHint("HeaderFieldContainer.its_aid" + "Len", String.valueOf(byteLen * Byte.SIZE )); // TCT3 workaround, i don't know how to abstract this :-(
// Remove the length from the real integer value