tom | 7ef8ff9 | 2014-09-17 13:08:06 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.protocol; |
| 2 | |
| 3 | import static org.junit.Assert.assertFalse; |
| 4 | import static org.junit.Assert.assertThat; |
| 5 | |
| 6 | import org.hamcrest.CoreMatchers; |
| 7 | import org.junit.Before; |
| 8 | import org.junit.Test; |
| 9 | import org.projectfloodlight.openflow.protocol.OFFactories; |
| 10 | import org.projectfloodlight.openflow.protocol.OFOxmList; |
| 11 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 12 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
| 13 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6DstMasked; |
| 14 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6SrcMasked; |
| 15 | import org.projectfloodlight.openflow.protocol.oxm.OFOxms; |
| 16 | import org.projectfloodlight.openflow.types.IPv6AddressWithMask; |
| 17 | |
| 18 | public class OFOxmListTest { |
| 19 | private OFOxms oxms; |
| 20 | |
| 21 | @Before |
| 22 | public void setup() { |
| 23 | oxms = OFFactories.getFactory(OFVersion.OF_13).oxms(); |
| 24 | } |
| 25 | |
| 26 | @Test |
| 27 | public void testCanonicalize() { |
| 28 | OFOxmList.Builder builder = new OFOxmList.Builder(); |
| 29 | IPv6AddressWithMask fullMasked = IPv6AddressWithMask.of("::/0"); |
| 30 | OFOxmIpv6DstMasked fullMaskedOxm = oxms.ipv6DstMasked(fullMasked.getValue(), fullMasked.getMask()); |
| 31 | builder.set(fullMaskedOxm); |
| 32 | |
| 33 | IPv6AddressWithMask address= IPv6AddressWithMask.of("1:2:3:4:5:6::8"); |
| 34 | OFOxmIpv6SrcMasked addressSrcOxm = oxms.ipv6SrcMasked(address.getValue(), address.getMask()); |
| 35 | builder.set(addressSrcOxm); |
| 36 | |
| 37 | OFOxmList list = builder.build(); |
| 38 | assertThat(list.get(MatchField.IPV6_DST), CoreMatchers.nullValue()); |
| 39 | assertFalse(list.get(MatchField.IPV6_SRC).isMasked()); |
| 40 | } |
| 41 | } |