use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpPrefix_ipv4.
/**
* Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link
* LispAddressUtil#addressTypeFromIpPrefix(IpPrefix)}
* methods with ipv4 address.
*/
@Test
public void addressFromIpPrefix_ipv4() {
IpPrefix ipv4Prefix = new IpPrefix(new Ipv4Prefix(IPV4_ADDRESS_PREFIX_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(ipv4Prefix);
assertEquals(Ipv4PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromIpPrefix(ipv4Prefix);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix);
assertEquals(IPV4_ADDRESS_PREFIX_VALUE_TEST, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) address).getIpv4Prefix().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project lispflowmapping by opendaylight.
the class Ipv4PrefixSerializer method serializeData.
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
Ipv4Prefix prefix = (Ipv4Prefix) lispAddress.getAddress();
String address = MaskUtil.getAddressStringForIpv4Prefix(prefix);
buffer.put(InetAddresses.forString(address).getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project lispflowmapping by opendaylight.
the class LispAddressUtil method toEid.
public static Eid toEid(Ipv4Prefix prefix, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddressType(Ipv4PrefixAfi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress((Address) new Ipv4PrefixBuilder().setIpv4Prefix(prefix).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project lispflowmapping by opendaylight.
the class MultiTableMapCacheTest method getMappingTest_withIpv4Prefix.
/**
* Tests {@link MultiTableMapCache#getMapping} with Ipv4Prefix address type.
*/
@Test
public void getMappingTest_withIpv4Prefix() {
final Eid key = MaskUtil.normalize(EID_IPV4_PREFIX_DST, (short) 24);
final Eid key2 = MaskUtil.normalize(MaskUtil.normalize(EID_IPV4_PREFIX_SRC), (short) 24);
final Map<String, Object> entry = getEntry1();
final Map<String, Object> entry2 = getEntry2();
when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
when(tableDaoMock.getBest(key)).thenReturn(entry);
when(srcDstDaoMock.getBest(LispAddressUtil.asIpPrefixBinaryEid(key2))).thenReturn(entry2);
assertEquals(DUMMY_OBJECT_2, multiTableMapCache.getMapping(EID_IPV4_PREFIX_SRC, EID_IPV4_PREFIX_DST));
assertEquals(DUMMY_OBJECT, multiTableMapCache.getMapping(null, EID_IPV4_PREFIX_DST));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__SegmentLCAF.
public void registerAndQuery__SegmentLCAF() throws SocketTimeoutException {
cleanUP();
String ipString = "10.20.255.30";
int instanceId = 6;
EidBuilder eb = new EidBuilder();
eb.setAddressType(Ipv4PrefixAfi.class);
eb.setVirtualNetworkId(new InstanceIdType((long) instanceId));
eb.setAddress(new Ipv4PrefixBuilder().setIpv4Prefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix(ipString)).build());
MapReply reply = registerAddressAndQuery(eb.build());
Eid receivedAddress = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(Ipv4PrefixAfi.class, receivedAddress.getAddressType());
assertEquals(ipString, ((Ipv4Prefix) receivedAddress.getAddress()).getIpv4Prefix().getValue());
assertEquals(instanceId, receivedAddress.getVirtualNetworkId().getValue().intValue());
}
Aggregations