Search in sources :

Example 6 with LispAfiAddress

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);
}
Also used : LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress)

Example 7 with LispAfiAddress

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);
}
Also used : LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress)

Example 8 with LispAfiAddress

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;
}
Also used : LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress)

Example 9 with LispAfiAddress

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;
}
Also used : MappingAddress(org.onosproject.mapping.addresses.MappingAddress) LispLocator(org.onosproject.lisp.msg.protocols.LispLocator) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) MappingTreatment(org.onosproject.mapping.MappingTreatment) DefaultMappingTreatment(org.onosproject.mapping.DefaultMappingTreatment)

Example 10 with LispAfiAddress

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();
}
Also used : MapRecordBuilder(org.onosproject.lisp.msg.protocols.LispMapRecord.MapRecordBuilder) DefaultMapRecordBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder) DefaultLocatorBuilder(org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispLocator(org.onosproject.lisp.msg.protocols.LispLocator) DefaultMapRecordBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.DefaultMapRecordBuilder) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LocatorBuilder(org.onosproject.lisp.msg.protocols.LispLocator.LocatorBuilder) DefaultLocatorBuilder(org.onosproject.lisp.msg.protocols.DefaultLispLocator.DefaultLocatorBuilder)

Aggregations

LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)16 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)10 Before (org.junit.Before)4 LispIpv6Address (org.onosproject.lisp.msg.types.LispIpv6Address)4 LispListLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress)3 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)3 UnknownHostException (java.net.UnknownHostException)2 Test (org.junit.Test)2 DefaultRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder)2 LispLocator (org.onosproject.lisp.msg.protocols.LispLocator)2 RequestBuilder (org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder)2 LispAsLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress)2 LispGeoCoordinateLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress)2 NatAddressBuilder (org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder)2 LispNonceLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress)2 IpAddress (org.onlab.packet.IpAddress)1 LispRouter (org.onosproject.lisp.ctl.LispRouter)1 LispRouterFactory (org.onosproject.lisp.ctl.LispRouterFactory)1 DefaultInfoReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoReply.DefaultInfoReplyBuilder)1 DefaultInfoRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoRequest.DefaultInfoRequestBuilder)1