use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class ExplicitLocatorPathSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
List<Hop> hops = new ArrayList<Hop>();
hops.add(new HopBuilder().setAddress(SimpleAddressBuilder.getDefaultInstance("170.187.204.221")).build());
hops.add(new HopBuilder().setAddress(SimpleAddressBuilder.getDefaultInstance("17.34.51.68")).build());
ExplicitLocatorPathBuilder elpb = new ExplicitLocatorPathBuilder();
elpb.setHop(hops);
RlocBuilder rb = new RlocBuilder();
rb.setAddressType(ExplicitLocatorPathLcaf.class);
rb.setVirtualNetworkId(null);
rb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder().setExplicitLocatorPath(elpb.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build()));
LispAddressSerializer.getInstance().serialize(buf, rb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"0A 00 00 10 " + // IPv4
"00 00 00 01 AA BB CC DD " + // IPv4
"00 00 00 01 11 22 33 44");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class InstanceIdSerializerTest method deserialize__Simple.
@Test
public void deserialize__Simple() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"02 20 00 0A " + // instance ID
"00 BB CC DD " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44"), new LispAddressSerializerContext(null));
assertEquals(Ipv4BinaryAfi.class, address.getAddressType());
Ipv4Binary ipv4 = (Ipv4Binary) address.getAddress();
assertArrayEquals(new byte[] { 0x11, 0x22, 0x33, 0x44 }, ipv4.getIpv4Binary().getValue());
assertEquals(0x00BBCCDD, address.getVirtualNetworkId().getValue().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class KeyValueAddressSerializerTest method deserialize__Simple.
@Test
public void deserialize__Simple() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"0F 20 00 0C " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44 " + "00 01 22 33 44 55"), // AFI=1, IP=0x22334455
null);
assertEquals(KeyValueAddressLcaf.class, address.getAddressType());
KeyValueAddress srcDestAddress = (KeyValueAddress) address.getAddress();
assertEquals("17.34.51.68", String.valueOf(srcDestAddress.getKeyValueAddress().getKey().getValue()));
assertEquals("34.51.68.85", String.valueOf(srcDestAddress.getKeyValueAddress().getValue().getValue()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class KeyValueAddressSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
KeyValueAddressBuilder addressBuilder = new KeyValueAddressBuilder();
addressBuilder.setKey(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
addressBuilder.setValue(new SimpleAddress(new IpAddress(new Ipv4Address("34.51.68.85"))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(KeyValueAddressLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddressBuilder().setKeyValueAddress(addressBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
LispAddressSerializer.getInstance().serialize(buf, eb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"0F 00 00 0C " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44 " + // AFI=1, IP=0x22334455
"00 01 22 33 44 55");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class SourceDestKeySerializerTest method deserialize__Simple.
@Test
public void deserialize__Simple() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"0C 20 00 10 " + // reserved + masks
"00 00 10 18 " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44 " + // AFI=1, IP=0x22334455
"00 01 22 33 44 55"), new LispAddressSerializerContext(null));
assertEquals(SourceDestKeyLcaf.class, address.getAddressType());
SourceDestKey srcDestAddress = (SourceDestKey) address.getAddress();
assertEquals((byte) 0x10, MaskUtil.getMaskForAddress(srcDestAddress.getSourceDestKey().getSource()));
assertEquals((byte) 0x18, MaskUtil.getMaskForAddress(srcDestAddress.getSourceDestKey().getDest()));
assertEquals("17.34.51.68/16", String.valueOf(srcDestAddress.getSourceDestKey().getSource().getValue()));
assertEquals("34.51.68.85/24", String.valueOf(srcDestAddress.getSourceDestKey().getDest().getValue()));
}
Aggregations