Mahesh Poojary S
Committed by Gerrit Code Review

[ONOS-2363]Implementation of Open and Error messages.

Change-Id: Id4aa762caf1847a6b5e56517cb159608fd54eefb
Showing 83 changed files with 4960 additions and 0 deletions
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.protocol.ver1;
import java.util.LinkedList;
import java.util.ListIterator;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcepError;
import org.onosproject.pcepio.protocol.PcepErrorInfo;
import org.onosproject.pcepio.protocol.PcepErrorObject;
import org.onosproject.pcepio.protocol.PcepRPObject;
import org.onosproject.pcepio.protocol.PcepTEObject;
import org.onosproject.pcepio.types.PcepObjectHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides PCEP Error Info.
* Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02.
*/
public class PcepErrorInfoVer1 implements PcepErrorInfo {
protected static final Logger log = LoggerFactory.getLogger(PcepErrorInfoVer1.class);
//Error list is optional
private LinkedList<PcepError> errList;
/**
* Constructor to add PCEP error object to the list.
*
* @param llRPObjList list of PCEP RP object
* @param llTEObjList list of PCEP TE object
* @param llErrObjList list of PCEP error object
*/
public PcepErrorInfoVer1(LinkedList<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList,
LinkedList<PcepErrorObject> llErrObjList) {
this.errList = new LinkedList<PcepError>();
if ((null != llErrObjList) && (!llErrObjList.isEmpty())) {
this.errList.add(new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList));
}
}
/**
* Constructor to initialize error info.
*
* @param errll linked list or pcep error
*/
public PcepErrorInfoVer1(LinkedList<PcepError> errll) {
this.errList = errll;
}
@Override
public boolean isErrorInfoPresent() {
return (!this.errList.isEmpty()) ? true : false;
}
@Override
public void read(ChannelBuffer cb) throws PcepParseException {
PcepObjectHeader tempObjHeader;
while (0 < cb.readableBytes()) {
cb.markReaderIndex();
tempObjHeader = PcepObjectHeader.read(cb);
cb.resetReaderIndex();
byte yObjClass = tempObjHeader.getObjClass();
if ((yObjClass != PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjClass != PcepTEObjectVer1.TE_OBJ_CLASS)
&& (yObjClass != PcepErrorObjectVer1.ERROR_OBJ_CLASS)) {
throw new PcepParseException("Unknown Object is present in PCEP-ERROR. Object Class: " + yObjClass);
}
this.errList.add(PcepErrorVer1.read(cb));
}
}
@Override
public void write(ChannelBuffer cb) throws PcepParseException {
//write <error>
ListIterator<PcepError> listIterator = errList.listIterator();
while (listIterator.hasNext()) {
PcepError pcepError = listIterator.next();
//RP Object list is optional
LinkedList<PcepRPObject> llRPObjList = pcepError.getRPObjList();
if (llRPObjList != null) {
ListIterator<PcepRPObject> rpListIterator = llRPObjList.listIterator();
while (rpListIterator.hasNext()) {
rpListIterator.next().write(cb);
}
}
//TE Object list is optional
LinkedList<PcepTEObject> llTEObjList = pcepError.getTEObjList();
if (llTEObjList != null) {
ListIterator<PcepTEObject> teListIterator = llTEObjList.listIterator();
while (teListIterator.hasNext()) {
teListIterator.next().write(cb);
}
}
// <error-obj-list> is mandatory
boolean bIsErrorObjListFound = false;
LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
if (llErrObjList != null) {
ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
while (errObjListIterator.hasNext()) {
errObjListIterator.next().write(cb);
bIsErrorObjListFound = true;
}
}
if (!bIsErrorObjListFound) {
throw new PcepParseException("<error-obj-list> is mandatory.");
}
}
}
@Override
public LinkedList<Integer> getErrorType() {
LinkedList<Integer> errorType = new LinkedList<Integer>();
ListIterator<PcepError> listIterator = errList.listIterator();
PcepErrorObject errObj;
int error;
while (listIterator.hasNext()) {
PcepError pcepError = listIterator.next();
LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
if (llErrObjList != null) {
ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
while (errObjListIterator.hasNext()) {
errObj = errObjListIterator.next();
error = errObj.getErrorType();
errorType.add(error);
}
}
}
return errorType;
}
@Override
public LinkedList<Integer> getErrorValue() {
LinkedList<Integer> errorValue = new LinkedList<Integer>();
ListIterator<PcepError> listIterator = errList.listIterator();
PcepErrorObject errObj;
int error;
while (listIterator.hasNext()) {
PcepError pcepError = listIterator.next();
LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
if (llErrObjList != null) {
ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
while (errObjListIterator.hasNext()) {
errObj = errObjListIterator.next();
error = errObj.getErrorValue();
errorValue.add(error);
}
}
}
return errorValue;
}
/**
* Builder class for PCEP error info.
*/
public static class Builder implements PcepErrorInfo.Builder {
private LinkedList<PcepError> errll;
@Override
public PcepErrorInfo build() {
return new PcepErrorInfoVer1(errll);
}
@Override
public LinkedList<PcepError> getPcepErrorList() {
return this.errll;
}
@Override
public Builder setPcepErrorList(LinkedList<PcepError> errll) {
this.errll = errll;
return this;
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("ErrorList", errList).toString();
}
}
package org.onosproject.pcepio.protocol.ver1;
import java.util.LinkedList;
import java.util.ListIterator;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcepErrorObject;
import org.onosproject.pcepio.types.PcepObjectHeader;
import org.onosproject.pcepio.types.PcepValueType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/*
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Object-Class | OT |Res|P|I| Object Length (bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved | Flags | Error-Type | Error-value |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
// Optional TLVs //
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
public class PcepErrorObjectVer1 implements PcepErrorObject {
protected static final Logger log = LoggerFactory.getLogger(PcepErrorObjectVer1.class);
public static final byte ERROR_OBJ_TYPE = 1;
public static final byte ERROR_OBJ_CLASS = 13;
public static final byte ERROR_OBJECT_VERSION = 1;
//ERROR_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ErrorObjectHeaderLen(4)
public static final short ERROR_OBJ_MINIMUM_LENGTH = 8;
public static final int OBJECT_HEADER_LENGTH = 4;
public static final PcepObjectHeader DEFAULT_ERROR_OBJECT_HEADER = new PcepObjectHeader(ERROR_OBJ_CLASS,
ERROR_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
ERROR_OBJ_MINIMUM_LENGTH);
private PcepObjectHeader errorObjHeader;
private byte yErrorType;
private byte yErrorValue;
private LinkedList<PcepValueType> llOptionalTlv; // Optional TLV
/**
* Constructor to initialize variables.
*
* @param errorObjHeader ERROR Object header
* @param yErrorType Error Type
* @param yErrorValue Error Value
* @param llOptionalTlv list of optional TLV
*/
public PcepErrorObjectVer1(PcepObjectHeader errorObjHeader, byte yErrorType, byte yErrorValue,
LinkedList<PcepValueType> llOptionalTlv) {
this.errorObjHeader = errorObjHeader;
this.yErrorType = yErrorType;
this.yErrorValue = yErrorValue;
this.llOptionalTlv = llOptionalTlv;
}
/**
* sets Object Header.
*
* @param obj Error-Object header
*/
public void setLspObjHeader(PcepObjectHeader obj) {
this.errorObjHeader = obj;
}
@Override
public void setErrorType(byte yErrorType) {
this.yErrorType = yErrorType;
}
@Override
public void setErrorValue(byte yErrorValue) {
this.yErrorValue = yErrorValue;
}
/**
* returns object header.
*
* @return errorObjHeader Error-Object header
*/
public PcepObjectHeader getErrorObjHeader() {
return this.errorObjHeader;
}
@Override
public int getErrorType() {
return this.yErrorType;
}
@Override
public byte getErrorValue() {
return this.yErrorValue;
}
@Override
public LinkedList<PcepValueType> getOptionalTlv() {
return this.llOptionalTlv;
}
@Override
public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
this.llOptionalTlv = llOptionalTlv;
}
/**
* Reads from channel buffer and returns object of PcepErrorObject.
*
* @param cb of channel buffer.
* @return object of PCEP-ERROR-OBJECT
*/
public static PcepErrorObject read(ChannelBuffer cb) {
PcepObjectHeader errorObjHeader;
byte yErrorType;
byte yErrorValue;
LinkedList<PcepValueType> llOptionalTlv;
errorObjHeader = PcepObjectHeader.read(cb);
//take only ErrorObject buffer.
ChannelBuffer tempCb = cb.readBytes(errorObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
tempCb.readByte(); //ignore Reserved
tempCb.readByte(); //ignore Flags
yErrorType = tempCb.readByte();
yErrorValue = tempCb.readByte();
llOptionalTlv = parseOptionalTlv(tempCb);
return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv);
}
/**
* returns Linked list of optional tlvs.
*
* @param cb channel buffer.
* @return Linked list of optional tlvs
*/
protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) {
LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
byte[] yTemp = new byte[cb.readableBytes()];
cb.readBytes(yTemp);
return llOutOptionalTlv;
}
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
//write Object header
int objStartIndex = cb.writerIndex();
int objLenIndex = errorObjHeader.write(cb);
if (objLenIndex <= 0) {
throw new PcepParseException("While writing Error Object Header.");
}
//write Reserved
cb.writeByte(0);
//write Flags
cb.writeByte(0);
//write ErrorType and ErrorValue
cb.writeByte(this.yErrorType);
cb.writeByte(this.yErrorValue);
// Add optional TLV
packOptionalTlv(cb);
//Update object length now
int length = cb.writerIndex() - objStartIndex;
//will be helpful during print().
errorObjHeader.setObjLen((short) length);
// As per RFC the length of object should be
// multiples of 4
int pad = length % 4;
if (pad != 0) {
pad = 4 - pad;
for (int i = 0; i < pad; i++) {
cb.writeByte((byte) 0);
}
length = length + pad;
}
cb.setShort(objLenIndex, (short) length);
return length;
}
/**
* Pack the Optional tlvs.
*
* @param cb channel buffer.
* @return writer index.
*/
protected int packOptionalTlv(ChannelBuffer cb) {
ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
int startIndex = cb.writerIndex();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
if (null == tlv) {
log.debug("TLV is null from OptionalTlv list");
continue;
}
tlv.write(cb);
}
return cb.writerIndex() - startIndex;
}
/**
* Builder class for PCEP error object.
*/
public static class Builder implements PcepErrorObject.Builder {
private boolean bIsHeaderSet = false;
private PcepObjectHeader errorObjHeader;
private byte yErrorType;
private byte yErrorValue;
private boolean bIsPFlagSet = false;
private boolean bPFlag;
private boolean bIsIFlagSet = false;
private boolean bIFlag;
private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
@Override
public PcepErrorObject build() {
PcepObjectHeader errorObjHeader = this.bIsHeaderSet ? this.errorObjHeader : DEFAULT_ERROR_OBJECT_HEADER;
if (bIsPFlagSet) {
errorObjHeader.setPFlag(bPFlag);
}
if (bIsIFlagSet) {
errorObjHeader.setIFlag(bIFlag);
}
return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv);
}
@Override
public PcepObjectHeader getErrorObjHeader() {
return this.errorObjHeader;
}
@Override
public Builder setErrorObjHeader(PcepObjectHeader obj) {
this.errorObjHeader = obj;
this.bIsHeaderSet = true;
return this;
}
@Override
public int getErrorType() {
return this.yErrorType;
}
@Override
public Builder setErrorType(byte value) {
this.yErrorType = value;
return this;
}
@Override
public byte getErrorValue() {
return this.yErrorValue;
}
@Override
public Builder setErrorValue(byte value) {
this.yErrorValue = value;
return this;
}
@Override
public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
this.llOptionalTlv = llOptionalTlv;
return this;
}
@Override
public LinkedList<PcepValueType> getOptionalTlv() {
return this.llOptionalTlv;
}
@Override
public Builder setPFlag(boolean value) {
this.bPFlag = value;
this.bIsPFlagSet = true;
return this;
}
@Override
public Builder setIFlag(boolean value) {
this.bIFlag = value;
this.bIsIFlagSet = true;
return this;
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("ObjectHeader", errorObjHeader).add("ErrorType", yErrorType)
.add("ErrorValue", yErrorValue).add("OptionalTlv", llOptionalTlv).toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.protocol.ver1;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcepMessageReader;
import org.onosproject.pcepio.protocol.PcepMessageWriter;
import org.onosproject.pcepio.protocol.PcepOpenMsg;
import org.onosproject.pcepio.protocol.PcepOpenObject;
import org.onosproject.pcepio.protocol.PcepType;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.PcepErrorDetailInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
public class PcepOpenMsgVer1 implements PcepOpenMsg {
/*
* <Open Message>::= <Common Header> <OPEN>
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Ver | Flags | Message-Type | Message-Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Object-Class | OT |Res|P|I| Object Length (bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Ver | Flags | Keepalive | DeadTimer | SID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
// Optional TLVs //
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(PcepOpenMsgVer1.class);
public static final byte PACKET_VERSION = 1;
public static final int PACKET_MINIMUM_LENGTH = 12;
public static final PcepType MSG_TYPE = PcepType.OPEN;
private PcepOpenObject pcepOpenObj;
public static final PcepOpenMsgVer1.Reader READER = new Reader();
/**
* Constructor to initialize PcepOpenObject.
*
* @param pcepOpenObj PCEP-OPEN-OBJECT
*/
public PcepOpenMsgVer1(PcepOpenObject pcepOpenObj) {
this.pcepOpenObj = pcepOpenObj;
}
@Override
public PcepOpenObject getPcepOpenObject() {
return this.pcepOpenObj;
}
@Override
public void setPcepOpenObject(PcepOpenObject pcepOpenObj) {
this.pcepOpenObj = pcepOpenObj;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public PcepType getType() {
return MSG_TYPE;
}
public static class Reader implements PcepMessageReader<PcepOpenMsg> {
@Override
public PcepOpenMsg readFrom(ChannelBuffer cb) throws PcepParseException {
if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
throw new PcepParseException("Packet size is less than the minimum length.");
}
byte version = cb.readByte();
version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
if (version != PACKET_VERSION) {
log.error("[readFrom] Invalid version: " + version);
throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
}
// fixed value property type == 1
byte type = cb.readByte();
if (type != MSG_TYPE.getType()) {
log.error("[readFrom] Unexpected type: " + type);
throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
}
int length = cb.readShort();
if (length < PACKET_MINIMUM_LENGTH) {
throw new PcepParseException(
"Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length);
}
return new PcepOpenMsgVer1(PcepOpenObjectVer1.read(cb));
}
}
/**
* Builder class for PCEP open message.
*/
static class Builder implements PcepOpenMsg.Builder {
private PcepOpenObject pcepOpenObj;
@Override
public PcepOpenMsg build() throws PcepParseException {
if (!(pcepOpenObj instanceof PcepOpenObjectVer1)) {
throw new NullPointerException("PcepOpenObject is null.");
}
return new PcepOpenMsgVer1(pcepOpenObj);
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public PcepType getType() {
return PcepType.OPEN;
}
@Override
public PcepOpenObject getPcepOpenObj() {
return this.pcepOpenObj;
}
@Override
public Builder setPcepOpenObj(PcepOpenObject obj) {
this.pcepOpenObj = obj;
return this;
}
}
@Override
public void writeTo(ChannelBuffer cb) throws PcepParseException {
WRITER.write(cb, this);
}
public static final Writer WRITER = new Writer();
public static class Writer implements PcepMessageWriter<PcepOpenMsgVer1> {
@Override
public void write(ChannelBuffer cb, PcepOpenMsgVer1 message) throws PcepParseException {
int startIndex = cb.writerIndex();
// first 3 bits set to version
cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
// message type
cb.writeByte(MSG_TYPE.getType());
// length is length of variable message, will be updated at the end
// Store the position of message
// length in buffer
int msgLenIndex = cb.writerIndex();
cb.writeShort(0);
message.getPcepOpenObject().write(cb);
// update message length field
int iLength = cb.writerIndex() - startIndex;
cb.setShort(msgLenIndex, (short) iLength);
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("OpenObject", pcepOpenObj).toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides Administrative Group Tlv which contains value (32 Bit ).
*/
public class AdministrativeGroupTlv implements PcepValueType {
/* REFERENCE :[RFC5305]/3.1
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TDB33] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| value (32 Bit ) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(AdministrativeGroupTlv.class);
public static final short TYPE = 3; //TDB33
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue of Administrative-Group-Tlv.
*/
public AdministrativeGroupTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created AdministrativeGroupTlv object.
*
* @param raw value.
* @return object of Administrative-Group-Tlv
*/
public static AdministrativeGroupTlv of(final int raw) {
return new AdministrativeGroupTlv(raw);
}
/**
* Returns raw value.
*
* @return rawValue raw value
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof AdministrativeGroupTlv) {
AdministrativeGroupTlv other = (AdministrativeGroupTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of Administrative-Group-Tlv.
*
* @param c input channel buffer
* @return object of Administrative-Group-Tlv
*/
public static AdministrativeGroupTlv read(ChannelBuffer c) {
return AdministrativeGroupTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides BGP LS identifier which contains opaque value (32 Bit ID).
*/
public class BGPLSidentifierTlv implements PcepValueType {
/* Reference :draft-ietf-idr-ls-distribution-10
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD11] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| opaque value (32 Bit ID). |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(BGPLSidentifierTlv.class);
public static final short TYPE = 17; //TODD:change this TBD11
public static final short LENGTH = 4;
private final int rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue BGP LS identifier Tlv
*/
public BGPLSidentifierTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created BGPLSidentifierTlv object.
*
* @param raw value
* @return object of BGPLSidentifierTlv
*/
public static BGPLSidentifierTlv of(final int raw) {
return new BGPLSidentifierTlv(raw);
}
/**
* Returns opaque value.
*
* @return rawValue opaque value
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BGPLSidentifierTlv) {
BGPLSidentifierTlv other = (BGPLSidentifierTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of BGPLSidentifierTlv.
*
* @param c input channel buffer
* @return object of BGP LS identifier Tlv
*/
public static BGPLSidentifierTlv read(ChannelBuffer c) {
return BGPLSidentifierTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides GMPLS Capability Tlv.
*/
public class GmplsCapabilityTlv implements PcepValueType {
/*
* GMPLS-CAPABILITY TLV format
* reference :draft-ietf-pce-gmpls-pcep-extensions -2.1.1
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=14 | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Flags |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(GmplsCapabilityTlv.class);
public static final short TYPE = 14;
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize raw value.
*
* @param rawValue of Gmpls-Capability-Tlv
*/
public GmplsCapabilityTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created GmplsCapabilityTlv object.
*
* @param raw Flags value
* @return object of Gmpls-Capability-Tlv
*/
public static GmplsCapabilityTlv of(final int raw) {
return new GmplsCapabilityTlv(raw);
}
/**
* Returns value of Flags.
*
* @return rawValue Flags
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof GmplsCapabilityTlv) {
GmplsCapabilityTlv other = (GmplsCapabilityTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of Gmpls-Capability-Tlv.
*
* @param c input channel buffer
* @return object of Gmpls-Capability-Tlv
*/
public static GmplsCapabilityTlv read(ChannelBuffer c) {
return GmplsCapabilityTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides IGP Link Metric .
*/
public class IGPMetricTlv implements PcepValueType {
/* Reference :[I-D.ietf-idr-ls-distribution] /3.3.2.4
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=TDB40 | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// IGP Link Metric (variable length) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(IGPMetricTlv.class);
public static final short TYPE = 1095; //TODO:NEED TO HANDLE TDB40
private short hLength;
private final byte[] rawValue;
/**
* Constructor to initialize raw value.
*
* @param rawValue IGP Link Metric
* @param hLength length
*/
public IGPMetricTlv(byte[] rawValue, short hLength) {
this.rawValue = rawValue;
this.hLength = hLength;
}
/**
* Returns newly created IGPMetricTlv object.
*
* @param raw value of IGP Link Metric
* @param hLength length
* @return object of IGPMetricTlv
*/
public static IGPMetricTlv of(final byte[] raw, short hLength) {
return new IGPMetricTlv(raw, hLength);
}
/**
* Returns value of IGP Link Metric.
*
* @return rawValue of IGP Link Metric
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IGPMetricTlv) {
IGPMetricTlv other = (IGPMetricTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(hLength);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IGPMetricTlv.
*
* @param c input channel buffer
* @param hLength length
* @return object of IGPMetricTlv
*/
public static PcepValueType read(ChannelBuffer c, short hLength) {
byte[] iIGPMetric = new byte[hLength];
c.readBytes(iIGPMetric, 0, hLength);
return new IGPMetricTlv(iIGPMetric, hLength);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", hLength);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides IPv4 Interface Address .
*/
public class IPv4InterfaceAddressTlv implements PcepValueType {
/*
* reference :[RFC5305]/3.2
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=6 | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 Interface Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(IPv4InterfaceAddressTlv.class);
public static final short TYPE = 6;
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue of IPv4-Interface-Address.
*/
public IPv4InterfaceAddressTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created IPv4InterfaceAddressTlv object.
*
* @param raw value of IPv4-Interface-Address
* @return object of IPv4-Interface-Address-Tlv
*/
public static IPv4InterfaceAddressTlv of(final int raw) {
return new IPv4InterfaceAddressTlv(raw);
}
/**
* Returns value of IPv4 Interface Address.
*
* @return rawValue IPv4 Interface Address
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv4InterfaceAddressTlv) {
IPv4InterfaceAddressTlv other = (IPv4InterfaceAddressTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv4InterfaceAddressTlv.
*
* @param c input channel buffer
* @return object of IPv4-Interface-Address-Tlv
*/
public static IPv4InterfaceAddressTlv read(ChannelBuffer c) {
return IPv4InterfaceAddressTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
\ No newline at end of file
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides IPv4 Neighbor Address .
*/
public class IPv4NeighborAddressTlv implements PcepValueType {
/* Reference :[RFC5305]/3.3
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=8 | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 Neighbor Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(IPv4NeighborAddressTlv.class);
public static final short TYPE = 8;
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue IPv4-Neighbor-Address-Tlv
*/
public IPv4NeighborAddressTlv(int rawValue) {
log.debug("IPv4NeighborAddressTlv");
this.rawValue = rawValue;
}
/**
* Returns newly created IPv4NeighborAddressTlv object.
*
* @param raw value of IPv4-Neighbor-Address
* @return object of IPv4NeighborAddressTlv
*/
public static IPv4NeighborAddressTlv of(final int raw) {
return new IPv4NeighborAddressTlv(raw);
}
/**
* Returns value of IPv4 Neighbor Address.
*
* @return rawValue IPv4 Neighbor Address
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv4NeighborAddressTlv) {
IPv4NeighborAddressTlv other = (IPv4NeighborAddressTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv4-Neighbor-Address-Tlv.
*
* @param c input channel buffer
* @return object of IPv4-Neighbor-Address-Tlv
*/
public static IPv4NeighborAddressTlv read(ChannelBuffer c) {
return IPv4NeighborAddressTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
\ No newline at end of file
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides IPv4 TE Router Id Of Local Node.
*/
public class IPv4TERouterIdOfLocalNodeTlv implements PcepValueType {
/* Reference:[RFC5305]/4.3
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TDB25] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 TE Router Id Of Local Node |
+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
*/
protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfLocalNodeTlv.class);
public static final short TYPE = 134; //TDB25
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue IPv4-TE-RouterId-Of-Local-Node-Tlv
*/
public IPv4TERouterIdOfLocalNodeTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created IPv4TERouterIdOfLocalNodeTlv object.
*
* @param raw value of IPv4-TE-RouterId-Of-Local-Node
* @return object of IPv4TERouterIdOfLocalNodeTlv
*/
public static IPv4TERouterIdOfLocalNodeTlv of(final int raw) {
return new IPv4TERouterIdOfLocalNodeTlv(raw);
}
/**
* Returns value of IPv4 TE Router Id Of Local Node.
*
* @return rawValue IPv4 TE Router Id Of Local Node
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv4TERouterIdOfLocalNodeTlv) {
IPv4TERouterIdOfLocalNodeTlv other = (IPv4TERouterIdOfLocalNodeTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv4TERouterIdOfLocalNodeTlv.
*
* @param c input channel buffer
* @return object of IPv4TERouterIdOfLocalNodeTlv
*/
public static IPv4TERouterIdOfLocalNodeTlv read(ChannelBuffer c) {
return IPv4TERouterIdOfLocalNodeTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides IPv4 TE Router Id Of Remote Node.
*/
public class IPv4TERouterIdOfRemoteNodeTlv implements PcepValueType {
/* Reference :[RFC5305]/4.3
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TDB28] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 TE Router Id Of Remote Node |
+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
*/
protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfRemoteNodeTlv.class);
public static final short TYPE = 1340; //TDB28
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue IPv4 TE RouterId Of Remote Node Tlv
*/
public IPv4TERouterIdOfRemoteNodeTlv(int rawValue) {
log.debug("IPv4TERouterIdOfRemoteNodeTlv");
this.rawValue = rawValue;
}
/**
* Returns newly created IPv4TERouterIdOfRemoteNodeTlv object.
*
* @param raw IPv4 TE RouterId Of Remote Node
* @return object of IPv4TERouterIdOfRemoteNodeTlv
*/
public static IPv4TERouterIdOfRemoteNodeTlv of(final int raw) {
return new IPv4TERouterIdOfRemoteNodeTlv(raw);
}
/**
* Returns value of IPv4 TE Router Id Of Remote Node.
*
* @return rawValue IPv4 TE Router Id Of Remote Node
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv4TERouterIdOfRemoteNodeTlv) {
IPv4TERouterIdOfRemoteNodeTlv other = (IPv4TERouterIdOfRemoteNodeTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv4TERouterIdOfRemoteNodeTlv.
*
* @param c input channel buffer
* @return object of IPv4TERouterIdOfRemoteNodeTlv
*/
public static IPv4TERouterIdOfRemoteNodeTlv read(ChannelBuffer c) {
return IPv4TERouterIdOfRemoteNodeTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides IPv6 Interface Address. REFERENCE :[RFC6119]/4.2.
*/
public class IPv6InterfaceAddressTlv implements PcepValueType {
protected static final Logger log = LoggerFactory.getLogger(IPv6InterfaceAddressTlv.class);
public static final short TYPE = 12; //TDB18
public static final short LENGTH = 20;
public static final byte VALUE_LENGTH = 18;
private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
public static final IPv6InterfaceAddressTlv NONE = new IPv6InterfaceAddressTlv(NONE_VAL);
private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
public static final IPv6InterfaceAddressTlv NO_MASK = new IPv6InterfaceAddressTlv(NO_MASK_VAL);
public static final IPv6InterfaceAddressTlv FULL_MASK = NONE;
private final byte[] rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue IPv6 Interface Address Tlv
*/
public IPv6InterfaceAddressTlv(byte[] rawValue) {
log.debug("IPv6InterfaceAddressTlv");
this.rawValue = rawValue;
}
/**
* Returns newly created IPv6InterfaceAddressTlv object.
*
* @param raw IPv6 Interface Address
* @return object of IPv6InterfaceAddressTlv
*/
public static IPv6InterfaceAddressTlv of(final byte[] raw) {
//check NONE_VAL
boolean bFoundNONE = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (NONE_VAL[i] != raw[i]) {
bFoundNONE = false;
}
}
if (bFoundNONE) {
return NONE;
}
//check NO_MASK_VAL
boolean bFoundNoMask = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (0xFF != raw[i]) {
bFoundNoMask = false;
}
}
if (bFoundNoMask) {
return NO_MASK;
}
return new IPv6InterfaceAddressTlv(raw);
}
/**
* Returns value of IPv6 Interface Address.
*
* @return rawValue raw value
*/
public byte[] getBytes() {
return rawValue;
}
/**
* Returns value of IPv6 Interface Address.
*
* @return rawValue raw value
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv6InterfaceAddressTlv) {
IPv6InterfaceAddressTlv other = (IPv6InterfaceAddressTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv6InterfaceAddressTlv.
*
* @param c input channel buffer
* @return object of IPv6InterfaceAddressTlv
*/
public static IPv6InterfaceAddressTlv read20Bytes(ChannelBuffer c) {
byte[] yTemp = new byte[20];
c.readBytes(yTemp, 0, 20);
return IPv6InterfaceAddressTlv.of(yTemp);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", LENGTH);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides IPv6 Neighbor Address. Reference :[RFC6119]/4.3.
*/
public class IPv6NeighborAddressTlv implements PcepValueType {
protected static final Logger log = LoggerFactory.getLogger(IPv6NeighborAddressTlv.class);
public static final short TYPE = 13; // TDB19
public static final short LENGTH = 20;
public static final byte VALUE_LENGTH = 18;
private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
public static final IPv6NeighborAddressTlv NONE = new IPv6NeighborAddressTlv(NONE_VAL);
private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
public static final IPv6NeighborAddressTlv NO_MASK = new IPv6NeighborAddressTlv(NO_MASK_VAL);
public static final IPv6NeighborAddressTlv FULL_MASK = NONE;
private final byte[] rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue IPv6 Neighbor Address Tlv
*/
public IPv6NeighborAddressTlv(byte[] rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created IPv6NeighborAddressTlv object.
*
* @param raw IPv6 Neighbor Address
* @return object of IPv6 Neighbor Address Tlv
*/
public static IPv6NeighborAddressTlv of(final byte[] raw) {
//check NONE_VAL
boolean bFoundNONE = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (NONE_VAL[i] != raw[i]) {
bFoundNONE = false;
}
}
if (bFoundNONE) {
return NONE;
}
//check NO_MASK_VAL
boolean bFoundNoMask = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (0xFF != raw[i]) {
bFoundNoMask = false;
}
}
if (bFoundNoMask) {
return NO_MASK;
}
return new IPv6NeighborAddressTlv(raw);
}
/**
* Returns value of IPv6 Neighbor Address.
*
* @return rawValue raw value
*/
public byte[] getBytes() {
return rawValue;
}
/**
* Returns value of IPv6 Neighbor Address.
*
* @return rawValue raw value
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv6NeighborAddressTlv) {
IPv6NeighborAddressTlv other = (IPv6NeighborAddressTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeBytes(rawValue);
return c.writerIndex() - iStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv6NeighborAddressTlv.
*
* @param c input channel buffer
* @return object of IPv6NeighborAddressTlv
*/
public static IPv6NeighborAddressTlv read20Bytes(ChannelBuffer c) {
byte[] yTemp = new byte[20];
c.readBytes(yTemp, 0, 20);
return IPv6NeighborAddressTlv.of(yTemp);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", LENGTH);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides IPv6 TE Router Id of Local Node. Reference :[RFC6119]/4.1.
*/
public class IPv6TERouterIdofLocalNodeTlv implements PcepValueType {
protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofLocalNodeTlv.class);
public static final short TYPE = 140; //TDB26
public static final short LENGTH = 20;
public static final byte VALUE_LENGTH = 18;
private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public static final IPv6TERouterIdofLocalNodeTlv NONE = new IPv6TERouterIdofLocalNodeTlv(NONE_VAL);
private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
public static final IPv6TERouterIdofLocalNodeTlv NO_MASK = new IPv6TERouterIdofLocalNodeTlv(NO_MASK_VAL);
public static final IPv6TERouterIdofLocalNodeTlv FULL_MASK = NONE;
private final byte[] rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue IPv6TERouterIdofLocalNodeTlv
*/
public IPv6TERouterIdofLocalNodeTlv(byte[] rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created IPv6TERouterIdofLocalNodeTlv object.
*
* @param raw IPv6 TE Router Id of Local Node
* @return object of IPv6TERouterIdofLocalNodeTlv
*/
public static IPv6TERouterIdofLocalNodeTlv of(final byte[] raw) {
//check NONE_VAL
boolean bFoundNONE = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (NONE_VAL[i] != raw[i]) {
bFoundNONE = false;
}
}
if (bFoundNONE) {
return NONE;
}
//check NO_MASK_VAL
boolean bFoundNoMask = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (0xFF != raw[i]) {
bFoundNoMask = false;
}
}
if (bFoundNoMask) {
return NO_MASK;
}
return new IPv6TERouterIdofLocalNodeTlv(raw);
}
/**
* Returns value of IPv6 TE Router Id of Local Node.
*
* @return byte array value of rawValue
*/
public byte[] getBytes() {
return rawValue;
}
/**
* Returns value of IPv6 TE Router Id of Local Node.
*
* @return byte array value of rawValue
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv6TERouterIdofLocalNodeTlv) {
IPv6TERouterIdofLocalNodeTlv other = (IPv6TERouterIdofLocalNodeTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeBytes(rawValue);
return c.writerIndex() - iStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv6TERouterIdofLocalNodeTlv.
*
* @param c input channel buffer
* @return object of IPv6TERouterIdofLocalNodeTlv
*/
public static IPv6TERouterIdofLocalNodeTlv read20Bytes(ChannelBuffer c) {
byte[] yTemp = new byte[20];
c.readBytes(yTemp, 0, 20);
return IPv6TERouterIdofLocalNodeTlv.of(yTemp);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", LENGTH);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides IPv6 TE Router Id of Remote Node. Reference :[RFC6119]/4.1.
*/
public class IPv6TERouterIdofRemoteNodeTlv implements PcepValueType {
protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofRemoteNodeTlv.class);
public static final short TYPE = 1400; //TDB29
public static final short LENGTH = 20;
public static final byte VALUE_LENGTH = 18;
private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
public static final IPv6TERouterIdofRemoteNodeTlv NONE = new IPv6TERouterIdofRemoteNodeTlv(NONE_VAL);
private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
public static final IPv6TERouterIdofRemoteNodeTlv NO_MASK = new IPv6TERouterIdofRemoteNodeTlv(NO_MASK_VAL);
public static final IPv6TERouterIdofRemoteNodeTlv FULL_MASK = NONE;
private final byte[] rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue IPv6TERouterIdofRemoteNodeTlv
*/
public IPv6TERouterIdofRemoteNodeTlv(byte[] rawValue) {
log.debug("IPv6TERouterIdofRemoteNodeTlv");
this.rawValue = rawValue;
}
/**
* Returns newly created IPv6TERouterIdofRemoteNodeTlv object.
*
* @param raw IPv6 TE Router Id of RemoteNode
* @return object of IPv6TERouterIdofRemoteNodeTlv
*/
public static IPv6TERouterIdofRemoteNodeTlv of(final byte[] raw) {
//check NONE_VAL
boolean bFoundNONE = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (NONE_VAL[i] != raw[i]) {
bFoundNONE = false;
}
}
if (bFoundNONE) {
return NONE;
}
//check NO_MASK_VAL
boolean bFoundNoMask = true;
//value starts from 3rd byte.
for (int i = 2; i < 20; ++i) {
if (0xFF != raw[i]) {
bFoundNoMask = false;
}
}
if (bFoundNoMask) {
return NO_MASK;
}
return new IPv6TERouterIdofRemoteNodeTlv(raw);
}
/**
* Returns value of IPv6 TE Router Id of Remote Node.
*
* @return byte array value of rawValue
*/
public byte[] getBytes() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof IPv6TERouterIdofRemoteNodeTlv) {
IPv6TERouterIdofRemoteNodeTlv other = (IPv6TERouterIdofRemoteNodeTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeBytes(rawValue);
return c.writerIndex() - iStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv6TERouterIdofRemoteNodeTlv.
*
* @param c input channel buffer
* @return object of IPv6TERouterIdofRemoteNodeTlv
*/
public static IPv6TERouterIdofRemoteNodeTlv read20Bytes(ChannelBuffer c) {
byte[] yTemp = new byte[20];
c.readBytes(yTemp, 0, 20);
return IPv6TERouterIdofRemoteNodeTlv.of(yTemp);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", LENGTH);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides ISIS Area Identifier.
*/
public class ISISAreaIdentifierTlv implements PcepValueType {
/* Reference :[I-D.ietf-idr- ls-distribution]/3.3.1.2
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD24] | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// Area Identifier (variable) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(ISISAreaIdentifierTlv.class);
public static final short TYPE = 107; //TODO:NEED TO HANDLE TBD24
private short hLength;
private final byte[] rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue ISIS-Area-Identifier
* @param hLength length
*/
public ISISAreaIdentifierTlv(byte[] rawValue, short hLength) {
log.debug("ISISAreaIdentifierTlv");
this.rawValue = rawValue;
if (0 == hLength) {
this.hLength = (short) rawValue.length;
} else {
this.hLength = hLength;
}
}
/**
* Returns newly created ISISAreaIdentifierTlv object.
*
* @param raw ISIS-Area-Identifier
* @param hLength length
* @return object of ISISAreaIdentifierTlv
*/
public static ISISAreaIdentifierTlv of(final byte[] raw, short hLength) {
return new ISISAreaIdentifierTlv(raw, hLength);
}
/**
* Returns value of ISIS-Area-Identifier.
*
* @return byte array of rawValue
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ISISAreaIdentifierTlv) {
ISISAreaIdentifierTlv other = (ISISAreaIdentifierTlv) obj;
return Objects.equals(hLength, other.hLength) && Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(hLength);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of ISISAreaIdentifierTlv.
*
* @param c input channel buffer
* @param hLength length
* @return object of ISISAreaIdentifierTlv
*/
public static PcepValueType read(ChannelBuffer c, short hLength) {
byte[] iISISAreaIdentifier = new byte[hLength];
c.readBytes(iISISAreaIdentifier, 0, hLength);
return new ISISAreaIdentifierTlv(iISISAreaIdentifier, hLength);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", hLength);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides Local and remote Link Identifiers.
*/
public class LinkLocalRemoteIdentifiersTlv implements PcepValueType {
/* Reference :RFC5307
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=4 | Length=8 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link Local Identifier |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Link Remote Identifier |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class);
public static final short TYPE = 4;
public static final short LENGTH = 8;
private final int iLinkLocalIdentifier;
private final int iLinkRemoteIdentifier;
/**
* Constructor to initialize iLinkLocalIdentifier , iLinkRemoteIdentifier.
*
* @param iLinkLocalIdentifier Link Local identifier
* @param iLinkRemoteIdentifier Link Remote identifier
*/
public LinkLocalRemoteIdentifiersTlv(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
this.iLinkLocalIdentifier = iLinkLocalIdentifier;
this.iLinkRemoteIdentifier = iLinkRemoteIdentifier;
}
/**
* Retruns an object of Link Local Remote Identifiers Tlv.
*
* @param iLinkLocalIdentifier Link Local identifier
* @param iLinkRemoteIdentifier Link Remote identifier
* @return object of LinkLocalRemoteIdentifiersTlv
*/
public static LinkLocalRemoteIdentifiersTlv of(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
}
/**
* Returns Link-Local-Identifier.
*
* @return iLinkLocalIdentifier Link Local Identifier
*/
public int getLinkLocalIdentifier() {
return iLinkLocalIdentifier;
}
/**
* Returns Link-Remote-Identifier.
*
* @return iLinkRemoteIdentifier Link Remote Identifier.
*/
public int getLinkRemoteIdentifier() {
return iLinkRemoteIdentifier;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public short getType() {
return TYPE;
}
@Override
public int hashCode() {
return Objects.hash(iLinkLocalIdentifier, iLinkRemoteIdentifier);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LinkLocalRemoteIdentifiersTlv) {
LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj;
return Objects.equals(iLinkLocalIdentifier, other.iLinkLocalIdentifier)
&& Objects.equals(iLinkRemoteIdentifier, other.iLinkRemoteIdentifier);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(iLinkLocalIdentifier);
c.writeInt(iLinkRemoteIdentifier);
return c.writerIndex() - iStartIndex;
}
/**
* Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv.
*
* @param c input channel buffer
* @return object of LinkLocalRemoteIdentifiersTlv
*/
public static PcepValueType read(ChannelBuffer c) {
int iLinkLocalIdentifier = c.readInt();
int iLinkRemoteIdentifier = c.readInt();
return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
.add("LinkLocalIdentifier", iLinkLocalIdentifier).add("LinkRemoteIdentifier", iLinkRemoteIdentifier)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides the Link Name.
*/
public class LinkNameTlv implements PcepValueType {
/* Reference :[I-D.ietf-idr- ls-distribution] /3.3.2.7
* Link name tlv format.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=TDB43 | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// Link Name (variable) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(LinkNameTlv.class);
public static final short TYPE = 1098; //TODO:NEED TO HANDLE TDB43
private short hLength;
private final byte[] rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue Link-Name
* @param hLength length
*/
public LinkNameTlv(byte[] rawValue, short hLength) {
this.rawValue = rawValue;
if (0 == hLength) {
this.hLength = (short) rawValue.length;
} else {
this.hLength = hLength;
}
}
/**
* Returns newly created LinkNameTlv object.
*
* @param raw Link-Name
* @param hLength length
* @return object of LinkNameTlv
*/
public static LinkNameTlv of(final byte[] raw, short hLength) {
return new LinkNameTlv(raw, hLength);
}
/**
* Returns value of Link-Name.
*
* @return raw value
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LinkNameTlv) {
LinkNameTlv other = (LinkNameTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(hLength);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of LinkNameTlv.
*
* @param c input channel buffer
* @param hLength length
* @return object of LinkNameTlv
*/
public static PcepValueType read(ChannelBuffer c, short hLength) {
byte[] linkName = new byte[hLength];
c.readBytes(linkName, 0, hLength);
return new LinkNameTlv(linkName, hLength);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", hLength);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provide Link Protection Type.
*/
public class LinkProtectionTypeTlv implements PcepValueType {
/* Reference :[RFC5307]/1.2
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TDB38] | Length=2 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Protection Cap | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(LinkProtectionTypeTlv.class);
public static final short TYPE = 20; //TDB38
public static final short LENGTH = 2;
private final byte protectionCap;
private final byte reserved;
/**
* Constructor to initialize protectionCap.
*
* @param protectionCap Protection Cap
*/
public LinkProtectionTypeTlv(byte protectionCap) {
this.protectionCap = protectionCap;
this.reserved = 0;
}
/**
* Constructor to initialize protectionCap, reserved.
*
* @param protectionCap Protection Cap
* @param reserved Reserved value
*/
public LinkProtectionTypeTlv(byte protectionCap, byte reserved) {
this.protectionCap = protectionCap;
this.reserved = reserved;
}
/**
* Returns Protection Cap.
*
* @return protectionCap Protection Cap
*/
public byte getProtectionCap() {
return protectionCap;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(protectionCap, reserved);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LinkProtectionTypeTlv) {
LinkProtectionTypeTlv other = (LinkProtectionTypeTlv) obj;
return Objects.equals(protectionCap, other.protectionCap) && Objects.equals(reserved, other.reserved);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeByte(protectionCap);
c.writeByte(reserved);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of LinkProtectionTypeTlv.
*
* @param c input channel buffer
* @return object of LinkProtectionTypeTlv
*/
public static PcepValueType read(ChannelBuffer c) {
byte protectionCap = c.readByte();
byte reserved = c.readByte();
return new LinkProtectionTypeTlv(protectionCap, reserved);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
.add("ProtectionCap", protectionCap).toString();
}
}
\ No newline at end of file
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides Local TE Node Descriptors TLV which contains Node Descriptor Sub-TLVs.
*/
public class LocalTENodeDescriptorsTLV implements PcepValueType {
/* REFERENCE :draft-ietf-idr-ls-distribution-10
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD8] | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
// Node Descriptor Sub-TLVs (variable) //
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Note: Length is including header here. Refer Routing Universe TLV.
*/
protected static final Logger log = LoggerFactory.getLogger(LocalTENodeDescriptorsTLV.class);
public static final short TYPE = 1637; //TODD:change this TBD8
public short hLength;
public static final int TLV_HEADER_LENGTH = 4;
// Node Descriptor Sub-TLVs (variable)
private LinkedList<PcepValueType> llNodeDescriptorSubTLVs;
/**
* Constructor to initialize llNodeDescriptorSubTLVs.
*
* @param llNodeDescriptorSubTLVs LinkedList of PcepValueType
*/
public LocalTENodeDescriptorsTLV(LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
this.llNodeDescriptorSubTLVs = llNodeDescriptorSubTLVs;
}
/**
* Returns a new object of LocalTENodeDescriptorsTLV.
*
* @param llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLVs
* @return object of LocalTENodeDescriptorsTLV
*/
public static LocalTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs);
}
/**
* Returns Linked List of tlvs.
*
* @return llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLV
*/
public LinkedList<PcepValueType> getllNodeDescriptorSubTLVs() {
return llNodeDescriptorSubTLVs;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(llNodeDescriptorSubTLVs.hashCode());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
/*
* Here we have a list of Tlv so to compare each sub tlv between the object
* we have to take a list iterator so one by one we can get each sub tlv object
* and can compare them.
* it may be possible that the size of 2 lists is not equal so we have to first check
* the size, if both are same then we should check for the subtlv objects otherwise
* we should return false.
*/
if (obj instanceof LocalTENodeDescriptorsTLV) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
LocalTENodeDescriptorsTLV other = (LocalTENodeDescriptorsTLV) obj;
Iterator<PcepValueType> objListIterator = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs
.iterator();
countObjSubTlv = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs.size();
countOtherSubTlv = other.llNodeDescriptorSubTLVs.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
PcepValueType subTlv = objListIterator.next();
isCommonSubTlv = Objects.equals(llNodeDescriptorSubTLVs.contains(subTlv),
other.llNodeDescriptorSubTLVs.contains(subTlv));
}
return isCommonSubTlv;
}
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int tlvStartIndex = c.writerIndex();
c.writeShort(TYPE);
int tlvLenIndex = c.writerIndex();
hLength = 0;
c.writeShort(0);
ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
if (null == tlv) {
log.debug("TLV is null from subTlv list");
continue;
}
tlv.write(c);
// need to take care of padding
int pad = tlv.getLength() % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; ++i) {
c.writeByte((byte) 0);
}
}
}
hLength = (short) (c.writerIndex() - tlvStartIndex);
c.setShort(tlvLenIndex, hLength);
return c.writerIndex() - tlvStartIndex;
}
/**
* Reads the channel buffer and returns object of AutonomousSystemTlv.
*
* @param c input channel buffer
* @param hLength length of subtlvs.
* @return object of AutonomousSystemTlv
* @throws PcepParseException if mandatory fields are missing
*/
public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
// Node Descriptor Sub-TLVs (variable)
LinkedList<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
PcepValueType tlv;
short hType = tempCb.readShort();
int iValue = 0;
short length = tempCb.readShort();
switch (hType) {
case AutonomousSystemTlv.TYPE:
iValue = tempCb.readInt();
tlv = new AutonomousSystemTlv(iValue);
break;
case BGPLSidentifierTlv.TYPE:
iValue = tempCb.readInt();
tlv = new BGPLSidentifierTlv(iValue);
break;
case OSPFareaIDsubTlv.TYPE:
iValue = tempCb.readInt();
tlv = new OSPFareaIDsubTlv(iValue);
break;
case RouterIDSubTlv.TYPE:
tlv = RouterIDSubTlv.read(tempCb, length);
break;
default:
throw new PcepParseException("Unsupported Sub TLV type :" + hType);
}
// Check for the padding
int pad = length % 4;
if (0 < pad) {
pad = 4 - pad;
if (pad <= tempCb.readableBytes()) {
tempCb.skipBytes(pad);
}
}
llNodeDescriptorSubTLVs.add(tlv);
}
if (0 < tempCb.readableBytes()) {
throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
}
return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
.add("NodeDescriptorSubTLVs", llNodeDescriptorSubTLVs).toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides MPLS Protocol Mask.
*/
public class MPLSProtocolMaskTlv implements PcepValueType {
/* Reference :[I-D.ietf-idr-ls-distribution]/3.3.2.2
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=TDB39 | Length =1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|L|R| Reserved |
+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(MPLSProtocolMaskTlv.class);
public static final short TYPE = 1094; //TDB39
public static final short LENGTH = 1;
public static final int SET = 1;
public static final byte LFLAG_SET = (byte) 0x80;
public static final byte RFLAG_SET = 0x40;
private final byte rawValue;
private final boolean bLFlag;
private final boolean bRFlag;
private final boolean isRawValueSet;
/**
* constructor to initialize rawValue.
*
* @param rawValue MPLS Protocol Mask Flag Bits
*/
public MPLSProtocolMaskTlv(byte rawValue) {
this.rawValue = rawValue;
isRawValueSet = true;
byte temp = rawValue;
if ((temp & LFLAG_SET) == SET) {
this.bLFlag = true;
} else {
this.bLFlag = false;
}
if ((temp & RFLAG_SET) == SET) {
this.bRFlag = true;
} else {
this.bRFlag = false;
}
}
/**
* constructor to initialize different Flags.
*
* @param bLFlag L-flag
* @param bRFlag R-flag
*/
public MPLSProtocolMaskTlv(boolean bLFlag, boolean bRFlag) {
this.bLFlag = bLFlag;
this.bRFlag = bRFlag;
this.rawValue = 0;
isRawValueSet = false;
}
/**
* Returns newly created MPLSProtocolMaskTlv object.
*
* @param raw MPLS Protocol Mask Tlv
* @return new object of MPLS Protocol Mask Tlv
*/
public static MPLSProtocolMaskTlv of(final byte raw) {
return new MPLSProtocolMaskTlv(raw);
}
/**
* Returns L-flag.
*
* @return bLFlag L-flag
*/
public boolean getbLFlag() {
return bLFlag;
}
/**
* Returns R-flag.
*
* @return bRFlag R-flag
*/
public boolean getbRFlag() {
return bRFlag;
}
/**
* Returns raw value.
*
* @return rawValue raw value
*/
public byte getByte() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
if (isRawValueSet) {
return Objects.hash(rawValue);
} else {
return Objects.hash(bLFlag, bRFlag);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof MPLSProtocolMaskTlv) {
MPLSProtocolMaskTlv other = (MPLSProtocolMaskTlv) obj;
if (isRawValueSet) {
return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag);
} else {
return Objects.equals(this.rawValue, other.rawValue);
}
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
if (isRawValueSet) {
c.writeByte(rawValue);
} else {
byte temp = 0;
if (bLFlag) {
temp = (byte) (temp | LFLAG_SET);
}
if (bRFlag) {
temp = (byte) (temp | RFLAG_SET);
}
c.writeByte(temp);
}
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of MPLS Protocol Mask Tlv.
*
* @param c input channel buffer
* @return object of MPLS Protocol Mask Tlv
*/
public static PcepValueType read(ChannelBuffer c) {
byte temp = c.readByte();
boolean bLFlag;
boolean bRFlag;
if ((temp & LFLAG_SET) == SET) {
bLFlag = true;
} else {
bLFlag = false;
}
if ((temp & RFLAG_SET) == SET) {
bRFlag = true;
} else {
bRFlag = false;
}
return new MPLSProtocolMaskTlv(bLFlag, bRFlag);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provide the Maximum Link Bandwidth.
*/
public class MaximumLinkBandwidthTlv implements PcepValueType {
/* Reference :[RFC5305]/3.3.
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TDB34] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Maximum Link Bandwidth |
+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
*/
protected static final Logger log = LoggerFactory.getLogger(MaximumLinkBandwidthTlv.class);
public static final short TYPE = 9; //TDB34
public static final short LENGTH = 4;
private final int rawValue;
/**
* Constructor to initialize rawValue.
*
* @param rawValue Maximum-Link-Bandwidth
*/
public MaximumLinkBandwidthTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created MaximumLinkBandwidthTlv object.
*
* @param raw value of Maximum-Link-Bandwidth
* @return object of MaximumLinkBandwidthTlv
*/
public static MaximumLinkBandwidthTlv of(final int raw) {
return new MaximumLinkBandwidthTlv(raw);
}
/**
* Returns value of Maximum Link Bandwidth.
*
* @return rawValue Maximum Link Bandwidth
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof MaximumLinkBandwidthTlv) {
MaximumLinkBandwidthTlv other = (MaximumLinkBandwidthTlv) obj;
return Objects.equals(rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of MaximumLinkBandwidthTlv.
*
* @param c input channel buffer
* @return object of MaximumLinkBandwidthTlv
*/
public static MaximumLinkBandwidthTlv read(ChannelBuffer c) {
return MaximumLinkBandwidthTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provide the Maximum Reservable Link Bandwidth.
*/
public class MaximumReservableLinkBandwidthTlv implements PcepValueType {
/* Reference :[RFC5305]/3.5.
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TDB35] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Maximum Reservable Link Bandwidth |
+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
*/
protected static final Logger log = LoggerFactory.getLogger(MaximumReservableLinkBandwidthTlv.class);
public static final short TYPE = 10; // TDB35
public static final short LENGTH = 4;
private final int rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue MaximumReservableLinkBandwidth
*/
public MaximumReservableLinkBandwidthTlv(int rawValue) {
log.debug("MaximumReservableLinkBandwidthTlv");
this.rawValue = rawValue;
}
/**
* Returns newly created MaximumReservableLinkBandwidth object.
*
* @param raw MaximumReservableLinkBandwidth
* @return object of MaximumReservableLinkBandwidthTlv
*/
public static MaximumReservableLinkBandwidthTlv of(final int raw) {
return new MaximumReservableLinkBandwidthTlv(raw);
}
/**
* Returns value of Maximum Reservable Link Bandwidth.
* @return rawValue Maximum Reservable Link Bandwidth
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof MaximumReservableLinkBandwidthTlv) {
MaximumReservableLinkBandwidthTlv other = (MaximumReservableLinkBandwidthTlv) obj;
return Objects.equals(this.rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of MaximumReservableLinkBandwidthTlv.
*
* @param c input channel buffer
* @return object of MaximumReservableLinkBandwidthTlv
*/
public static MaximumReservableLinkBandwidthTlv read(ChannelBuffer c) {
return MaximumReservableLinkBandwidthTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provide node Flags bits.
*/
public class NodeFlagBitsTlv implements PcepValueType {
/* Reference :[I-D.ietf-idr- ls-distribution] /3.3.1.1
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD21] | Length=1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|O|T|E|B| Reserved|
+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(NodeFlagBitsTlv.class);
public static final short TYPE = 14;
public static final short LENGTH = 1;
public static final int SET = 1;
public static final byte OFLAG_SET = (byte) 0x80;
public static final byte TFLAG_SET = 0x40;
public static final byte EFLAG_SET = 0x20;
public static final byte BFLAG_SET = 0x10;
private final byte rawValue;
private final boolean bOFlag;
private final boolean bTFlag;
private final boolean bEFlag;
private final boolean bBFlag;
private final boolean isRawValueSet;
/**
* constructor to initialize rawValue.
*
* @param rawValue of Node Flag Bits TLV
*/
public NodeFlagBitsTlv(byte rawValue) {
this.rawValue = rawValue;
isRawValueSet = true;
byte temp = rawValue;
this.bOFlag = (temp & OFLAG_SET) == OFLAG_SET ? true : false;
this.bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false;
this.bEFlag = (temp & EFLAG_SET) == EFLAG_SET ? true : false;
this.bBFlag = (temp & BFLAG_SET) == BFLAG_SET ? true : false;
}
/**
* constructor to initialize different Flags.
*
* @param bOFlag O-flag
* @param bTFlag T-flag
* @param bEFlag E-flag
* @param bBFlag B-flag
*/
public NodeFlagBitsTlv(boolean bOFlag, boolean bTFlag, boolean bEFlag, boolean bBFlag) {
this.bOFlag = bOFlag;
this.bTFlag = bTFlag;
this.bEFlag = bEFlag;
this.bBFlag = bBFlag;
this.rawValue = 0;
this.isRawValueSet = false;
}
/**
* Returns newly created NodeFlagBitsTlv object.
*
* @param raw of Node Flag Bits TLV
* @return new object of NodeFlagBitsTlv
*/
public static NodeFlagBitsTlv of(final byte raw) {
return new NodeFlagBitsTlv(raw);
}
/**
* Returns raw value of NodeFlagBitsTlv.
*
* @return rawValue raw value
*/
public byte getbyte() {
return rawValue;
}
/**
* Returns O-flag.
*
* @return bOFlag O-flag
*/
public boolean getOFlag() {
return bOFlag;
}
/**
* Returns T-flag.
*
* @return bTFlag T-flag
*/
public boolean getTFlag() {
return bTFlag;
}
/**
* Returns E-flag.
*
* @return bEFlag E-flag
*/
public boolean getEFlag() {
return bEFlag;
}
/**
* Returns B-flag.
*
* @return bBFlag B-flag
*/
public boolean getBFlag() {
return bBFlag;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
if (isRawValueSet) {
return Objects.hash(rawValue);
} else {
return Objects.hash(bOFlag, bTFlag, bEFlag, bBFlag);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof NodeFlagBitsTlv) {
NodeFlagBitsTlv other = (NodeFlagBitsTlv) obj;
if (isRawValueSet) {
return Objects.equals(this.bOFlag, other.bOFlag) && Objects.equals(this.bTFlag, other.bTFlag)
&& Objects.equals(this.bEFlag, other.bEFlag) && Objects.equals(this.bBFlag, other.bBFlag);
} else {
return Objects.equals(this.rawValue, other.rawValue);
}
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
if (isRawValueSet) {
c.writeByte(rawValue);
} else {
byte temp = 0;
if (bOFlag) {
temp = (byte) (temp | OFLAG_SET);
}
if (bTFlag) {
temp = (byte) (temp | TFLAG_SET);
}
if (bEFlag) {
temp = (byte) (temp | EFLAG_SET);
}
if (bBFlag) {
temp = (byte) (temp | BFLAG_SET);
}
c.writeByte(temp);
}
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of NodeFlagBitsTlv.
*
* @param c input channel buffer
* @return object of NodeFlagBitsTlv
*/
public static PcepValueType read(ChannelBuffer c) {
return NodeFlagBitsTlv.of(c.readByte());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
.add("OFlag", (bOFlag) ? 1 : 0).add("TFlag", (bTFlag) ? 1 : 0).add("EFlag", (bEFlag) ? 1 : 0)
.add("BFlag", (bBFlag) ? 1 : 0).toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provide the name for the node.
*/
public class NodeNameTlv implements PcepValueType {
/* reference :[I-D.ietf-idr-ls-distribution]/3.3.1.3
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD23] | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// Node Name (variable) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(NodeNameTlv.class);
public static final short TYPE = 1007; //TODO:check and change TBD23
public final short hLength;
private final byte[] rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue of Node Name
* @param hLength length
*/
public NodeNameTlv(byte[] rawValue, short hLength) {
log.debug("NodeNameTlv");
this.rawValue = rawValue;
if (0 == hLength) {
this.hLength = (short) rawValue.length;
} else {
this.hLength = hLength;
}
}
/**
* Returns newly created NodeNameTlv object.
*
* @param raw of NodeName
* @param hLength length
* @return new object of Node Name Tlv
*/
public static NodeNameTlv of(final byte[] raw, short hLength) {
return new NodeNameTlv(raw, hLength);
}
/**
* Returns RawValue for NodeName.
*
* @return rawValue raw value
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof NodeNameTlv) {
NodeNameTlv other = (NodeNameTlv) obj;
return Objects.equals(this.rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(hLength);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of NodeNameTlv.
*
* @param c input channel buffer
* @param hLength length
* @return object of Node Name TLV
*/
public static PcepValueType read(ChannelBuffer c, short hLength) {
byte[] iNodeName = new byte[hLength];
c.readBytes(iNodeName, 0, hLength);
return new NodeNameTlv(iNodeName, hLength);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", hLength);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides area ID for OSPF area.
*/
public class OSPFareaIDsubTlv implements PcepValueType {
/* Reference :draft-ietf-idr-ls-distribution-10.
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD12] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| opaque value (32 Bit AS Number) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(OSPFareaIDsubTlv.class);
public static final short TYPE = 600; //TODD:change this TBD12
public static final short LENGTH = 4;
private final int rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue area ID for OSPF area.
*/
public OSPFareaIDsubTlv(int rawValue) {
this.rawValue = rawValue;
}
/**
* Returns newly created OSPFareaIDsubTlv object.
*
* @param raw opaque value of AreaID
* @return new object of OSPF area ID sub TLV
*/
public static OSPFareaIDsubTlv of(final int raw) {
return new OSPFareaIDsubTlv(raw);
}
/**
* Returns RawValue opaque value of AreaID.
*
* @return rawValue Area ID
*/
public int getInt() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof OSPFareaIDsubTlv) {
OSPFareaIDsubTlv other = (OSPFareaIDsubTlv) obj;
return Objects.equals(this.rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of OSPFAreaIdSubTlv.
*
* @param c input channel buffer
* @return object of OSPFAreaIdSubTlv
*/
public static OSPFareaIDsubTlv read(ChannelBuffer c) {
return OSPFareaIDsubTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides Opaque Link Attribute.
*/
public class OpaqueLinkAttributeTlv implements PcepValueType {
/*
* TLV format.
* Reference :[I-D.ietf-idr-attributesls-distribution] /3.3.2.6
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=TBD42 | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// Opaque link attributes (variable) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(OpaqueLinkAttributeTlv.class);
public static final short TYPE = 1097; //TODO:NEED TO HANDLE TDB42
private final short hLength;
private final byte[] rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue of Opaque Link Attribute
* @param hLength length
*/
public OpaqueLinkAttributeTlv(byte[] rawValue, short hLength) {
log.debug("OpaqueLinkAttributeTlv");
this.rawValue = rawValue;
if (0 == hLength) {
this.hLength = (short) rawValue.length;
} else {
this.hLength = hLength;
}
}
/**
* Returns newly created OpaqueLinkAttributeTlv object.
*
* @param raw of Opaque Link Attribute
* @param hLength length
* @return new object of OpaqueLinkAttributeTlv
*/
public static OpaqueLinkAttributeTlv of(final byte[] raw, short hLength) {
return new OpaqueLinkAttributeTlv(raw, hLength);
}
/**
* Returns raw value of Opaque Link Attribute Tlv.
* @return rawValue raw value
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof OpaqueLinkAttributeTlv) {
OpaqueLinkAttributeTlv other = (OpaqueLinkAttributeTlv) obj;
return Objects.equals(this.rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(hLength);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of OpaqueLinkAttributeTlv.
*
* @param c input channel buffer
* @param hLength length
* @return object of Opaque Link Attribute Tlv
*/
public static PcepValueType read(ChannelBuffer c, short hLength) {
byte[] iOpaqueValue = new byte[hLength];
c.readBytes(iOpaqueValue, 0, hLength);
return new OpaqueLinkAttributeTlv(iOpaqueValue, hLength);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", hLength);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
/**
* Provides Opaque node attributes.
*/
public class OpaqueNodeAttributeTlv implements PcepValueType {
/*
* Reference [I-D.ietf-idr-Properties ls-distribution] /3.3.1.5
* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=[TBD22] | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// Opaque node attributes (variable) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(OpaqueNodeAttributeTlv.class);
public static final short TYPE = 1001;
private final short hLength;
private final byte[] rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue Opaque Node Attribute
* @param hLength length
*/
public OpaqueNodeAttributeTlv(byte[] rawValue, short hLength) {
this.rawValue = rawValue;
if (0 == hLength) {
this.hLength = (short) rawValue.length;
} else {
this.hLength = hLength;
}
}
/**
* Returns newly created OpaqueNodeAttributeTlv object.
*
* @param raw value of Opaque Node Attribute
* @param hLength length
* @return new object of Opaque Node Attribute Tlv
*/
public static OpaqueNodeAttributeTlv of(final byte[] raw, short hLength) {
return new OpaqueNodeAttributeTlv(raw, hLength);
}
/**
* Returns raw value of Opaque Node Attribute Tlv.
*
* @return rawValue of Opaque Node Attribute
*/
public byte[] getValue() {
return rawValue;
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return hLength;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof OpaqueLinkAttributeTlv) {
OpaqueNodeAttributeTlv other = (OpaqueNodeAttributeTlv) obj;
return Objects.equals(this.rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(hLength);
c.writeBytes(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of Opaque Node Attribute Tlv.
*
* @param c input channel buffer
* @param hLength length
* @return object of OpaqueNodeAttributeTlv
*/
public static PcepValueType read(ChannelBuffer c, short hLength) {
byte[] iOpaqueValue = new byte[hLength];
c.readBytes(iOpaqueValue, 0, hLength);
return new OpaqueNodeAttributeTlv(iOpaqueValue, hLength);
}
@Override
public String toString() {
ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
toStrHelper.add("Type", TYPE);
toStrHelper.add("Length", hLength);
StringBuffer result = new StringBuffer();
for (byte b : rawValue) {
result.append(String.format("%02X ", b));
}
toStrHelper.add("Value", result);
return toStrHelper.toString();
}
}
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides PceccCapabilityTlv.
*/
public class PceccCapabilityTlv implements PcepValueType {
/* PCECC CAPABILITY TLV
* Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01, section-7.1.1
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=32 | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Flags |G|L|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class);
public static final short TYPE = 32;
public static final short LENGTH = 4;
public static final int SET = 1;
public static final byte LFLAG_CHECK = 0x01;
public static final byte GFLAG_CHECK = 0x02;
private final boolean bGFlag;
private final boolean bLFlag;
private final int rawValue;
private final boolean isRawValueSet;
/**
* Constructor to initialize raw Value.
*
* @param rawValue raw value
*/
public PceccCapabilityTlv(final int rawValue) {
this.rawValue = rawValue;
this.isRawValueSet = true;
bLFlag = (rawValue & LFLAG_CHECK) == LFLAG_CHECK ? true : false;
bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK ? true : false;
}
/**
* Constructor to initialize G-flag L-flag.
* @param bGFlag G-flag
* @param bLFlag L-flag
*/
public PceccCapabilityTlv(boolean bGFlag, boolean bLFlag) {
this.bGFlag = bGFlag;
this.bLFlag = bLFlag;
this.rawValue = 0;
this.isRawValueSet = false;
}
/**
* Returns newly created PceccCapabilityTlv object.
*
* @param raw value
* @return object of Pcecc Capability Tlv
*/
public static PceccCapabilityTlv of(final int raw) {
return new PceccCapabilityTlv(raw);
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
/**
* Returns G-flag.
* @return bGFlag G-flag
*/
public boolean getGFlag() {
return bGFlag;
}
/**
* Returns L-flag.
* @return bLFlag L-flag
*/
public boolean getLFlag() {
return bLFlag;
}
/**
* Returns the raw value.
* @return rawValue Flags
*/
public int getInt() {
return rawValue;
}
@Override
public short getType() {
return TYPE;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public int hashCode() {
if (isRawValueSet) {
return Objects.hash(rawValue);
} else {
return Objects.hash(bLFlag, bGFlag);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PceccCapabilityTlv) {
PceccCapabilityTlv other = (PceccCapabilityTlv) obj;
if (isRawValueSet) {
return Objects.equals(this.rawValue, other.rawValue);
} else {
return Objects.equals(this.bGFlag, other.bGFlag) && Objects.equals(this.bLFlag, other.bLFlag);
}
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
int temp = 0;
c.writeShort(TYPE);
c.writeShort(LENGTH);
if (isRawValueSet) {
c.writeInt(rawValue);
} else {
if (bGFlag) {
temp = temp | GFLAG_CHECK;
}
if (bLFlag) {
temp = temp | LFLAG_CHECK;
}
c.writeInt(temp);
}
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads channel buffer and returns object of PceccCapabilityTlv.
*
* @param c input channel buffer
* @return object of PceccCapabilityTlv
*/
public static PceccCapabilityTlv read(ChannelBuffer c) {
return PceccCapabilityTlv.of(c.readInt());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.MoreObjects;
/**
* Provides CEP LABEL DB VERSION TLV which contains LSP State DB Version (32 Bit ).
*/
public class PcepLabelDbVerTlv implements PcepValueType {
/* PCEP LABEL DB VERSION TLV format
Reference : draft-ietf-pce-stateful-sync-optimizations-02, section 3.3.1
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=23 | Length=8 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LSP State DB Version |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(PcepLabelDbVerTlv.class);
public static final short TYPE = 34;
public static final short LENGTH = 8;
private final long rawValue;
/**
* constructor to initialize rawValue.
*
* @param rawValue of Pcep Label Db Version Tlv
*/
public PcepLabelDbVerTlv(final long rawValue) {
log.debug("PcepLabelDbVerTlv");
this.rawValue = rawValue;
}
/**
* Returns newly created PcepLabelDbVerTlv object.
*
* @param raw LSP State DB Version
* @return object of PcepLabelDbVerTlv
*/
public static PcepLabelDbVerTlv of(final long raw) {
return new PcepLabelDbVerTlv(raw);
}
@Override
public PcepVersion getVersion() {
return PcepVersion.PCEP_1;
}
/**
* Returns LSP State DB Version.
* @return raw value
*/
public long getLong() {
return rawValue;
}
@Override
public short getLength() {
return LENGTH;
}
@Override
public short getType() {
return TYPE;
}
@Override
public int hashCode() {
return Objects.hash(rawValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PceccCapabilityTlv) {
PcepLabelDbVerTlv other = (PcepLabelDbVerTlv) obj;
return Objects.equals(this.rawValue, other.rawValue);
}
return false;
}
@Override
public int write(ChannelBuffer c) {
int iLenStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeLong(rawValue);
return c.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of PcepLabelDbVerTlv.
*
* @param c input channel buffer
* @return object of PcepLabelDbVerTlv
*/
public static PcepLabelDbVerTlv read(ChannelBuffer c) {
return PcepLabelDbVerTlv.of(c.readLong());
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
.toString();
}
}