use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class MapRegisterSerializationTest method deserialize__Locators.
@Test
public void deserialize__Locators() throws Exception {
MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 " + //
"FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 " + //
"66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 " + //
"00 00 00 0a " + //
"03 " + // Locator Count
"20 10 00 00 00 00 01 99 10 fe 01 " + // Locator 1
"01 64 1f 00 " + // priorities + weights
"00 05 " + // Flags
"00 01 c0 a8 88 0a " + // Locator 2
"67 00 30 34 " + // priorities + weights
"00 02 " + // Flags
"00 01 cc aa AA 11 " + // Locator 3
"60 11 34 A4 " + // priorities + weights
"00 03 " + // Flags
"00 01 c0 a8 88 0a "), null);
assertEquals(1, mr.getMappingRecordItem().size());
MappingRecordItem eidToLocator = mr.getMappingRecordItem().get(0);
assertEquals(3, eidToLocator.getMappingRecord().getLocatorRecord().size());
LocatorRecord loc0 = eidToLocator.getMappingRecord().getLocatorRecord().get(0);
LocatorRecord loc1 = eidToLocator.getMappingRecord().getLocatorRecord().get(1);
LocatorRecord loc2 = eidToLocator.getMappingRecord().getLocatorRecord().get(2);
assertEquals((byte) 0x01, loc0.getPriority().byteValue());
assertEquals((byte) 0x67, loc1.getPriority().byteValue());
assertEquals((byte) 0x60, loc2.getPriority().byteValue());
assertEquals((byte) 0x64, loc0.getWeight().byteValue());
assertEquals((byte) 0x00, loc1.getWeight().byteValue());
assertEquals((byte) 0x11, loc2.getWeight().byteValue());
assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
assertTrue(loc0.isLocalLocator());
assertFalse(loc1.isLocalLocator());
assertFalse(loc2.isLocalLocator());
assertFalse(loc0.isRlocProbed());
assertTrue(loc1.isRlocProbed());
assertTrue(loc2.isRlocProbed());
assertTrue(loc0.isRouted());
assertFalse(loc1.isRouted());
assertTrue(loc2.isRouted());
assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class MapRegisterSerializationTest method serialize__deserialize.
@Test
public void serialize__deserialize() throws Exception {
MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32"));
mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
recordBuilder.setAction(Action.NoAction);
recordBuilder.setMapVersion((short) 0);
recordBuilder.setRecordTtl(0);
mrBuilder.setNonce(6161616161L);
mrBuilder.setKeyId((short) 0x0001);
mrBuilder.setWantMapNotify(true);
mrBuilder.setProxyMapReply(true);
byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
mrBuilder.setAuthenticationData(authenticationData);
MapRegister mapRegister = mrBuilder.build();
ArrayAssert.assertEquals(MapRegisterSerializer.getInstance().serialize(mapRegister).array(), MapRegisterSerializer.getInstance().serialize(MapRegisterSerializer.getInstance().deserialize(MapRegisterSerializer.getInstance().serialize(mapRegister), null)).array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class Stringifier method getString.
public static String getString(MappingRecord mapping, int indentation) {
final String indent = getSpacesAsString(indentation);
StringBuilder mrsb = new StringBuilder(indent);
// Main information, EID prefix and TTL (for now)
mrsb.append(LispAddressStringifier.getString(mapping.getEid()));
mrsb.append(", TTL: ");
mrsb.append(mapping.getRecordTtl().toString());
mrsb.append(NEW_LINE);
// Locator records
// Regular indentation for the mapping record
mrsb.append(indent);
// Extra indentation for locator records
mrsb.append(indent);
if (mapping.getLocatorRecord() == null || mapping.getLocatorRecord().isEmpty()) {
// We only print the action for negative mappings (0 locator records)
mrsb.append("-> Negative entry, action: ");
mrsb.append(mapping.getAction().getName());
} else {
mrsb.append("-> Locator State Pri/Wgt");
mrsb.append(NEW_LINE);
mrsb.append(indent);
boolean first = true;
for (LocatorRecord record : mapping.getLocatorRecord()) {
if (first) {
first = false;
} else {
mrsb.append(NEW_LINE);
mrsb.append(indent);
}
mrsb.append(getString(record, indentation + 3));
}
}
return mrsb.toString();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asLocatorRecords.
/**
* Tests {@link LispAddressUtil#asLocatorRecords(List)} method.
*/
@Test
public void asLocatorRecords() {
final List<Rloc> expectedRlocs = Arrays.asList(LispAddressUtil.toRloc(IPV4_ADDRESS_TEST), LispAddressUtil.toRloc(IPV6_ADDRESS_TEST));
final List<LocatorRecord> locatorRecords = LispAddressUtil.asLocatorRecords(expectedRlocs);
assertEquals(expectedRlocs.size(), locatorRecords.size());
for (Rloc rloc : expectedRlocs) {
assertTrue("Rloc " + rloc + " should be part of " + "locator records list list", isRlocInLocatorRecords(locatorRecords, rloc));
}
for (LocatorRecord locatorRecord : locatorRecords) {
assertFalse(locatorRecord.isLocalLocator());
assertFalse(locatorRecord.isRlocProbed());
assertTrue(locatorRecord.isRouted());
assertTrue(1 == locatorRecord.getWeight());
assertTrue(1 == locatorRecord.getPriority());
assertTrue(1 == locatorRecord.getMulticastWeight());
assertTrue(1 == locatorRecord.getMulticastPriority());
assertEquals("SFC_LISP", locatorRecord.getLocatorId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord in project lispflowmapping by opendaylight.
the class LocatorRecordSerializer method deserialize.
protected LocatorRecord deserialize(ByteBuffer buffer) {
LocatorRecordBuilder builder = new LocatorRecordBuilder();
builder.setPriority((short) ByteUtil.getUnsignedByte(buffer));
builder.setWeight((short) ByteUtil.getUnsignedByte(buffer));
builder.setMulticastPriority((short) ByteUtil.getUnsignedByte(buffer));
builder.setMulticastWeight((short) ByteUtil.getUnsignedByte(buffer));
byte flags = (byte) buffer.getShort();
builder.setLocalLocator(ByteUtil.extractBit(flags, Flags.LOCAL_LOCATOR));
builder.setRlocProbed(ByteUtil.extractBit(flags, Flags.RLOC_PROBED));
builder.setRouted(ByteUtil.extractBit(flags, Flags.ROUTED));
Rloc rloc = LispAddressSerializer.getInstance().deserializeRloc(buffer);
builder.setRloc(rloc);
builder.setLocatorId(LispAddressStringifier.getString(rloc));
return builder.build();
}
Aggregations