Commit 7c515cdb authored by berge's avatar berge
Browse files

/!\ FIXING BRANCH/MERGE ISSUES /!\

Reverting non STF455-specific changes trunk/javasrc (r1427 - r1432). 
Those changes:
 - have been manually duplicated in Security branch, causing massive conflicts upon merging the branch back in trunk. 
 - will be re-inserted by merging Security branch back in trunk (cf. next commit)
parent bac556d6
......@@ -9,7 +9,6 @@
package org.etsi.its.adapter;
import org.etsi.its.adapter.ports.FsapPort;
import org.etsi.its.adapter.ports.GnPort;
/**
......@@ -28,12 +27,6 @@ public interface IManagementLayers {
*/
public void registerGnPort(GnPort gnPort);
/**
* Registers a FSAP port
* @param The FSAP port to register
*/
public void registerFsapPort(final FsapPort fntpPort);
/**
* Gets the GeoNetworking beaconing interval
* @return GeoNetworking beaconing interval in ms
......
......@@ -55,15 +55,4 @@ public interface IManagementTA {
*/
public byte[] getLongPositionVector(byte[] targetGnAddress);
/**
* Requests Test Adapter to trigger a Service Provider InSapPrimitiveUp/SAM message sending
* @param sam The SAM message to transmit
*/
public void startSamTransmission(final byte[] sam);
/**
* Requests Test Adapter to stop a Service Provider InSapPrimitiveUp/SAM message sending
* @param sam The SAM message to transmit
*/
public void stopSamTransmission();
}
......@@ -19,7 +19,6 @@ import org.etsi.adapter.TERFactory;
import org.etsi.common.ByteHelper;
import org.etsi.common.ITuple;
import org.etsi.common.Tuple;
import org.etsi.its.adapter.ports.FsapPort;
import org.etsi.its.adapter.ports.GnPort;
import org.etsi.ttcn.tci.CharstringValue;
......@@ -70,11 +69,6 @@ public class Management implements IManagementTA, IManagementLayers {
private GnPort gnPort = null;
/**
* Registered FSAP Port
*/
private FsapPort fsapPort = null; // FIXME Enhance this using Fsap.send() method
/**
* Private constructor (Multiton pattern)
*/
private Management() {
......@@ -287,27 +281,4 @@ public class Management implements IManagementTA, IManagementLayers {
enqueueBeacon = null;
}
/**
* Registers a FSAP port
* @param The FSAP port to register
*/
@Override
public void registerFsapPort(final FsapPort fsapPort) {
this.fsapPort = fsapPort;
}
@Override
public void startSamTransmission(final byte[] sam) {
if(fsapPort != null) {
fsapPort.startSamTransmission(sam);
}
}
@Override
public void stopSamTransmission() {
if(fsapPort != null) {
fsapPort.stopSamTransmission();
}
}
}
......@@ -46,13 +46,8 @@ public class PcapMultiplexer implements Runnable {
// Obtain the list of network interfaces
List<PcapIf> alldevs = new ArrayList<PcapIf>(); // Will be filled with NICs
int r;
try {
r = Pcap.findAllDevs(alldevs, errbuf);
} catch (java.lang.UnsatisfiedLinkError e) {
e.printStackTrace();
return;
}
int r = Pcap.findAllDevs(alldevs, errbuf);
if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
System.err.printf("Can't read list of devices, error is %s", errbuf.toString());
return;
......
......@@ -14,7 +14,6 @@ import java.util.Observer;
import org.etsi.adapter.ITERequired;
import org.etsi.adapter.TERFactory;
import org.etsi.its.adapter.ports.AdapterControlPort;
import org.etsi.its.adapter.ports.ConfigTesterPort;
import org.etsi.its.adapter.ports.IPort;
import org.etsi.its.adapter.ports.PortEvent;
import org.etsi.its.adapter.ports.ProtocolPortFactory;
......@@ -93,8 +92,6 @@ public class TestAdapter implements TriCommunicationSA, Observer {
port = new AdapterControlPort(portName, ComponentId);
} else if (tsiPortId.getPortName().equals("utPort")) {
port = new UpperTesterPort(portName, ComponentId);
} else if (tsiPortId.getPortName().equals("cfPort")) {
port = new ConfigTesterPort(portName, ComponentId);
} else {
String componentName = compPortId.getComponent().getComponentName();
......@@ -296,8 +293,7 @@ public class TestAdapter implements TriCommunicationSA, Observer {
*/
@Override
public TriStatus triSutActionInformal(String description) {
javax.swing.JOptionPane.showMessageDialog(null, description);
return required.getTriStatus(TriStatus.TRI_OK, "");
return required.getTriStatus(TriStatus.TRI_ERROR, "triSutActionInformal not implemented");
}
/**
......
......@@ -46,11 +46,7 @@ public class LayerFactory {
layers.put("GN", GnLayer.class);
layers.put("G5", G5Layer.class);
layers.put("ETH", EthernetLayer.class);
layers.put("UdpIp", UdpIpLayer.class); // Used for CALM ports
layers.put("FNTP", FntpLayer.class);
layers.put("FSAP", FsapLayer.class);
layers.put("IICP", IicpLayer.class);
layers.put("ATSP", AtspLayer.class);
layers.put("Loopback", LoopbackLayer.class);
layers.put("Debug", DebugLayer.class);
layers.put("CamSource", CamSourceLayer.class);
......
......@@ -7,19 +7,12 @@ import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.etsi.adapter.TERFactory;
import org.etsi.common.ByteHelper;
import org.etsi.its.adapter.IManagementLayers;
import org.etsi.ttcn.tci.CharstringValue;
public class UdpIpLayer extends Layer {
private static final String SETTINGS_PATTERN = "(\\S+)\\:(\\d+)\\:(\\d+)"; // FIXME The second port shall be optional if the same port shall be used for server and client
private Pattern settingsPattern = Pattern.compile(SETTINGS_PATTERN);
public UdpIpLayer(IManagementLayers management, Stack<String> lowerStack) {
super(management, lowerStack);
......@@ -30,7 +23,7 @@ public class UdpIpLayer extends Layer {
*/
@Override
public boolean send(byte[] message, Map<String, Object> params) {
DatagramPacket packet = new DatagramPacket(message, message.length, iutAddress, iutClientPort);
DatagramPacket packet = new DatagramPacket(message, message.length, iutAddress, iutPort);
try {
iutSocket.send(packet);
} catch (IOException e) {
......@@ -47,22 +40,10 @@ public class UdpIpLayer extends Layer {
if(registeredUpperLayer == null) {
super.register(upperLayer);
try {
// UDP connection parameters
String settings = ((CharstringValue)TERFactory.getInstance().getTaParameter("LowerTesterSettings")).getString();
Matcher matcher = settingsPattern.matcher(settings);
if (matcher.find()) {
iutAddress = InetAddress.getByName(matcher.group(1));
iutClientPort = Integer.parseInt(matcher.group(2));
if (matcher.group(3) != null) {
iutServerPort = Integer.parseInt(matcher.group(3));
} else {
iutServerPort = iutClientPort;
}
} else {
System.err.println("No pattern matching");
}
// UDP server socket for communication with UT
iutSocket = new DatagramSocket(iutServerPort);
iutAddress = InetAddress.getByName("127.0.0.1");
//System.out.println("IUT Address: " + iutAddress.getHostAddress());
iutPort = 3750;
iutSocket = new DatagramSocket(3751);
iutThread = new UdpThread(iutSocket);
iutThread.start();
} catch (Exception e) {
......@@ -88,8 +69,7 @@ public class UdpIpLayer extends Layer {
private DatagramSocket iutSocket;
private InetAddress iutAddress;
private int iutClientPort;
private int iutServerPort;
private int iutPort;
private Thread iutThread;
private class UdpThread extends Thread {
......
......@@ -20,7 +20,6 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
/* AdapterControl Primitives */
private static final byte AcGnPrimitive = 0;
private static final byte AcGn6Primitive = 1;
private static final byte AcFsapPrimitive = 2;
/* AdapterControl Response */
private static final byte AcGnResponse = 0;
......@@ -113,15 +112,6 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
}
*/
break;
case AcFsapPrimitive:
ByteHelper.dump("AdapterControlPort.send", message);
byte[] data = ByteHelper.extract(message, 2, message.length - 2);
if ((data.length == 1) && (data[0] == 0x01)) {
Management.getInstance(getComponentName()).stopSamTransmission();
} else {
Management.getInstance(getComponentName()).startSamTransmission(data);
}
break;
} // End of 'switch' statement
return result;
......
......@@ -38,10 +38,6 @@ public class ProtocolPortFactory {
ports.put("geoNetworkingPort", GnPort.class);
ports.put("ipv6OverGeoNetworkingPort", Gn6Port.class);
ports.put("v2gPort", V2GPort.class);
ports.put("fntpPort", FntpPort.class);
ports.put("fsapPort", FsapPort.class);
ports.put("iicpPort", IicpPort.class);
ports.put("atspPort", AtspPort.class);
}
/**
......
......@@ -27,31 +27,7 @@ public interface ITciCDWrapper {
* See ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
* @return An instance of Type representing a TTCN-3 integer type
*/
public IntegerValue setInteger(final Integer value);
/**
* Constructs and returns a basic TTCN-3 big integer type
*
* @see ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
* @return An instance of Type representing a TTCN-3 integer type
*/
public IntegerValue setInteger(final BigInteger value);
/**
* Constructs and returns a basic integer type
*
* See ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
* @return An instance of Type representing a TTCN-3 integer type
*/
public int getInteger(final IntegerValue iv);
/**
* Constructs and returns a basic big integer type
*
* @see ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
* @return An instance of Type representing a TTCN-3 integer type
*/
public long/*TODO BigInteger*/ getBigInteger(final IntegerValue iv);
public IntegerValue getInteger();
/**
* Constructs and returns a basic TTCN-3 octet string type
......@@ -68,6 +44,14 @@ public interface ITciCDWrapper {
* @return An instance of Type representing a TTCN-3 float type
*/
public FloatValue getFloat();
/**
* Constructs and returns a basic TTCN-3 big integer type
*
* @see ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
* @return An instance of Type representing a TTCN-3 integer type
*/
IntegerValue getBigInteger(BigInteger bigInt);
/**
* Constructs and returns a basic TTCN-3 float type
......
......@@ -59,14 +59,9 @@ public class CodecFactory {
// initialize additional codec plugins
org.etsi.ttcn.codec.its.adapter.Plugin.init();
org.etsi.ttcn.codec.its.uppertester.Plugin.init();
org.etsi.ttcn.codec.its.configtester.Plugin.init();
org.etsi.ttcn.codec.its.geonetworking.Plugin.init();
org.etsi.ttcn.codec.its.btp.Plugin.init();
org.etsi.ttcn.codec.its.fntp.Plugin.init();
org.etsi.ttcn.codec.its.fsap.Plugin.init();
org.etsi.ttcn.codec.its.iicp.Plugin.init();
org.etsi.ttcn.codec.its.atsp.Plugin.init();
}
}
......
......@@ -8,15 +8,15 @@ package org.etsi.ttcn.codec;
import java.util.Map;
import java.util.TreeMap;
import org.etsi.codec.ITciCDWrapper;
import org.etsi.ttcn.tri.TriMessage;
import org.etsi.ttcn.tci.TciCDProvided;
import org.etsi.ttcn.tci.TciCDRequired;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
import org.etsi.ttcn.tri.TriMessage;
public class MainCodec extends ICodec {
public MainCodec(ITciCDWrapper cdReq) {
public MainCodec(TciCDRequired cdReq) {
super(null);
this.cdReq = cdReq;
}
......@@ -97,11 +97,11 @@ public class MainCodec extends ICodec {
presenceHints.put(key, value);
}
public ITciCDWrapper getTciCDRequired() {
public TciCDRequired getTciCDRequired() {
return cdReq;
}
protected Map<String, String> hints = new TreeMap<String, String>();
protected Map<String, java.lang.Boolean> presenceHints = new TreeMap<String, java.lang.Boolean>();
protected ITciCDWrapper cdReq;
protected TciCDRequired cdReq;
}
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.adapter;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.ttcn.tci.UnionValue;
public class AcFsapPrimitive extends Union {
public AcFsapPrimitive(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preEncode(CodecBuffer buf, UnionValue uv) {
String variant = uv.getPresentVariantName();
int primitiveId = -1;
// Append AcGnPrimitive message id
buf.appendBytes(ByteHelper.intToByteArray(2, 1)); // AdapterControl Primitive identifer for AcFsapPrimitive
// Append primitive command identifier
if(variant.equals("inSapPrimitivesUp")) {
primitiveId = 0;
}
else if(variant.equals("stopTransmission")) {
primitiveId = 1;
}
buf.appendBytes(ByteHelper.intToByteArray(primitiveId, 1));
}
}
package org.etsi.ttcn.codec.its.atsp;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class AtspInd extends Record {
public AtspInd(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
System.out.println("FntpInd.preDecodeField: " + fieldName + " - " + decodingHypothesis.getName());
if(fieldName.equals("receptionTime")) {
buf.overwriteWith(receptionTime);
}
}
@Override
protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
int msgLen = buf.getNbBits() - 6/*Time48IAT*/ * Byte.SIZE;
receptionTime = buf.getBuffer(msgLen, 6 * Byte.SIZE);
}
private CodecBuffer receptionTime = null;
} // End of class FntpInd
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.atsp;
import org.etsi.ttcn.tci.TciTypeClass;
import org.etsi.ttcn.codec.CodecFactory;
public class Plugin {
public static void init() {
CodecFactory cf = CodecFactory.getInstance();
cf.setCodec(TciTypeClass.RECORD, "LibIts_Interface", "AtspInd", AtspInd.class);
}
}
\ No newline at end of file
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Boolean;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class CfBoolean extends Boolean {
public CfBoolean(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
Byte id = CfPduId.value(decodingHypothesis.getName());
if(id != null) {
byte[] readId = buf.readBytes(1);
if(readId[0] != id) {
return null;
}
}
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
Byte id = CfPduId.value(value.getType().getName());
if(id != null) {
return new CodecBuffer(new byte[] {id.byteValue()});
}
return null;
}
}
/**
* @author ETSI / STF462 / STF455
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import java.util.HashMap;
import java.util.Map;
public enum CfPduId {
/* From LibItsCommon_TypesAndValues */
CfResult(0x25),
/* From LibItsFntp_TypesAndValues */
CfInitialize_cfFntpInitialize (0x10),
CfFntpEventInd_mnRequestRequest (0x1a),
/* From LibItsFsap_TypesAndValues */
CfInitialize_cfFsapInitialize (0x20),
CfFsapEventInd_mfRequestRequest (0x2a),
/* From LibItsAtsp_TypesAndValues */
CfInitialize_cfIicpInitialize (0x30),
/* From LibItsAtsp_TypesAndValues */
CfInitialize_cfAtspInitialize (0x40),
/* Reserved */
reserved(0xFF);
private byte value;
private static final Map<String, Byte> UtPduIds = new HashMap<String, Byte>();
private static final Map<Byte, String> UtPduNames = new HashMap<Byte, String>();
private CfPduId(int value) {
this.value = (byte)value;
}
public static Byte value(String name) {
return UtPduIds.get(name);
}
public static String name(Byte value) {
return UtPduNames.get(value);
}
static {
for (CfPduId item : CfPduId.values()) {
UtPduIds.put(item.name(), new Byte(item.value));
UtPduNames.put(new Byte(item.value), item.name());
}
}
}
\ No newline at end of file
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class CfRecord extends Record {
public CfRecord(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
System.out.println("CfRecord.decode: " + decodingHypothesis.getName());
Byte id = CfPduId.value(decodingHypothesis.getName());
if(id != null) {
byte[] readId = buf.readBytes(1);
if(readId[0] != id) {
return null;
}
}
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
System.out.println("UtRecord.preEncode: " + value.getType().getName());
Byte id = CfPduId.value(value.getType().getName());
if(id != null) {
return new CodecBuffer(new byte[] {id.byteValue()});
}
return null;
}
}
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/