summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/utils
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/utils')
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/EthType.java2
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MacAddress.java1
-rwxr-xr-xframework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java3
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java16
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java17
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java23
-rw-r--r--framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java69
-rw-r--r--framework/src/onos/utils/stc/src/test/java/org/onlab/stc/CompilerTest.java4
-rw-r--r--framework/src/onos/utils/stc/src/test/resources/org/onlab/stc/scenario.xml7
9 files changed, 109 insertions, 33 deletions
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/EthType.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/EthType.java
index 561c9307..b3b79e2c 100644
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/EthType.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/EthType.java
@@ -45,7 +45,7 @@ public class EthType {
private final Deserializer<?> deserializer;
/**
- * Constucts a new ethertype.
+ * Constructs a new ethertype.
*
* @param ethType The actual ethertype
* @param type it's textual representation
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MacAddress.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MacAddress.java
index 89cddbae..cb7f2013 100644
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MacAddress.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/MacAddress.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
*/
public class MacAddress {
+ public static final MacAddress NONE = valueOf("a4:23:05:00:00:00");
public static final MacAddress ZERO = valueOf("00:00:00:00:00:00");
public static final MacAddress BROADCAST = valueOf("ff:ff:ff:ff:ff:ff");
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java
index d9a5e83f..e6ef0aed 100755
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/PIM.java
@@ -43,6 +43,9 @@ public class PIM extends BasePacket {
public static final int PIM_HEADER_LEN = 4;
+ public static final byte ADDRESS_FAMILY_IP4 = 0x1;
+ public static final byte ADDRESS_FAMILY_IP6 = 0x2;
+
public static final Map<Byte, Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP =
new HashMap<>();
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java
index be4ab19a..0db82afb 100644
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrGroup.java
@@ -17,9 +17,11 @@ package org.onlab.packet.pim;
import org.onlab.packet.DeserializationException;
import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip6Address;
+import org.onlab.packet.PIM;
+
import java.nio.ByteBuffer;
@@ -41,7 +43,7 @@ public class PIMAddrGroup {
* PIM Encoded Group Address.
*/
public PIMAddrGroup() {
- this.family = 4;
+ this.family = PIM.ADDRESS_FAMILY_IP4;
this.encType = 0;
this.reserved = 0;
this.bBit = false;
@@ -83,7 +85,7 @@ public class PIMAddrGroup {
public void setAddr(IpPrefix pfx) {
this.addr = pfx.address();
this.masklen = (byte) pfx.prefixLength();
- this.family = (byte) ((this.addr.isIp4()) ? 4 : 6);
+ this.family = (byte) ((this.addr.isIp4()) ? PIM.ADDRESS_FAMILY_IP4 : PIM.ADDRESS_FAMILY_IP6);
}
/**
@@ -181,9 +183,9 @@ public class PIMAddrGroup {
checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_GROUP_IPV4_BYTE_LENGTH);
this.family = bb.get();
- if (family != 4 && family != 6) {
+ if (family != PIM.ADDRESS_FAMILY_IP4 && family != PIM.ADDRESS_FAMILY_IP6) {
throw new DeserializationException("Illegal IP version number: " + family + "\n");
- } else if (family == 6) {
+ } else if (family == PIM.ADDRESS_FAMILY_IP6) {
// Check for one less by since we have already read the first byte of the packet.
checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_GROUP_IPV6_BYTE_LENGTH - 1);
@@ -201,9 +203,9 @@ public class PIMAddrGroup {
this.reserved |= 0x7d;
this.masklen = bb.get();
- if (this.family == 4) {
+ if (this.family == PIM.ADDRESS_FAMILY_IP4) {
this.addr = IpAddress.valueOf(bb.getInt());
- } else if (this.family == 6) {
+ } else if (this.family == PIM.ADDRESS_FAMILY_IP6) {
this.addr = Ip6Address.valueOf(bb.array(), 2);
}
return this;
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java
index 21526408..762dad56 100644
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrSource.java
@@ -17,9 +17,10 @@ package org.onlab.packet.pim;
import org.onlab.packet.DeserializationException;
import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip6Address;
+import org.onlab.packet.PIM;
import java.nio.ByteBuffer;
@@ -66,7 +67,7 @@ public class PIMAddrSource {
}
private void init() {
- this.family = 4;
+ this.family = PIM.ADDRESS_FAMILY_IP4;
this.encType = 0;
this.reserved = 0;
this.sBit = true;
@@ -92,7 +93,7 @@ public class PIMAddrSource {
public void setAddr(IpPrefix spfx) {
this.addr = spfx.address();
this.masklen = (byte) spfx.prefixLength();
- this.family = (byte) ((this.addr.isIp4()) ? 4 : 6);
+ this.family = (byte) ((this.addr.isIp4()) ? PIM.ADDRESS_FAMILY_IP4 : PIM.ADDRESS_FAMILY_IP6);
}
/**
@@ -156,7 +157,7 @@ public class PIMAddrSource {
*/
public int getByteSize() {
int size = 4;
- size += addr.isIp4() ? 4 : 16;
+ size += addr.isIp4() ? PIM.ADDRESS_FAMILY_IP4 : PIM.ADDRESS_FAMILY_IP6;
return size;
}
@@ -202,9 +203,9 @@ public class PIMAddrSource {
checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_SOURCE_IPV4_BYTE_LENGTH);
this.family = bb.get();
- if (family != 4 && family != 6) {
+ if (family != PIM.ADDRESS_FAMILY_IP4 && family != PIM.ADDRESS_FAMILY_IP6) {
throw new DeserializationException("Illegal IP version number: " + family + "\n");
- } else if (family == 6) {
+ } else if (family == PIM.ADDRESS_FAMILY_IP6) {
// Check for one less by since we have already read the first byte of the packet.
checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_SOURCE_IPV6_BYTE_LENGTH - 1);
@@ -226,9 +227,9 @@ public class PIMAddrSource {
this.reserved &= 0xf8;
this.masklen = bb.get();
- if (this.family == 4) {
+ if (this.family == PIM.ADDRESS_FAMILY_IP4) {
this.addr = IpAddress.valueOf(bb.getInt());
- } else if (this.family == 6) {
+ } else if (this.family == PIM.ADDRESS_FAMILY_IP6) {
this.addr = Ip6Address.valueOf(bb.array(), 2);
}
return this;
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java
index a6ba3895..3327a8e7 100644
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java
+++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/pim/PIMAddrUnicast.java
@@ -15,10 +15,13 @@
*/
package org.onlab.packet.pim;
+
+
import org.onlab.packet.DeserializationException;
import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
import org.onlab.packet.Ip6Address;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.PIM;
import java.nio.ByteBuffer;
@@ -36,7 +39,7 @@ public class PIMAddrUnicast {
* PIM Encoded Source Address.
*/
public PIMAddrUnicast() {
- this.family = 4;
+ this.family = PIM.ADDRESS_FAMILY_IP4;
this.encType = 0;
}
@@ -48,9 +51,9 @@ public class PIMAddrUnicast {
public PIMAddrUnicast(String addr) {
this.addr = IpAddress.valueOf(addr);
if (this.addr.isIp4()) {
- this.family = 4;
+ this.family = PIM.ADDRESS_FAMILY_IP4;
} else {
- this.family = 6;
+ this.family = PIM.ADDRESS_FAMILY_IP6;
}
this.encType = 0;
}
@@ -63,9 +66,9 @@ public class PIMAddrUnicast {
public void setAddr(IpAddress addr) {
this.addr = addr;
if (this.addr.isIp4()) {
- this.family = 4;
+ this.family = PIM.ADDRESS_FAMILY_IP4;
} else {
- this.family = 6;
+ this.family = PIM.ADDRESS_FAMILY_IP6;
}
}
@@ -121,17 +124,17 @@ public class PIMAddrUnicast {
this.family = bb.get();
// If we have IPv6 we need to ensure we have adequate buffer space.
- if (this.family != 4 && this.family != 6) {
+ if (this.family != PIM.ADDRESS_FAMILY_IP4 && this.family != PIM.ADDRESS_FAMILY_IP6) {
throw new DeserializationException("Invalid address family: " + this.family);
- } else if (this.family == 6) {
+ } else if (this.family == PIM.ADDRESS_FAMILY_IP6) {
// Subtract -1 from ENC_UNICAST_IPv6 BYTE_LENGTH because we read one byte for family previously.
checkInput(bb.array(), bb.position(), bb.limit() - bb.position(), ENC_UNICAST_IPV6_BYTE_LENGTH - 1);
}
this.encType = bb.get();
- if (this.family == 4) {
+ if (this.family == PIM.ADDRESS_FAMILY_IP4) {
this.addr = IpAddress.valueOf(bb.getInt());
- } else if (this.family == 6) {
+ } else if (this.family == PIM.ADDRESS_FAMILY_IP6) {
this.addr = Ip6Address.valueOf(bb.array(), 2);
}
return this;
diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java
index add71eb5..919cbd5b 100644
--- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java
+++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Compiler.java
@@ -48,6 +48,7 @@ public class Compiler {
private static final String GROUP = "group";
private static final String STEP = "step";
private static final String PARALLEL = "parallel";
+ private static final String SEQUENTIAL = "sequential";
private static final String DEPENDENCY = "dependency";
private static final String LOG_DIR = "[@logDir]";
@@ -59,12 +60,16 @@ public class Compiler {
private static final String IF = "[@if]";
private static final String UNLESS = "[@unless]";
private static final String VAR = "[@var]";
+ private static final String STARTS = "[@starts]";
+ private static final String ENDS = "[@ends]";
private static final String FILE = "[@file]";
private static final String NAMESPACE = "[@namespace]";
static final String PROP_START = "${";
static final String PROP_END = "}";
+
private static final String HASH = "#";
+ private static final String HASH_PREV = "#-1";
private final Scenario scenario;
@@ -72,7 +77,7 @@ public class Compiler {
private final Map<String, Step> inactiveSteps = Maps.newHashMap();
private final Map<String, String> requirements = Maps.newHashMap();
private final Set<Dependency> dependencies = Sets.newHashSet();
- private final List<Integer> parallels = Lists.newArrayList();
+ private final List<Integer> clonables = Lists.newArrayList();
private ProcessFlow processFlow;
private File logDir;
@@ -175,6 +180,10 @@ public class Compiler {
cfg.configurationsAt(PARALLEL)
.forEach(c -> processParallelGroup(c, namespace, parentGroup));
+ // Scan all sequential groups
+ cfg.configurationsAt(SEQUENTIAL)
+ .forEach(c -> processSequentialGroup(c, namespace, parentGroup));
+
// Scan all dependencies
cfg.configurationsAt(DEPENDENCY)
.forEach(c -> processDependency(c, namespace));
@@ -309,14 +318,62 @@ public class Compiler {
int i = 1;
while (condition(var, i).length() > 0) {
- parallels.add(0, i);
+ clonables.add(0, i);
+ compile(cfg, namespace, parentGroup);
+ clonables.remove(0);
+ i++;
+ }
+ }
+
+ /**
+ * Processes a sequential clone group directive.
+ *
+ * @param cfg hierarchical definition
+ * @param namespace optional namespace
+ * @param parentGroup optional parent group
+ */
+ private void processSequentialGroup(HierarchicalConfiguration cfg,
+ String namespace, Group parentGroup) {
+ String var = cfg.getString(VAR);
+ String starts = cfg.getString(STARTS);
+ String ends = cfg.getString(ENDS);
+ print("sequential var=%s", var);
+
+ int i = 1;
+ while (condition(var, i).length() > 0) {
+ clonables.add(0, i);
compile(cfg, namespace, parentGroup);
- parallels.remove(0);
+ if (i > 1) {
+ processSequentialRequirements(starts, ends, namespace);
+ }
+ clonables.remove(0);
i++;
}
}
/**
+ * Hooks starts of this sequence tier to the previous tier.
+ *
+ * @param starts comma-separated list of start steps
+ * @param ends comma-separated list of end steps
+ * @param namespace optional namespace
+ */
+ private void processSequentialRequirements(String starts, String ends,
+ String namespace) {
+ for (String s : split(starts)) {
+ String start = expand(prefix(s, namespace));
+ String reqs = requirements.get(s);
+ for (String n : split(ends)) {
+ boolean isSoft = n.startsWith("~");
+ String name = n.replaceFirst("^~", "");
+ name = (isSoft ? "~" : "") + expand(prefix(name, namespace));
+ reqs = reqs == null ? name : (reqs + "," + name);
+ }
+ requirements.put(start, reqs);
+ }
+ }
+
+ /**
* Returns the elaborated repetition construct conditional.
*
* @param var repetition var property
@@ -413,9 +470,11 @@ public class Compiler {
String prop = pString.substring(start + PROP_START.length(), end);
String value;
if (prop.equals(HASH)) {
- value = parallels.get(0).toString();
+ value = Integer.toString(clonables.get(0));
+ } else if (prop.equals(HASH_PREV)) {
+ value = Integer.toString(clonables.get(0) - 1);
} else if (prop.endsWith(HASH)) {
- pString = pString.replaceFirst("#}", parallels.get(0).toString() + "}");
+ pString = pString.replaceFirst("#}", clonables.get(0) + "}");
last = start;
continue;
} else {
diff --git a/framework/src/onos/utils/stc/src/test/java/org/onlab/stc/CompilerTest.java b/framework/src/onos/utils/stc/src/test/java/org/onlab/stc/CompilerTest.java
index d70eff08..59b55307 100644
--- a/framework/src/onos/utils/stc/src/test/java/org/onlab/stc/CompilerTest.java
+++ b/framework/src/onos/utils/stc/src/test/java/org/onlab/stc/CompilerTest.java
@@ -69,8 +69,8 @@ public class CompilerTest {
ProcessFlow flow = compiler.processFlow();
assertSame("incorrect scenario", scenario, compiler.scenario());
- assertEquals("incorrect step count", 24, flow.getVertexes().size());
- assertEquals("incorrect dependency count", 16, flow.getEdges().size());
+ assertEquals("incorrect step count", 33, flow.getVertexes().size());
+ assertEquals("incorrect dependency count", 26, flow.getEdges().size());
assertEquals("incorrect logDir",
new File(TEST_DIR.getAbsolutePath(), "foo"), compiler.logDir());
diff --git a/framework/src/onos/utils/stc/src/test/resources/org/onlab/stc/scenario.xml b/framework/src/onos/utils/stc/src/test/resources/org/onlab/stc/scenario.xml
index 34e67fd5..533b11ea 100644
--- a/framework/src/onos/utils/stc/src/test/resources/org/onlab/stc/scenario.xml
+++ b/framework/src/onos/utils/stc/src/test/resources/org/onlab/stc/scenario.xml
@@ -44,4 +44,11 @@
<step name="ding-${#}" exec="asdads" requires="ping-${#},pong-${#}"/>
<dependency name="maybe" requires="ding-${#}"/>
</parallel>
+
+ <sequential var="${TOC#}" requires="alpha" starts="fifi-${#},gigi-${#}" ends="gaga-${#-1}">
+ <step name="fifi-${#}" exec="asdads ${TOC#}"/>
+ <step name="gigi-${#}" exec="asdads"/>
+ <step name="gaga-${#}" exec="asdads" requires="fifi-${#},gigi-${#}"/>
+ <dependency name="maybe" requires="gaga-${#}"/>
+ </sequential>
</scenario> \ No newline at end of file