Commit 049adf80 authored by garciay's avatar garciay
Browse files

Spirent upgrade of plugin configuration files

Add Commsignia libraries
parent 4e1103ee
......@@ -25,238 +25,238 @@ import org.etsi.ttcn.tri.TriPortId;
*/
public class ComponentMgr{
/**
* Association Component ID <-> Component reference
*/
private LinkedHashMap<String, TriComponentId> mapCompNameToTriComp;
/**
* Association Component ID <-> Component reference
*/
private LinkedHashMap<String, TriComponentId> mapCompNameToTriComp;
/**
* Association Component ID <-> { (TTCN-3 Port reference / SUT Port reference) }
*/
private LinkedHashMap<String, Map<String, ITuple<TriPortId, IPort>>> mapTriPortToTuple;
/**
* Association Component ID <-> { (TTCN-3 Port reference / SUT Port reference) }
*/
private LinkedHashMap<String, Map<String, ITuple<TriPortId, IPort>>> mapTriPortToTuple;
/**
* Used to add Observer object
*/
private TestAdapter adapter;
/**
* Used to add Observer object
*/
private TestAdapter adapter;
/**
* Constructor
* @param adapter TestAdapter reference, required for Observer/Observable pattern
*/
public ComponentMgr(final TestAdapter adapter) {
/**
* Constructor
* @param adapter TestAdapter reference, required for Observer/Observable pattern
*/
public ComponentMgr(final TestAdapter adapter) {
this.adapter = adapter;
mapCompNameToTriComp = new LinkedHashMap<String, TriComponentId>();
mapTriPortToTuple = new LinkedHashMap<String, Map<String, ITuple<TriPortId, IPort>>>();
}
this.adapter = adapter;
mapCompNameToTriComp = new LinkedHashMap<String, TriComponentId>();
mapTriPortToTuple = new LinkedHashMap<String, Map<String, ITuple<TriPortId, IPort>>>();
}
/**
* Adds a new component
* If the component was already added, nothing is done
* @param component The component to add
*/
public void addComponent(TriComponentId component) {
// Sanity check
if(component == null) {
TERFactory.getInstance().logError("Error: Trying to add null component");
return;
}
/**
* Adds a new component
* If the component was already added, nothing is done
* @param component The component to add
*/
public void addComponent(TriComponentId component) {
// Sanity check
if(component == null) {
TERFactory.getInstance().logError("Error: Trying to add null component");
return;
}
if(!mapCompNameToTriComp.containsKey(component.getComponentId())) {
// Create an entry in the list of Component
mapCompNameToTriComp.put(component.getComponentId(), component);
if(!mapTriPortToTuple.containsKey(component.getComponentId())) {
// Create an entry in the list of Component/Ports
mapTriPortToTuple.put(component.getComponentId(), new LinkedHashMap<String, ITuple<TriPortId, IPort>>());
}
}
}
if(!mapCompNameToTriComp.containsKey(component.getComponentId())) {
// Create an entry in the list of Component
mapCompNameToTriComp.put(component.getComponentId(), component);
if(!mapTriPortToTuple.containsKey(component.getComponentId())) {
// Create an entry in the list of Component/Ports
mapTriPortToTuple.put(component.getComponentId(), new LinkedHashMap<String, ITuple<TriPortId, IPort>>());
}
}
}
/**
* Adds a new port to the specified component
* @param component The component reference
* @param portname The port name
* @param port The port to add
*/
public void addPort(final String componentName, final TriPortId ttcnPort, final IPort port) {
// Sanity checks
if(componentName.isEmpty() || (ttcnPort == null) || (port == null)) {
TERFactory.getInstance().logError("Wrong parameters");
return;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("Error: Trying to add port to unknown component");
return;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
// Create an entry in the list of Component/Ports
/**
* Adds a new port to the specified component
* @param component The component reference
* @param portname The port name
* @param port The port to add
*/
public void addPort(final String componentName, final TriPortId ttcnPort, final IPort port) {
// Sanity checks
if(componentName.isEmpty() || (ttcnPort == null) || (port == null)) {
TERFactory.getInstance().logError("ComponentMgr.addPort: Wrong parameters");
return;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.addPort: Trying to add port to unknown component");
return;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
// Create an entry in the list of Component/Ports
mapTriPortToTuple.put(componentName, new LinkedHashMap<String, ITuple<TriPortId, IPort>>());
}
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(ttcnPort.getPortName())) {
portItem.put(ttcnPort.getPortName(), new Tuple<TriPortId, IPort>(ttcnPort, port));
((IObservable)port).addObserver((Observer) adapter);
mapTriPortToTuple.put(componentName, portItem);
}
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(ttcnPort.getPortName())) {
portItem.put(ttcnPort.getPortName(), new Tuple<TriPortId, IPort>(ttcnPort, port));
((IObservable)port).addObserver((Observer) adapter);
mapTriPortToTuple.put(componentName, portItem);
}
}
/**
* Gets the component reference from its name
* @param componentName The component name
* @return The component reference if the component exists, null otherwise
*/
public TriComponentId getComponent(String componentName) {
/**
* Gets the component reference from its name
* @param componentName The component name
* @return The component reference if the component exists, null otherwise
*/
public TriComponentId getComponent(String componentName) {
// Sanity checks
if(componentName == null || componentName.isEmpty()) {
TERFactory.getInstance().logError("Invalid component");
return null;
}
// Sanity checks
if(componentName == null || componentName.isEmpty()) {
TERFactory.getInstance().logError("ComponentMgr.getComponent: Invalid component");
return null;
}
return mapCompNameToTriComp.get(componentName);
}
return mapCompNameToTriComp.get(componentName);
}
/**
* Retrieves the TTCN-3 port identifier (TriPortId) from component/port names
* @param componentName The component reference
* @param portName The port name
* @return The TTCN-3 port identifier if the component and the port exists, null otherwise
*/
public TriPortId getPortId(String componentName, String portName) {
/**
* Retrieves the TTCN-3 port identifier (TriPortId) from component/port names
* @param componentName The component reference
* @param portName The port name
* @return The TTCN-3 port identifier if the component and the port exists, null otherwise
*/
public TriPortId getPortId(String componentName, String portName) {
// Sanity checks
if(componentName.isEmpty() || portName.isEmpty()) {
TERFactory.getInstance().logError("Wrong parameters");
return null;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("Unknown component");
return null;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
TERFactory.getInstance().logError("No port list entry");
return null;
}
// Sanity checks
if(componentName.isEmpty() || portName.isEmpty()) {
TERFactory.getInstance().logError("ComponentMgr.getPortId: Wrong parameters");
return null;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.getPortId: Unknown component");
return null;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.getPortId: No port list entry");
return null;
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(portName)) {
return null;
}
ITuple<TriPortId, IPort> item = portItem.get(portName);
return item.getA();
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(portName)) {
return null;
}
ITuple<TriPortId, IPort> item = portItem.get(portName);
return item.getA();
}
/**
* Retrieves the test adapter port identifier (Port or IAdapterPort) from component/port names
* @param componentName The component owner
* @return The port reference if the component and the port exists, null otherwise
*
* @see Port
* @see IAdapterPort
*/
public IPort getPort(String componentName, String portName) {
/**
* Retrieves the test adapter port identifier (Port or IAdapterPort) from component/port names
* @param componentName The component owner
* @return The port reference if the component and the port exists, null otherwise
*
* @see Port
* @see IAdapterPort
*/
public IPort getPort(String componentName, String portName) {
// Sanity checks
if(componentName.isEmpty() || portName.isEmpty()) {
TERFactory.getInstance().logError("Wrong parameters");
return null;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("Unknown component");
return null;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
TERFactory.getInstance().logError("No port list entry");
return null;
}
// Sanity checks
if(componentName.isEmpty() || portName.isEmpty()) {
TERFactory.getInstance().logError("ComponentMgr.getPort: Wrong parameters");
return null;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.getPort: Unknown component");
return null;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.getPort: No port list entry");
return null;
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(portName)) {
return null;
}
ITuple<TriPortId, IPort> item = portItem.get(portName);
return item.getB();
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(portName)) {
return null;
}
ITuple<TriPortId, IPort> item = portItem.get(portName);
return item.getB();
}
/**
* Removes the specified component
*
* Note that after the port removal, if the component has no more port, it will be removed also
*
* @param component The component reference
*/
public void removeComponent(String componentName) {
/**
* Removes the specified component
*
* Note that after the port removal, if the component has no more port, it will be removed also
*
* @param component The component reference
*/
public void removeComponent(String componentName) {
removeAllPorts();
}
removeAllPorts();
}
/**
* Removes the specified port
*
* Note that all ports attached to this component will be removed also
*
* @param componentName The component name to remove
*/
public void removePort(String componentName, String portName) {
/**
* Removes the specified port
*
* Note that all ports attached to this component will be removed also
*
* @param componentName The component name to remove
*/
public void removePort(String componentName, String portName) {
// Sanity checks
if(componentName.isEmpty() || portName.isEmpty()) {
TERFactory.getInstance().logError("Wrong parameters");
return;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("Unknown component");
return;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
TERFactory.getInstance().logError("No port list entry");
return;
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(portName)) {
return;
}
// Remove Observers
((IObservable)portItem.get(portName).getB()).deleteObservers();
// Sanity checks
if(componentName.isEmpty() || portName.isEmpty()) {
TERFactory.getInstance().logError("ComponentMgr.removePort: Wrong parameters");
return;
}
if(!mapCompNameToTriComp.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.removePort: Unknown component");
return;
}
if(!mapTriPortToTuple.containsKey(componentName)) {
TERFactory.getInstance().logError("ComponentMgr.removePort: No port list entry");
return;
}
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
if(!portItem.containsKey(portName)) {
return;
}
// Remove Observers
((IObservable)portItem.get(portName).getB()).deleteObservers();
// Call dispose
((IPort)portItem.get(portName).getB()).dispose();
// Call dispose
((IPort)portItem.get(portName).getB()).dispose();
// Remove item
portItem.remove(portName);
if(portItem.size() != 0) {
mapTriPortToTuple.put(componentName, portItem);
} else {
mapTriPortToTuple.remove(componentName);
// Remove item
portItem.remove(portName);
if(portItem.size() != 0) {
mapTriPortToTuple.put(componentName, portItem);
} else {
mapTriPortToTuple.remove(componentName);
mapCompNameToTriComp.remove(componentName);
if(mapCompNameToTriComp.isEmpty()) {
mapCompNameToTriComp.clear();
}
}
if(mapTriPortToTuple.isEmpty()) {
mapTriPortToTuple.clear();
}
}
/**
* Removes all ports.
*/
public void removeAllPorts() {
// Remove all ports
for(Object componentName : mapTriPortToTuple.keySet().toArray()) {
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
for(Object portName : portItem.keySet().toArray()) {
removePort((String)componentName, (String)portName);
}
}
// Remove component mapping
mapCompNameToTriComp.clear();
}
if(mapTriPortToTuple.isEmpty()) {
mapTriPortToTuple.clear();
}
}
/**
* Removes all ports.
*/
public void removeAllPorts() {
// Remove all ports
for(Object componentName : mapTriPortToTuple.keySet().toArray()) {
Map<String, ITuple<TriPortId, IPort>> portItem = mapTriPortToTuple.get(componentName);
for(Object portName : portItem.keySet().toArray()) {
removePort((String)componentName, (String)portName);
}
}
// Remove component mapping
mapCompNameToTriComp.clear();
}
}
......@@ -55,7 +55,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
/**
* Logger instance
*/
private final static Logger _logger = Logger.getLogger("org.etsi.its");
//private final static Logger _logger = Logger.getLogger("org.etsi.its");
/**
* Unique instance of TciCDWrapper class
......@@ -83,8 +83,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
* Default ctor
*/
public ItsExternalFunctionsProvider() {
_logger.entering("ItsExternalFunctionsProvider", "Constructor",
String.format("version:%s", Version));
//_logger.entering("ItsExternalFunctionsProvider", "Constructor", String.format("version:%s", Version));
_tcicdWrapper = TciCDWrapperFactory.getTciCDInstance();
......@@ -110,7 +109,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
@Override
public synchronized IntegerValue fx_getCurrentTime() {
IntegerValue now = null;
_logger.entering("ItsExternalFunctionsProvider", "fx_getCurrentTime");
//_logger.entering("ItsExternalFunctionsProvider", "fx_getCurrentTime");
if (gnssScenarioSupport) {
now = _tcicdWrapper.setInteger(GNSS.getGpsTime());
......@@ -130,7 +129,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
now = _tcicdWrapper.setInteger(0);
}
_logger.exiting("ItsExternalFunctionsProvider", "fx_getCurrentTime", String.format("%10d", _tcicdWrapper.getBigInteger(now)));
//_logger.exiting("ItsExternalFunctionsProvider", "fx_getCurrentTime", String.format("%10d", _tcicdWrapper.getBigInteger(now)));
}
return now;
} // End of method fx_getCurrentTime
......@@ -156,7 +155,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
public synchronized FloatValue fx_computeDistance(
final IntegerValue p_latitudeA, final IntegerValue p_longitudeA,
final IntegerValue p_latitudeB, final IntegerValue p_longitudeB) {
// _logger.entering("ItsExternalFunctionsProvider", "fx_computeDistance",
// //_logger.entering("ItsExternalFunctionsProvider", "fx_computeDistance",
// String.format("%d, %d, %d, %d",
// p_latitudeA.getInteger(),
// p_longitudeA.getInteger(),
......@@ -209,7 +208,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
final IntegerValue p_refLongitude, final FloatValue p_distance,
final IntegerValue p_orientation, IntegerValue p_latitude,
IntegerValue p_longitude) {
// _logger.entering(
// //_logger.entering(
// "ItsExternalFunctionsProvider",
// "fx_computePositionUsingDistance",
// String.format("%d, %d", p_distance.getInteger(),
......@@ -333,8 +332,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
final OctetstringValue p_destinationAddress,
final IntegerValue p_payloadLength,
final OctetstringValue p_payload, final IntegerValue p_nextHdr) {
_logger.entering("ItsExternalFunctionsProvider",
"fx_computeIPv6CheckSum");
//_logger.entering("ItsExternalFunctionsProvider", "fx_computeIPv6CheckSum");
// Build the pseudo header according RFC 2460 - Clause 8.1
ByteArrayOutputStream pseudoheader = new ByteArrayOutputStream();
......@@ -378,18 +376,14 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
--length;
}
sum = (~((sum & 0xFFFF) + (sum >> 16))) & 0xFFFF;
_logger.info(String
.format("ItsExternalFunctionsProvider.fx_computeIPv6CheckSum: finalSum=%d",
sum));
//_logger.info(String.format("ItsExternalFunctionsProvider.fx_computeIPv6CheckSum: finalSum=%d",sum));
// Set the return value
OctetstringValue checksum = _tcicdWrapper.getOctetstring();
checksum.setLength(2);
checksum.setOctet(0, (byte) ((byte) (sum >> 8) & 0xff));
checksum.setOctet(1, (byte) (sum & 0x00ff));
_logger.exiting("ItsExternalFunctionsProvider",
"fx_computeIPv6CheckSum", checksum); // FIXME Check which method
// to call for logging
//_logger.exiting("ItsExternalFunctionsProvider", "fx_computeIPv6CheckSum", checksum); // FIXME Check which method to call for logging
return checksum;
}
......@@ -421,7 +415,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
* @return The hash value
*/
public OctetstringValue fx_hashWithSha256(final OctetstringValue p_toBeHashedData) {
_logger.entering("ItsExternalFunctionsProvider", "fx_hashWithSha256");
//_logger.entering("ItsExternalFunctionsProvider", "fx_hashWithSha256");
byte[] toBeHashedData = new byte[p_toBeHashedData.getLength()];
for (int i = 0; i < toBeHashedData.length; i++) {
......@@ -444,7 +438,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
* @return The signature value
*/
public OctetstringValue fx_signWithEcdsaNistp256WithSha256(final OctetstringValue p_toBeSignedData, final OctetstringValue/*IntegerValue*/ p_privateKey) {
_logger.entering("ItsExternalFunctionsProvider", "fx_signWithEcdsaNistp256WithSha256");
//_logger.entering("ItsExternalFunctionsProvider", "fx_signWithEcdsaNistp256WithSha256");
byte[] toBeSignedData = new byte[p_toBeSignedData.getLength()];
for (int i = 0; i < toBeSignedData.length; i++) {
......@@ -481,7 +475,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
* @return true on success, false otherwise
*/
public BooleanValue fx_verifyWithEcdsaNistp256WithSha256(final OctetstringValue p_toBeVerifiedData, final OctetstringValue p_signature, final OctetstringValue p_ecdsaNistp256PublicKeyX, final OctetstringValue p_ecdsaNistp256PublicKeyY) {
_logger.entering("ItsExternalFunctionsProvider", "fx_verifyWithEcdsaNistp256WithSha256");
//_logger.entering("ItsExternalFunctionsProvider", "fx_verifyWithEcdsaNistp256WithSha256");
BooleanValue result = _tcicdWrapper.getBoolean();
result.setBoolean(false);
......@@ -513,7 +507,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
e.printStackTrace();
}
_logger.exiting("ItsExternalFunctionsProvider", "fx_verifyWithEcdsaNistp256WithSha256");
//_logger.exiting("ItsExternalFunctionsProvider", "fx_verifyWithEcdsaNistp256WithSha256");
return result;
}
......@@ -525,7 +519,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
* @return true on success, false otherwise
*/
public BooleanValue fx_generateKeyPair(OctetstringValue/*IntegerValue*/ p_privateKey, OctetstringValue p_publicKeyX, OctetstringValue p_publicKeyY) {
_logger.entering("ItsExternalFunctionsProvider", "fx_generateKeyPair");
//_logger.entering("ItsExternalFunctionsProvider", "fx_generateKeyPair");
BooleanValue result = _tcicdWrapper.getBoolean();
result.setBoolean(true);
......@@ -547,7 +541,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
p_publicKeyY.setOctet(i, ref[i]);
} // End 'for' statement
_logger.exiting("ItsExternalFunctionsProvider", "fx_generateKeyPair");
//_logger.exiting("ItsExternalFunctionsProvider", "fx_generateKeyPair");
return result;
}
......@@ -557,7 +551,7 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
* @return true on success, false otherwise