use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asBinaryEidTest_ipv4Prefix.
/**
* Tests {@link LispAddressUtil#asBinaryEid(SimpleAddress, InstanceIdType)} method with ipv4Prefix.
*/
@Test
public void asBinaryEidTest_ipv4Prefix() {
final Eid result = LispAddressUtil.asBinaryEid(SIMPLE_ADDRESS_IPV4_PREFIX_TEST, INSTANCE_ID_TYPE_TEST);
assertEquals(IPV4_ADDRESS_PREFIX_BINARY_EID_1, result);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class SourceDestKeySerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
SourceDestKeyBuilder addressBuilder = new SourceDestKeyBuilder();
addressBuilder.setSource(new SimpleAddress(new IpPrefix(new Ipv4Prefix("17.34.51.68/8"))));
addressBuilder.setDest(new SimpleAddress(new IpPrefix(new Ipv4Prefix("34.51.68.85/16"))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(SourceDestKeyLcaf.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.SourceDestKeyBuilder().setSourceDestKey(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 " + //
"0C 00 00 10 " + // reserved + masks
"00 00 08 10 " + // 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class LispAddressUtil method toRloc.
public static Rloc toRloc(SimpleAddress address) {
RlocBuilder builder = new RlocBuilder();
builder.setAddressType(addressTypeFromSimpleAddress(address));
builder.setVirtualNetworkId(null);
builder.setAddress(addressFromSimpleAddress(address));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class LispAddressUtil method asEid.
public static Eid asEid(SimpleAddress address, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddressType(addressTypeFromSimpleAddress(address));
builder.setVirtualNetworkId(vni);
// XXX Not sure if the below actually works as expected... also, what happens to AFI?
builder.setAddress(addressFromSimpleAddress(address));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class MappingSystem method updateServicePathMappingRecord.
private MappingData updateServicePathMappingRecord(MappingData mappingData, Eid eid) {
// keep properties of original record
MappingRecordBuilder recordBuilder = new MappingRecordBuilder(mappingData.getRecord());
recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
// there should only be one locator record
if (mappingData.getRecord().getLocatorRecord().size() != 1) {
LOG.warn("MappingRecord associated to ServicePath EID has more than one locator!");
return mappingData;
}
LocatorRecord locatorRecord = mappingData.getRecord().getLocatorRecord().get(0);
long serviceIndex = ((ServicePath) eid.getAddress()).getServicePath().getServiceIndex();
int index = LispAddressUtil.STARTING_SERVICE_INDEX - (int) serviceIndex;
Rloc rloc = locatorRecord.getRloc();
if (rloc.getAddress() instanceof Ipv4 || rloc.getAddress() instanceof Ipv6) {
if (index != 0) {
LOG.warn("Service Index should be 255 for simple IP RLOCs!");
}
return mappingData;
} else if (rloc.getAddress() instanceof ExplicitLocatorPath) {
ExplicitLocatorPath elp = (ExplicitLocatorPath) rloc.getAddress();
List<Hop> hops = elp.getExplicitLocatorPath().getHop();
if (index < 0 || index > hops.size()) {
LOG.warn("Service Index out of bounds!");
return mappingData;
}
SimpleAddress nextHop = hops.get(index).getAddress();
LocatorRecordBuilder lrb = new LocatorRecordBuilder(locatorRecord);
lrb.setRloc(LispAddressUtil.toRloc(nextHop));
recordBuilder.getLocatorRecord().add(lrb.build());
return new MappingData(recordBuilder.build());
} else {
LOG.warn("Nothing to do with ServicePath mapping record");
return mappingData;
}
}
Aggregations