use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class DefaultLispGenericLocator method deserialize.
/**
* Deserializes LispGenericLocator message portion.
*
* @param byteBuf byte buffer
* @return LispGenericLocator
* @throws LispParseError LISP message parse error
* @throws LispReaderException LISP message reader exception
*/
public static LispGenericLocator deserialize(ByteBuf byteBuf) throws LispParseError, LispReaderException {
// priority -> 8 bits
byte priority = (byte) byteBuf.readUnsignedByte();
// weight -> 8 bits
byte weight = (byte) byteBuf.readUnsignedByte();
// multi-cast priority -> 8 bits
byte multicastPriority = (byte) byteBuf.readUnsignedByte();
// multi-cast weight -> 8 bits
byte multicastWeight = (byte) byteBuf.readUnsignedByte();
// let's skip unused flags
byteBuf.skipBytes(SKIP_UNUSED_FLAG_LENGTH);
byte flags = byteBuf.readByte();
// local locator flag -> 1 bit
boolean localLocator = ByteOperator.getBit(flags, LOCAL_LOCATOR_INDEX);
// rloc probe flag -> 1 bit
boolean rlocProbed = ByteOperator.getBit(flags, RLOC_PROBED_INDEX);
// routed flag -> 1 bit
boolean routed = ByteOperator.getBit(flags, ROUTED_INDEX);
LispAfiAddress address = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
return new DefaultLispGenericLocator(priority, weight, multicastPriority, multicastWeight, localLocator, rlocProbed, routed, address);
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class DefaultLispInfo method deserialize.
public static LispInfo deserialize(ByteBuf byteBuf) throws LispParseError, LispReaderException {
if (byteBuf.readerIndex() != 0) {
return null;
}
// infoReply -> 1 bit
boolean infoReplyFlag = ByteOperator.getBit(byteBuf.readByte(), INFO_REPLY_INDEX);
// let's skip the reserved field
byteBuf.skipBytes(RESERVED_SKIP_LENGTH_1);
// nonce -> 64 bits
long nonce = byteBuf.readLong();
// keyId -> 16 bits
short keyId = byteBuf.readShort();
// authenticationDataLength -> 16 bits
short authLength = byteBuf.readShort();
// authData -> depends on the authenticationDataLength
byte[] authData = new byte[authLength];
byteBuf.readBytes(authData);
// ttl -> 32 bits
int ttl = byteBuf.readInt();
// let's skip the reserved field
byteBuf.skipBytes(RESERVED_SKIP_LENGTH_2);
// mask length -> 8 bits
short maskLength = byteBuf.readUnsignedByte();
LispAfiAddress prefix = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
return new DefaultLispInfo(infoReplyFlag, nonce, keyId, authLength, authData, ttl, (byte) maskLength, prefix);
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class LispListLcafAddress method checkAddressValidity.
/**
* Checks the validity of a collection of input addresses.
*
* @param addresses a collection of addresses
* @return validity result
*/
private boolean checkAddressValidity(List<LispAfiAddress> addresses) {
if (addresses == null || addresses.size() != 2) {
return false;
}
LispAfiAddress ipv4 = addresses.get(0);
LispAfiAddress ipv6 = addresses.get(1);
return ipv4.getAfi() == AddressFamilyIdentifierEnum.IP4 && ipv6.getAfi() == AddressFamilyIdentifierEnum.IP6;
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class MappingEntryBuilder method buildTreatments.
/**
* Builds a collection of mapping treatments.
*
* @param record LISP map record
* @return a collection of mapping treatments
*/
private List<MappingTreatment> buildTreatments(LispMapRecord record) {
List<LispLocator> locators = record.getLocators();
List<MappingTreatment> treatments = Lists.newArrayList();
for (LispLocator locator : locators) {
MappingTreatment.Builder builder = DefaultMappingTreatment.builder();
LispAfiAddress address = locator.getLocatorAfi();
final MappingAddress mappingAddress = getAddress(deviceService, deviceId, address);
if (mappingAddress != null) {
builder.withAddress(mappingAddress);
}
builder.setUnicastWeight(locator.getWeight()).setUnicastPriority(locator.getPriority()).setMulticastWeight(locator.getMulticastWeight()).setMulticastPriority(locator.getMulticastPriority());
// TODO: need to convert specific properties to
// abstracted extension properties
treatments.add(builder.build());
}
return treatments;
}
use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.
the class MappingEntryBuilderTest method getMapRecord.
/**
* Obtains a MapRecord instance.
*
* @param afiType AFI address type
* @param lcafType LCAF address type
* @return a MapRecord instance
*/
private LispMapRecord getMapRecord(AddressFamilyIdentifierEnum afiType, LispCanonicalAddressFormatEnum lcafType) {
MapRecordBuilder recordBuilder = new DefaultMapRecordBuilder();
LispIpv4Address recordAddress = new LispIpv4Address(IpAddress.valueOf(IP_RECORD_ADDRESS));
LocatorBuilder locatorBuilder = new DefaultLocatorBuilder();
LispAfiAddress locatorAddress = getAfiAddress(afiType, lcafType);
LispLocator locator = locatorBuilder.withPriority(UNIQUE_BYTE).withWeight(UNIQUE_BYTE).withMulticastPriority(UNIQUE_BYTE).withMulticastWeight(UNIQUE_BYTE).withLocalLocator(true).withRlocProbed(false).withRouted(true).withLocatorAfi(locatorAddress).build();
return recordBuilder.withRecordTtl(UNIQUE_INT).withIsAuthoritative(true).withMapVersionNumber(UNIQUE_SHORT).withMaskLength((byte) IP_RECORD_MASK_LENGTH).withAction(LispMapReplyAction.NativelyForward).withEidPrefixAfi(recordAddress).withLocators(ImmutableList.of(locator)).build();
}
Aggregations