Implement some of the missing Selector and Match Conditions
Work toward ONOS-509 The following match conditions are added/implemented: - IPV6_EXTHDR Also, fixed the match criteria for the optical signal type to represent unsigned 8 bits integer (per spec). Change-Id: I925db19cb43c5d9f589c1f090b6a75faabe0a19b
Showing
11 changed files
with
247 additions
and
29 deletions
... | @@ -280,6 +280,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -280,6 +280,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
280 | } | 280 | } |
281 | 281 | ||
282 | @Override | 282 | @Override |
283 | + public Builder matchIPv6ExthdrFlags(Integer exthdrFlags) { | ||
284 | + return add(Criteria.matchIPv6ExthdrFlags(exthdrFlags)); | ||
285 | + } | ||
286 | + | ||
287 | + @Override | ||
283 | public Builder matchLambda(Short lambda) { | 288 | public Builder matchLambda(Short lambda) { |
284 | return add(Criteria.matchLambda(lambda)); | 289 | return add(Criteria.matchLambda(lambda)); |
285 | } | 290 | } | ... | ... |
... | @@ -300,6 +300,14 @@ public interface TrafficSelector { | ... | @@ -300,6 +300,14 @@ public interface TrafficSelector { |
300 | public Builder matchMplsLabel(Integer mplsLabel); | 300 | public Builder matchMplsLabel(Integer mplsLabel); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | + * Matches on IPv6 Extension Header pseudo-field fiags. | ||
304 | + * | ||
305 | + * @param exthdrFlags the IPv6 Extension Header pseudo-field fiags | ||
306 | + * @return a selection builder | ||
307 | + */ | ||
308 | + public Builder matchIPv6ExthdrFlags(Integer exthdrFlags); | ||
309 | + | ||
310 | + /** | ||
303 | * Matches an optical signal ID or lambda. | 311 | * Matches an optical signal ID or lambda. |
304 | * | 312 | * |
305 | * @param lambda lamda | 313 | * @param lambda lamda | ... | ... |
... | @@ -62,7 +62,7 @@ public final class Criteria { | ... | @@ -62,7 +62,7 @@ public final class Criteria { |
62 | * @param metadata metadata value (64 bits data) | 62 | * @param metadata metadata value (64 bits data) |
63 | * @return match criterion | 63 | * @return match criterion |
64 | */ | 64 | */ |
65 | - public static Criterion matchMetadata(Long metadata) { | 65 | + public static Criterion matchMetadata(long metadata) { |
66 | return new MetadataCriterion(metadata); | 66 | return new MetadataCriterion(metadata); |
67 | } | 67 | } |
68 | 68 | ||
... | @@ -338,11 +338,22 @@ public final class Criteria { | ... | @@ -338,11 +338,22 @@ public final class Criteria { |
338 | * @param mplsLabel MPLS label (20 bits) | 338 | * @param mplsLabel MPLS label (20 bits) |
339 | * @return match criterion | 339 | * @return match criterion |
340 | */ | 340 | */ |
341 | - public static Criterion matchMplsLabel(Integer mplsLabel) { | 341 | + public static Criterion matchMplsLabel(int mplsLabel) { |
342 | return new MplsCriterion(mplsLabel); | 342 | return new MplsCriterion(mplsLabel); |
343 | } | 343 | } |
344 | 344 | ||
345 | /** | 345 | /** |
346 | + * Creates a match on IPv6 Extension Header pseudo-field fiags. | ||
347 | + * Those are defined in Criterion.IPv6ExthdrFlags. | ||
348 | + * | ||
349 | + * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits) | ||
350 | + * @return match criterion | ||
351 | + */ | ||
352 | + public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) { | ||
353 | + return new IPv6ExthdrFlagsCriterion(exthdrFlags); | ||
354 | + } | ||
355 | + | ||
356 | + /** | ||
346 | * Creates a match on lambda field using the specified value. | 357 | * Creates a match on lambda field using the specified value. |
347 | * | 358 | * |
348 | * @param lambda lambda to match on (16 bits unsigned integer) | 359 | * @param lambda lambda to match on (16 bits unsigned integer) |
... | @@ -355,10 +366,10 @@ public final class Criteria { | ... | @@ -355,10 +366,10 @@ public final class Criteria { |
355 | /** | 366 | /** |
356 | * Creates a match on optical signal type using the specified value. | 367 | * Creates a match on optical signal type using the specified value. |
357 | * | 368 | * |
358 | - * @param sigType optical signal type (16 bits unsigned integer) | 369 | + * @param sigType optical signal type (8 bits unsigned integer) |
359 | * @return match criterion | 370 | * @return match criterion |
360 | */ | 371 | */ |
361 | - public static Criterion matchOpticalSignalType(int sigType) { | 372 | + public static Criterion matchOpticalSignalType(short sigType) { |
362 | return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE); | 373 | return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE); |
363 | } | 374 | } |
364 | 375 | ||
... | @@ -1550,6 +1561,64 @@ public final class Criteria { | ... | @@ -1550,6 +1561,64 @@ public final class Criteria { |
1550 | } | 1561 | } |
1551 | 1562 | ||
1552 | /** | 1563 | /** |
1564 | + * Implementation of IPv6 Extension Header pseudo-field criterion | ||
1565 | + * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags. | ||
1566 | + */ | ||
1567 | + public static final class IPv6ExthdrFlagsCriterion implements Criterion { | ||
1568 | + private static final int MASK = 0xffff; | ||
1569 | + private final int exthdrFlags; // IPv6 Exthdr flags: 16 bits | ||
1570 | + | ||
1571 | + /** | ||
1572 | + * Constructor. | ||
1573 | + * | ||
1574 | + * @param exthdrFlags the IPv6 Extension Header pseudo-field flags | ||
1575 | + * to match (16 bits). Those are defined in Criterion.IPv6ExthdrFlags | ||
1576 | + */ | ||
1577 | + public IPv6ExthdrFlagsCriterion(int exthdrFlags) { | ||
1578 | + this.exthdrFlags = exthdrFlags & MASK; | ||
1579 | + } | ||
1580 | + | ||
1581 | + @Override | ||
1582 | + public Type type() { | ||
1583 | + return Type.IPV6_EXTHDR; | ||
1584 | + } | ||
1585 | + | ||
1586 | + /** | ||
1587 | + * Gets the IPv6 Extension Header pseudo-field flags to match. | ||
1588 | + * | ||
1589 | + * @return the IPv6 Extension Header pseudo-field flags to match | ||
1590 | + * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags | ||
1591 | + */ | ||
1592 | + public int exthdrFlags() { | ||
1593 | + return exthdrFlags; | ||
1594 | + } | ||
1595 | + | ||
1596 | + @Override | ||
1597 | + public String toString() { | ||
1598 | + return toStringHelper(type().toString()) | ||
1599 | + .add("exthdrFlags", Long.toHexString(exthdrFlags)).toString(); | ||
1600 | + } | ||
1601 | + | ||
1602 | + @Override | ||
1603 | + public int hashCode() { | ||
1604 | + return Objects.hash(type(), exthdrFlags); | ||
1605 | + } | ||
1606 | + | ||
1607 | + @Override | ||
1608 | + public boolean equals(Object obj) { | ||
1609 | + if (this == obj) { | ||
1610 | + return true; | ||
1611 | + } | ||
1612 | + if (obj instanceof IPv6ExthdrFlagsCriterion) { | ||
1613 | + IPv6ExthdrFlagsCriterion that = (IPv6ExthdrFlagsCriterion) obj; | ||
1614 | + return Objects.equals(exthdrFlags, that.exthdrFlags) && | ||
1615 | + Objects.equals(this.type(), that.type()); | ||
1616 | + } | ||
1617 | + return false; | ||
1618 | + } | ||
1619 | + } | ||
1620 | + | ||
1621 | + /** | ||
1553 | * Implementation of lambda (wavelength) criterion (16 bits unsigned | 1622 | * Implementation of lambda (wavelength) criterion (16 bits unsigned |
1554 | * integer). | 1623 | * integer). |
1555 | */ | 1624 | */ |
... | @@ -1610,23 +1679,23 @@ public final class Criteria { | ... | @@ -1610,23 +1679,23 @@ public final class Criteria { |
1610 | } | 1679 | } |
1611 | 1680 | ||
1612 | /** | 1681 | /** |
1613 | - * Implementation of optical signal type criterion (16 bits unsigned | 1682 | + * Implementation of optical signal type criterion (8 bits unsigned |
1614 | * integer). | 1683 | * integer). |
1615 | */ | 1684 | */ |
1616 | public static final class OpticalSignalTypeCriterion implements Criterion { | 1685 | public static final class OpticalSignalTypeCriterion implements Criterion { |
1617 | - private static final int MASK = 0xffff; | 1686 | + private static final short MASK = 0xff; |
1618 | - private final int signalType; // Signal type value: 16 bits | 1687 | + private final short signalType; // Signal type value: 8 bits |
1619 | private final Type type; | 1688 | private final Type type; |
1620 | 1689 | ||
1621 | /** | 1690 | /** |
1622 | * Constructor. | 1691 | * Constructor. |
1623 | * | 1692 | * |
1624 | - * @param signalType the optical signal type to match (16 bits unsigned | 1693 | + * @param signalType the optical signal type to match (8 bits unsigned |
1625 | * integer) | 1694 | * integer) |
1626 | * @param type the match type. Should be Type.OCH_SIGTYPE | 1695 | * @param type the match type. Should be Type.OCH_SIGTYPE |
1627 | */ | 1696 | */ |
1628 | - public OpticalSignalTypeCriterion(int signalType, Type type) { | 1697 | + public OpticalSignalTypeCriterion(short signalType, Type type) { |
1629 | - this.signalType = signalType & MASK; | 1698 | + this.signalType = (short) (signalType & MASK); |
1630 | this.type = type; | 1699 | this.type = type; |
1631 | } | 1700 | } |
1632 | 1701 | ||
... | @@ -1638,9 +1707,9 @@ public final class Criteria { | ... | @@ -1638,9 +1707,9 @@ public final class Criteria { |
1638 | /** | 1707 | /** |
1639 | * Gets the optical signal type to match. | 1708 | * Gets the optical signal type to match. |
1640 | * | 1709 | * |
1641 | - * @return the optical signal type to match | 1710 | + * @return the optical signal type to match (8 bits unsigned integer) |
1642 | */ | 1711 | */ |
1643 | - public int signalType() { | 1712 | + public short signalType() { |
1644 | return signalType; | 1713 | return signalType; |
1645 | } | 1714 | } |
1646 | 1715 | ... | ... |
... | @@ -129,11 +129,48 @@ public interface Criterion { | ... | @@ -129,11 +129,48 @@ public interface Criterion { |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * Returns the type of criterion. | 131 | * Returns the type of criterion. |
132 | + * | ||
132 | * @return type of criterion | 133 | * @return type of criterion |
133 | */ | 134 | */ |
134 | public Type type(); | 135 | public Type type(); |
135 | 136 | ||
136 | - // TODO: Create factory class 'Criteria' that will have various factory | 137 | + /** |
137 | - // to create specific criterions. | 138 | + * Bit definitions for IPv6 Extension Header pseudo-field. |
139 | + * From page 79 of OpenFlow 1.5.0 spec. | ||
140 | + */ | ||
141 | + public enum IPv6ExthdrFlags { | ||
142 | + /** "No next header" encountered. */ | ||
143 | + NONEXT(1 << 0), | ||
144 | + /** Encrypted Sec Payload header present. */ | ||
145 | + ESP(1 << 1), | ||
146 | + /** Authentication header present. */ | ||
147 | + AUTH(1 << 2), | ||
148 | + /** 1 or 2 dest headers present. */ | ||
149 | + DEST(1 << 3), | ||
150 | + /** Fragment header present. */ | ||
151 | + FRAG(1 << 4), | ||
152 | + /** Router header present. */ | ||
153 | + ROUTER(1 << 5), | ||
154 | + /** Hop-by-hop header present. */ | ||
155 | + HOP(1 << 6), | ||
156 | + /** Unexpected repeats encountered. */ | ||
157 | + UNREP(1 << 7), | ||
158 | + /** Unexpected sequencing encountered. */ | ||
159 | + UNSEQ(1 << 8); | ||
160 | + | ||
161 | + private int value; | ||
138 | 162 | ||
163 | + IPv6ExthdrFlags(int value) { | ||
164 | + this.value = value; | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * Gets the value as an integer. | ||
169 | + * | ||
170 | + * @return the value as an integer | ||
171 | + */ | ||
172 | + public int getValue() { | ||
173 | + return this.value; | ||
174 | + } | ||
175 | + } | ||
139 | } | 176 | } | ... | ... |
... | @@ -255,6 +255,10 @@ public class DefaultTrafficSelectorTest { | ... | @@ -255,6 +255,10 @@ public class DefaultTrafficSelectorTest { |
255 | assertThat(selector, hasCriterionWithType(Type.MPLS_LABEL)); | 255 | assertThat(selector, hasCriterionWithType(Type.MPLS_LABEL)); |
256 | 256 | ||
257 | selector = DefaultTrafficSelector.builder() | 257 | selector = DefaultTrafficSelector.builder() |
258 | + .matchIPv6ExthdrFlags(Criterion.IPv6ExthdrFlags.NONEXT.getValue()).build(); | ||
259 | + assertThat(selector, hasCriterionWithType(Type.IPV6_EXTHDR)); | ||
260 | + | ||
261 | + selector = DefaultTrafficSelector.builder() | ||
258 | .matchLambda(shortValue).build(); | 262 | .matchLambda(shortValue).build(); |
259 | assertThat(selector, hasCriterionWithType(Type.OCH_SIGID)); | 263 | assertThat(selector, hasCriterionWithType(Type.OCH_SIGID)); |
260 | 264 | ... | ... |
... | @@ -192,14 +192,32 @@ public class CriteriaTest { | ... | @@ -192,14 +192,32 @@ public class CriteriaTest { |
192 | Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1); | 192 | Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1); |
193 | Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2); | 193 | Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2); |
194 | 194 | ||
195 | + int ipv6ExthdrFlags1 = | ||
196 | + Criterion.IPv6ExthdrFlags.NONEXT.getValue() | | ||
197 | + Criterion.IPv6ExthdrFlags.ESP.getValue() | | ||
198 | + Criterion.IPv6ExthdrFlags.AUTH.getValue() | | ||
199 | + Criterion.IPv6ExthdrFlags.DEST.getValue() | | ||
200 | + Criterion.IPv6ExthdrFlags.FRAG.getValue() | | ||
201 | + Criterion.IPv6ExthdrFlags.ROUTER.getValue() | | ||
202 | + Criterion.IPv6ExthdrFlags.HOP.getValue() | | ||
203 | + Criterion.IPv6ExthdrFlags.UNREP.getValue(); | ||
204 | + int ipv6ExthdrFlags2 = ipv6ExthdrFlags1 | | ||
205 | + Criterion.IPv6ExthdrFlags.UNSEQ.getValue(); | ||
206 | + Criterion matchIpv6ExthdrFlags1 = | ||
207 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); | ||
208 | + Criterion sameAsMatchIpv6ExthdrFlags1 = | ||
209 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); | ||
210 | + Criterion matchIpv6ExthdrFlags2 = | ||
211 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags2); | ||
212 | + | ||
195 | int lambda1 = 1; | 213 | int lambda1 = 1; |
196 | int lambda2 = 2; | 214 | int lambda2 = 2; |
197 | Criterion matchLambda1 = Criteria.matchLambda(lambda1); | 215 | Criterion matchLambda1 = Criteria.matchLambda(lambda1); |
198 | Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1); | 216 | Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1); |
199 | Criterion matchLambda2 = Criteria.matchLambda(lambda2); | 217 | Criterion matchLambda2 = Criteria.matchLambda(lambda2); |
200 | 218 | ||
201 | - int signalLambda1 = 1; | 219 | + short signalLambda1 = 1; |
202 | - int signalLambda2 = 2; | 220 | + short signalLambda2 = 2; |
203 | Criterion matchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1); | 221 | Criterion matchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1); |
204 | Criterion sameAsMatchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1); | 222 | Criterion sameAsMatchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1); |
205 | Criterion matchSignalLambda2 = Criteria.matchOpticalSignalType(signalLambda2); | 223 | Criterion matchSignalLambda2 = Criteria.matchOpticalSignalType(signalLambda2); |
... | @@ -256,6 +274,7 @@ public class CriteriaTest { | ... | @@ -256,6 +274,7 @@ public class CriteriaTest { |
256 | assertThatClassIsImmutable(Criteria.IPv6NDTargetAddressCriterion.class); | 274 | assertThatClassIsImmutable(Criteria.IPv6NDTargetAddressCriterion.class); |
257 | assertThatClassIsImmutable(Criteria.IPv6NDLinkLayerAddressCriterion.class); | 275 | assertThatClassIsImmutable(Criteria.IPv6NDLinkLayerAddressCriterion.class); |
258 | assertThatClassIsImmutable(Criteria.MplsCriterion.class); | 276 | assertThatClassIsImmutable(Criteria.MplsCriterion.class); |
277 | + assertThatClassIsImmutable(Criteria.IPv6ExthdrFlagsCriterion.class); | ||
259 | assertThatClassIsImmutable(Criteria.LambdaCriterion.class); | 278 | assertThatClassIsImmutable(Criteria.LambdaCriterion.class); |
260 | assertThatClassIsImmutable(Criteria.OpticalSignalTypeCriterion.class); | 279 | assertThatClassIsImmutable(Criteria.OpticalSignalTypeCriterion.class); |
261 | } | 280 | } |
... | @@ -952,6 +971,35 @@ public class CriteriaTest { | ... | @@ -952,6 +971,35 @@ public class CriteriaTest { |
952 | .testEquals(); | 971 | .testEquals(); |
953 | } | 972 | } |
954 | 973 | ||
974 | + // IPv6ExthdrFlagsCriterion class | ||
975 | + | ||
976 | + /** | ||
977 | + * Test the matchIPv6ExthdrFlags method. | ||
978 | + */ | ||
979 | + @Test | ||
980 | + public void testMatchIPv6ExthdrFlagsMethod() { | ||
981 | + Criterion matchExthdrFlags = | ||
982 | + Criteria.matchIPv6ExthdrFlags(ipv6ExthdrFlags1); | ||
983 | + Criteria.IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = | ||
984 | + checkAndConvert(matchExthdrFlags, | ||
985 | + Criterion.Type.IPV6_EXTHDR, | ||
986 | + Criteria.IPv6ExthdrFlagsCriterion.class); | ||
987 | + assertThat(exthdrFlagsCriterion.exthdrFlags(), | ||
988 | + is(equalTo(ipv6ExthdrFlags1))); | ||
989 | + } | ||
990 | + | ||
991 | + /** | ||
992 | + * Test the equals() method of the IPv6ExthdrFlagsCriterion class. | ||
993 | + */ | ||
994 | + @Test | ||
995 | + public void testIPv6ExthdrFlagsCriterionEquals() { | ||
996 | + new EqualsTester() | ||
997 | + .addEqualityGroup(matchIpv6ExthdrFlags1, | ||
998 | + sameAsMatchIpv6ExthdrFlags1) | ||
999 | + .addEqualityGroup(matchIpv6ExthdrFlags2) | ||
1000 | + .testEquals(); | ||
1001 | + } | ||
1002 | + | ||
955 | // LambdaCriterion class | 1003 | // LambdaCriterion class |
956 | 1004 | ||
957 | /** | 1005 | /** | ... | ... |
... | @@ -410,7 +410,6 @@ public class FlowEntryBuilder { | ... | @@ -410,7 +410,6 @@ public class FlowEntryBuilder { |
410 | case IPV4_SRC: | 410 | case IPV4_SRC: |
411 | if (match.isPartiallyMasked(MatchField.IPV4_SRC)) { | 411 | if (match.isPartiallyMasked(MatchField.IPV4_SRC)) { |
412 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC); | 412 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC); |
413 | - | ||
414 | ip4Prefix = Ip4Prefix.valueOf( | 413 | ip4Prefix = Ip4Prefix.valueOf( |
415 | maskedIp.getValue().getInt(), | 414 | maskedIp.getValue().getInt(), |
416 | maskedIp.getMask().asCidrMaskLength()); | 415 | maskedIp.getMask().asCidrMaskLength()); |
... | @@ -419,13 +418,11 @@ public class FlowEntryBuilder { | ... | @@ -419,13 +418,11 @@ public class FlowEntryBuilder { |
419 | match.get(MatchField.IPV4_SRC).getInt(), | 418 | match.get(MatchField.IPV4_SRC).getInt(), |
420 | Ip4Prefix.MAX_MASK_LENGTH); | 419 | Ip4Prefix.MAX_MASK_LENGTH); |
421 | } | 420 | } |
422 | - | ||
423 | builder.matchIPSrc(ip4Prefix); | 421 | builder.matchIPSrc(ip4Prefix); |
424 | break; | 422 | break; |
425 | case IPV4_DST: | 423 | case IPV4_DST: |
426 | if (match.isPartiallyMasked(MatchField.IPV4_DST)) { | 424 | if (match.isPartiallyMasked(MatchField.IPV4_DST)) { |
427 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST); | 425 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST); |
428 | - | ||
429 | ip4Prefix = Ip4Prefix.valueOf( | 426 | ip4Prefix = Ip4Prefix.valueOf( |
430 | maskedIp.getValue().getInt(), | 427 | maskedIp.getValue().getInt(), |
431 | maskedIp.getMask().asCidrMaskLength()); | 428 | maskedIp.getMask().asCidrMaskLength()); |
... | @@ -434,7 +431,6 @@ public class FlowEntryBuilder { | ... | @@ -434,7 +431,6 @@ public class FlowEntryBuilder { |
434 | match.get(MatchField.IPV4_DST).getInt(), | 431 | match.get(MatchField.IPV4_DST).getInt(), |
435 | Ip4Prefix.MAX_MASK_LENGTH); | 432 | Ip4Prefix.MAX_MASK_LENGTH); |
436 | } | 433 | } |
437 | - | ||
438 | builder.matchIPDst(ip4Prefix); | 434 | builder.matchIPDst(ip4Prefix); |
439 | break; | 435 | break; |
440 | case TCP_SRC: | 436 | case TCP_SRC: |
... | @@ -519,6 +515,10 @@ public class FlowEntryBuilder { | ... | @@ -519,6 +515,10 @@ public class FlowEntryBuilder { |
519 | builder.matchMplsLabel((int) match.get(MatchField.MPLS_LABEL) | 515 | builder.matchMplsLabel((int) match.get(MatchField.MPLS_LABEL) |
520 | .getValue()); | 516 | .getValue()); |
521 | break; | 517 | break; |
518 | + case IPV6_EXTHDR: | ||
519 | + builder.matchIPv6ExthdrFlags((int) match.get(MatchField.IPV6_EXTHDR) | ||
520 | + .getValue()); | ||
521 | + break; | ||
522 | case OCH_SIGID: | 522 | case OCH_SIGID: |
523 | builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber()); | 523 | builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber()); |
524 | break; | 524 | break; |
... | @@ -539,5 +539,4 @@ public class FlowEntryBuilder { | ... | @@ -539,5 +539,4 @@ public class FlowEntryBuilder { |
539 | } | 539 | } |
540 | return builder.build(); | 540 | return builder.build(); |
541 | } | 541 | } |
542 | - | ||
543 | } | 542 | } | ... | ... |
... | @@ -67,6 +67,7 @@ import org.projectfloodlight.openflow.types.OFMetadata; | ... | @@ -67,6 +67,7 @@ import org.projectfloodlight.openflow.types.OFMetadata; |
67 | import org.projectfloodlight.openflow.types.OFPort; | 67 | import org.projectfloodlight.openflow.types.OFPort; |
68 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; | 68 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
69 | import org.projectfloodlight.openflow.types.TransportPort; | 69 | import org.projectfloodlight.openflow.types.TransportPort; |
70 | +import org.projectfloodlight.openflow.types.U16; | ||
70 | import org.projectfloodlight.openflow.types.U32; | 71 | import org.projectfloodlight.openflow.types.U32; |
71 | import org.projectfloodlight.openflow.types.U8; | 72 | import org.projectfloodlight.openflow.types.U8; |
72 | import org.projectfloodlight.openflow.types.VlanPcp; | 73 | import org.projectfloodlight.openflow.types.VlanPcp; |
... | @@ -363,6 +364,12 @@ public abstract class FlowModBuilder { | ... | @@ -363,6 +364,12 @@ public abstract class FlowModBuilder { |
363 | Criteria.MplsCriterion mp = (Criteria.MplsCriterion) c; | 364 | Criteria.MplsCriterion mp = (Criteria.MplsCriterion) c; |
364 | mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label())); | 365 | mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label())); |
365 | break; | 366 | break; |
367 | + case IPV6_EXTHDR: | ||
368 | + Criteria.IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = | ||
369 | + (Criteria.IPv6ExthdrFlagsCriterion) c; | ||
370 | + mBuilder.setExact(MatchField.IPV6_EXTHDR, | ||
371 | + U16.of(exthdrFlagsCriterion.exthdrFlags())); | ||
372 | + break; | ||
366 | case OCH_SIGID: | 373 | case OCH_SIGID: |
367 | LambdaCriterion lc = (LambdaCriterion) c; | 374 | LambdaCriterion lc = (LambdaCriterion) c; |
368 | mBuilder.setExact(MatchField.OCH_SIGID, | 375 | mBuilder.setExact(MatchField.OCH_SIGID, |
... | @@ -373,14 +380,13 @@ public abstract class FlowModBuilder { | ... | @@ -373,14 +380,13 @@ public abstract class FlowModBuilder { |
373 | Criteria.OpticalSignalTypeCriterion sc = | 380 | Criteria.OpticalSignalTypeCriterion sc = |
374 | (Criteria.OpticalSignalTypeCriterion) c; | 381 | (Criteria.OpticalSignalTypeCriterion) c; |
375 | mBuilder.setExact(MatchField.OCH_SIGTYPE, | 382 | mBuilder.setExact(MatchField.OCH_SIGTYPE, |
376 | - U8.of((short) sc.signalType())); | 383 | + U8.of(sc.signalType())); |
377 | break; | 384 | break; |
378 | case ARP_OP: | 385 | case ARP_OP: |
379 | case ARP_SHA: | 386 | case ARP_SHA: |
380 | case ARP_SPA: | 387 | case ARP_SPA: |
381 | case ARP_THA: | 388 | case ARP_THA: |
382 | case ARP_TPA: | 389 | case ARP_TPA: |
383 | - case IPV6_EXTHDR: | ||
384 | case MPLS_BOS: | 390 | case MPLS_BOS: |
385 | case MPLS_TC: | 391 | case MPLS_TC: |
386 | case PBB_ISID: | 392 | case PBB_ISID: | ... | ... |
... | @@ -71,6 +71,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> { | ... | @@ -71,6 +71,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> { |
71 | formatMap.put(Criterion.Type.IPV6_ND_SLL, new FormatV6NDTll()); | 71 | formatMap.put(Criterion.Type.IPV6_ND_SLL, new FormatV6NDTll()); |
72 | formatMap.put(Criterion.Type.IPV6_ND_TLL, new FormatV6NDTll()); | 72 | formatMap.put(Criterion.Type.IPV6_ND_TLL, new FormatV6NDTll()); |
73 | formatMap.put(Criterion.Type.MPLS_LABEL, new FormatMplsLabel()); | 73 | formatMap.put(Criterion.Type.MPLS_LABEL, new FormatMplsLabel()); |
74 | + formatMap.put(Criterion.Type.IPV6_EXTHDR, new FormatIpV6Exthdr()); | ||
74 | formatMap.put(Criterion.Type.OCH_SIGID, new FormatOchSigId()); | 75 | formatMap.put(Criterion.Type.OCH_SIGID, new FormatOchSigId()); |
75 | formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType()); | 76 | formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType()); |
76 | 77 | ||
... | @@ -84,7 +85,6 @@ public final class CriterionCodec extends JsonCodec<Criterion> { | ... | @@ -84,7 +85,6 @@ public final class CriterionCodec extends JsonCodec<Criterion> { |
84 | formatMap.put(Criterion.Type.MPLS_BOS, new FormatUnknown()); | 85 | formatMap.put(Criterion.Type.MPLS_BOS, new FormatUnknown()); |
85 | formatMap.put(Criterion.Type.PBB_ISID, new FormatUnknown()); | 86 | formatMap.put(Criterion.Type.PBB_ISID, new FormatUnknown()); |
86 | formatMap.put(Criterion.Type.TUNNEL_ID, new FormatUnknown()); | 87 | formatMap.put(Criterion.Type.TUNNEL_ID, new FormatUnknown()); |
87 | - formatMap.put(Criterion.Type.IPV6_EXTHDR, new FormatUnknown()); | ||
88 | formatMap.put(Criterion.Type.UNASSIGNED_40, new FormatUnknown()); | 88 | formatMap.put(Criterion.Type.UNASSIGNED_40, new FormatUnknown()); |
89 | formatMap.put(Criterion.Type.PBB_UCA, new FormatUnknown()); | 89 | formatMap.put(Criterion.Type.PBB_UCA, new FormatUnknown()); |
90 | formatMap.put(Criterion.Type.TCP_FLAGS, new FormatUnknown()); | 90 | formatMap.put(Criterion.Type.TCP_FLAGS, new FormatUnknown()); |
... | @@ -289,6 +289,15 @@ public final class CriterionCodec extends JsonCodec<Criterion> { | ... | @@ -289,6 +289,15 @@ public final class CriterionCodec extends JsonCodec<Criterion> { |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | + private static class FormatIpV6Exthdr implements CriterionTypeFormatter { | ||
293 | + @Override | ||
294 | + public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { | ||
295 | + final Criteria.IPv6ExthdrFlagsCriterion exthdrCriterion = | ||
296 | + (Criteria.IPv6ExthdrFlagsCriterion) criterion; | ||
297 | + return root.put("exthdrFlags", exthdrCriterion.exthdrFlags()); | ||
298 | + } | ||
299 | + } | ||
300 | + | ||
292 | private static class FormatOchSigId implements CriterionTypeFormatter { | 301 | private static class FormatOchSigId implements CriterionTypeFormatter { |
293 | @Override | 302 | @Override |
294 | public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { | 303 | public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { | ... | ... |
... | @@ -407,6 +407,27 @@ public class CriterionCodecTest { | ... | @@ -407,6 +407,27 @@ public class CriterionCodecTest { |
407 | } | 407 | } |
408 | 408 | ||
409 | /** | 409 | /** |
410 | + * Tests IPv6 Extension Header pseudo-field flags criterion. | ||
411 | + */ | ||
412 | + @Test | ||
413 | + public void matchIPv6ExthdrFlagsTest() { | ||
414 | + int exthdrFlags = | ||
415 | + Criterion.IPv6ExthdrFlags.NONEXT.getValue() | | ||
416 | + Criterion.IPv6ExthdrFlags.ESP.getValue() | | ||
417 | + Criterion.IPv6ExthdrFlags.AUTH.getValue() | | ||
418 | + Criterion.IPv6ExthdrFlags.DEST.getValue() | | ||
419 | + Criterion.IPv6ExthdrFlags.FRAG.getValue() | | ||
420 | + Criterion.IPv6ExthdrFlags.ROUTER.getValue() | | ||
421 | + Criterion.IPv6ExthdrFlags.HOP.getValue() | | ||
422 | + Criterion.IPv6ExthdrFlags.UNREP.getValue() | | ||
423 | + Criterion.IPv6ExthdrFlags.UNSEQ.getValue(); | ||
424 | + Criterion criterion = Criteria.matchIPv6ExthdrFlags(exthdrFlags); | ||
425 | + ObjectNode result = criterionCodec.encode(criterion, context); | ||
426 | + assertThat(result.get("type").textValue(), is(criterion.type().toString())); | ||
427 | + assertThat(result.get("exthdrFlags").asInt(), is(exthdrFlags)); | ||
428 | + } | ||
429 | + | ||
430 | + /** | ||
410 | * Tests lambda criterion. | 431 | * Tests lambda criterion. |
411 | */ | 432 | */ |
412 | @Test | 433 | @Test |
... | @@ -422,10 +443,10 @@ public class CriterionCodecTest { | ... | @@ -422,10 +443,10 @@ public class CriterionCodecTest { |
422 | */ | 443 | */ |
423 | @Test | 444 | @Test |
424 | public void matchOpticalSignalTypeTest() { | 445 | public void matchOpticalSignalTypeTest() { |
425 | - Criterion criterion = Criteria.matchOpticalSignalType((short) 40000); | 446 | + Criterion criterion = Criteria.matchOpticalSignalType((byte) 250); |
426 | ObjectNode result = criterionCodec.encode(criterion, context); | 447 | ObjectNode result = criterionCodec.encode(criterion, context); |
427 | assertThat(result.get("type").textValue(), is(criterion.type().toString())); | 448 | assertThat(result.get("type").textValue(), is(criterion.type().toString())); |
428 | - assertThat(result.get("signalType").asInt(), is(40000)); | 449 | + assertThat(result.get("signalType").asInt(), is(250)); |
429 | } | 450 | } |
430 | 451 | ||
431 | } | 452 | } | ... | ... |
... | @@ -294,6 +294,18 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -294,6 +294,18 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
294 | } | 294 | } |
295 | break; | 295 | break; |
296 | 296 | ||
297 | + case IPV6_EXTHDR: | ||
298 | + final Criteria.IPv6ExthdrFlagsCriterion exthdrCriterion = | ||
299 | + (Criteria.IPv6ExthdrFlagsCriterion) criterion; | ||
300 | + final int exthdrFlags = exthdrCriterion.exthdrFlags(); | ||
301 | + final int jsonExthdrFlags = | ||
302 | + jsonCriterion.get("exthdrFlags").intValue(); | ||
303 | + if (exthdrFlags != jsonExthdrFlags) { | ||
304 | + description.appendText("exthdrFlags was " + Long.toHexString(jsonExthdrFlags)); | ||
305 | + return false; | ||
306 | + } | ||
307 | + break; | ||
308 | + | ||
297 | case OCH_SIGID: | 309 | case OCH_SIGID: |
298 | final Criteria.LambdaCriterion lambdaCriterion = | 310 | final Criteria.LambdaCriterion lambdaCriterion = |
299 | (Criteria.LambdaCriterion) criterion; | 311 | (Criteria.LambdaCriterion) criterion; |
... | @@ -308,10 +320,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -308,10 +320,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
308 | case OCH_SIGTYPE: | 320 | case OCH_SIGTYPE: |
309 | final Criteria.OpticalSignalTypeCriterion opticalSignalTypeCriterion = | 321 | final Criteria.OpticalSignalTypeCriterion opticalSignalTypeCriterion = |
310 | (Criteria.OpticalSignalTypeCriterion) criterion; | 322 | (Criteria.OpticalSignalTypeCriterion) criterion; |
311 | - final int signalType = opticalSignalTypeCriterion.signalType(); | 323 | + final short signalType = opticalSignalTypeCriterion.signalType(); |
312 | - final int jsonSignalType = jsonCriterion.get("signalType").intValue(); | 324 | + final short jsonSignalType = jsonCriterion.get("signalType").shortValue(); |
313 | if (signalType != jsonSignalType) { | 325 | if (signalType != jsonSignalType) { |
314 | - description.appendText("signal type was " + Integer.toString(signalType)); | 326 | + description.appendText("signal type was " + Short.toString(signalType)); |
315 | return false; | 327 | return false; |
316 | } | 328 | } |
317 | break; | 329 | break; | ... | ... |
-
Please register or login to post a comment