blob: 39e8c0c8e14fbc583c0ec0d1234ba5dd7fbc9a72 [file] [log] [blame]
alshabib1f44e8e2014-08-14 15:19:57 -07001package org.projectfloodlight.protocol;
2
3import static org.junit.Assert.assertFalse;
4import static org.junit.Assert.assertThat;
5
6import org.hamcrest.CoreMatchers;
7import org.junit.Before;
8import org.junit.Test;
9import org.projectfloodlight.openflow.protocol.OFFactories;
10import org.projectfloodlight.openflow.protocol.OFOxmList;
11import org.projectfloodlight.openflow.protocol.OFVersion;
12import org.projectfloodlight.openflow.protocol.match.MatchField;
13import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6DstMasked;
14import org.projectfloodlight.openflow.protocol.oxm.OFOxmIpv6SrcMasked;
15import org.projectfloodlight.openflow.protocol.oxm.OFOxms;
16import org.projectfloodlight.openflow.types.IPv6AddressWithMask;
17
18public 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}