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