diff options
Diffstat (limited to 'framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr')
24 files changed, 0 insertions, 3619 deletions
diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java deleted file mode 100755 index e0fef7c8..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute node flag. - */ -public final class BgpAttrNodeFlagBitTlv implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpAttrNodeFlagBitTlv.class); - - public static final int ATTRNODE_FLAGBIT = 1024; - - /* Node flag bit TLV */ - private final boolean bOverloadBit; - private final boolean bAttachedBit; - private final boolean bExternalBit; - private final boolean bAbrBit; - - public static final byte FIRST_BIT = (byte) 0x80; - public static final byte SECOND_BIT = 0x40; - public static final byte THIRD_BIT = 0x20; - public static final byte FOURTH_BIT = 0x01; - - /** - * Constructor to initialize parameters. - * - * @param bOverloadBit Overload bit - * @param bAttachedBit Attached bit - * @param bExternalBit External bit - * @param bAbrBit ABR Bit - */ - private BgpAttrNodeFlagBitTlv(boolean bOverloadBit, boolean bAttachedBit, - boolean bExternalBit, boolean bAbrBit) { - this.bOverloadBit = bOverloadBit; - this.bAttachedBit = bAttachedBit; - this.bExternalBit = bExternalBit; - this.bAbrBit = bAbrBit; - } - - /** - * Returns object of this class with specified values. - * - * @param bOverloadBit Overload bit - * @param bAttachedBit Attached bit - * @param bExternalBit External bit - * @param bAbrBit ABR Bit - * @return object of BgpAttrNodeFlagBitTlv - */ - public static BgpAttrNodeFlagBitTlv of(final boolean bOverloadBit, - final boolean bAttachedBit, - final boolean bExternalBit, - final boolean bAbrBit) { - return new BgpAttrNodeFlagBitTlv(bOverloadBit, bAttachedBit, - bExternalBit, bAbrBit); - } - - /** - * Reads the Node Flag Bits. - * - * @param cb ChannelBuffer - * @return attribute node flag bit tlv - * @throws BgpParseException while parsing BgpAttrNodeFlagBitTlv - */ - public static BgpAttrNodeFlagBitTlv read(ChannelBuffer cb) - throws BgpParseException { - boolean bOverloadBit = false; - boolean bAttachedBit = false; - boolean bExternalBit = false; - boolean bAbrBit = false; - - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != 1) || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - byte nodeFlagBits = cb.readByte(); - - bOverloadBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT); - bAttachedBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT); - bExternalBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT); - bAbrBit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT); - - return BgpAttrNodeFlagBitTlv.of(bOverloadBit, bAttachedBit, - bExternalBit, bAbrBit); - } - - /** - * Returns Overload Bit. - * - * @return Overload Bit - */ - public boolean overLoadBit() { - return bOverloadBit; - } - - /** - * Returns Attached Bit. - * - * @return Attached Bit - */ - public boolean attachedBit() { - return bAttachedBit; - } - - /** - * Returns External Bit. - * - * @return External Bit - */ - public boolean externalBit() { - return bExternalBit; - } - - /** - * Returns ABR Bit. - * - * @return ABR Bit - */ - public boolean abrBit() { - return bAbrBit; - } - - @Override - public short getType() { - return ATTRNODE_FLAGBIT; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public int hashCode() { - return Objects.hash(bOverloadBit, bAttachedBit, bExternalBit, bAbrBit); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrNodeFlagBitTlv) { - BgpAttrNodeFlagBitTlv other = (BgpAttrNodeFlagBitTlv) obj; - return Objects.equals(bOverloadBit, other.bOverloadBit) - && Objects.equals(bAttachedBit, other.bAttachedBit) - && Objects.equals(bExternalBit, other.bExternalBit) - && Objects.equals(bAbrBit, other.bAbrBit); - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("bOverloadBit", bOverloadBit) - .add("bAttachedBit", bAttachedBit) - .add("bExternalBit", bExternalBit).add("bAbrBit", bAbrBit) - .toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java deleted file mode 100644 index 0435a65f..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeIsIsAreaId.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Arrays; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute ISIS Area Identifier. - */ -public class BgpAttrNodeIsIsAreaId implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpAttrNodeIsIsAreaId.class); - - public static final int ATTRNODE_ISISAREAID = 1027; - - /* IS-IS Area Identifier TLV */ - private byte[] isisAreaId; - - /** - * Constructor to initialize value. - * - * @param isisAreaId ISIS area Identifier - */ - public BgpAttrNodeIsIsAreaId(byte[] isisAreaId) { - this.isisAreaId = Arrays.copyOf(isisAreaId, isisAreaId.length); - } - - /** - * Returns object of this class with specified values. - * - * @param isisAreaId ISIS area Identifier - * @return object of BgpAttrNodeIsIsAreaId - */ - public static BgpAttrNodeIsIsAreaId of(final byte[] isisAreaId) { - return new BgpAttrNodeIsIsAreaId(isisAreaId); - } - - /** - * Reads the IS-IS Area Identifier. - * - * @param cb ChannelBuffer - * @return object of BgpAttrNodeIsIsAreaId - * @throws BgpParseException while parsing BgpAttrNodeIsIsAreaId - */ - public static BgpAttrNodeIsIsAreaId read(ChannelBuffer cb) - throws BgpParseException { - byte[] isisAreaId; - - short lsAttrLength = cb.readShort(); - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - isisAreaId = new byte[lsAttrLength]; - cb.readBytes(isisAreaId); - - return BgpAttrNodeIsIsAreaId.of(isisAreaId); - } - - /** - * Returns ISIS area Identifier. - * - * @return Area ID - */ - public byte[] attrNodeIsIsAreaId() { - return isisAreaId; - } - - @Override - public short getType() { - return ATTRNODE_ISISAREAID; - } - - @Override - public int hashCode() { - return Arrays.hashCode(isisAreaId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrNodeIsIsAreaId) { - BgpAttrNodeIsIsAreaId other = (BgpAttrNodeIsIsAreaId) obj; - return Arrays.equals(isisAreaId, other.isisAreaId); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("isisAreaId", isisAreaId).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java deleted file mode 100644 index 31d855db..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * BGP Multi-Topology ID of the LS attribute. - */ -public class BgpAttrNodeMultiTopologyId implements BgpValueType { - - private static final Logger log = LoggerFactory - .getLogger(BgpAttrNodeMultiTopologyId.class); - - public static final int ATTRNODE_MULTITOPOLOGY = 263; - - /* Opaque Node Attribute */ - private List<Short> multiTopologyId = new ArrayList<Short>(); - - /** - * Constructor to initialize the Node attribute multi-topology ID. - * - * @param multiTopologyId multi-topology ID - */ - public BgpAttrNodeMultiTopologyId(List<Short> multiTopologyId) { - this.multiTopologyId = multiTopologyId; - } - - /** - * Returns object of this class with specified values. - * - * @param multiTopologyId Prefix Metric - * @return object of BgpAttrNodeMultiTopologyId - */ - public static BgpAttrNodeMultiTopologyId of(ArrayList<Short> multiTopologyId) { - return new BgpAttrNodeMultiTopologyId(multiTopologyId); - } - - /** - * Reads the Multi-topology ID of Node attribute. - * - * @param cb ChannelBuffer - * @return Constructor of BgpAttrNodeMultiTopologyId - * @throws BgpParseException while parsing BgpAttrNodeMultiTopologyId - */ - public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb) - throws BgpParseException { - ArrayList<Short> multiTopologyId = new ArrayList<Short>(); - short tempMultiTopologyId; - short lsAttrLength = cb.readShort(); - int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - for (int i = 0; i < len; i++) { - tempMultiTopologyId = cb.readShort(); - multiTopologyId.add(new Short(tempMultiTopologyId)); - } - - return new BgpAttrNodeMultiTopologyId(multiTopologyId); - } - - /** - * to get the multi-topology ID. - * - * @return multitopology ID - */ - public List<Short> attrMultiTopologyId() { - return multiTopologyId; - } - - @Override - public short getType() { - return ATTRNODE_MULTITOPOLOGY; - } - - @Override - public int hashCode() { - return Objects.hash(multiTopologyId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrNodeMultiTopologyId) { - BgpAttrNodeMultiTopologyId other = (BgpAttrNodeMultiTopologyId) obj; - return Objects.equals(multiTopologyId, other.multiTopologyId); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .omitNullValues() - .add("multiTopologyId", multiTopologyId) - .toString(); - } - - @Override - public int compareTo(Object o) { - if (this.equals(o)) { - return 0; - } - int countOtherSubTlv = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.size(); - int countObjSubTlv = multiTopologyId.size(); - if (countOtherSubTlv != countObjSubTlv) { - if (countOtherSubTlv > countObjSubTlv) { - return 1; - } else { - return -1; - } - } - ListIterator<Short> listIterator = multiTopologyId.listIterator(); - ListIterator<Short> listIteratorOther = ((BgpAttrNodeMultiTopologyId) o).multiTopologyId.listIterator(); - while (listIterator.hasNext()) { - short id = listIterator.next(); - short id1 = listIteratorOther.next(); - if (((Short) id).compareTo((Short) id1) != 0) { - return ((Short) id).compareTo((Short) id1); - } - } - return 0; - } -}
\ No newline at end of file diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java deleted file mode 100644 index 2e1c7a05..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Arrays; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute node name. - */ -public class BgpAttrNodeName implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpAttrNodeName.class); - - public static final int ATTRNODE_NAME = 1026; - - /* Node Name */ - private byte[] nodeName; - - /** - * Constructor to initialize value. - * - * @param nodeName node name - */ - public BgpAttrNodeName(byte[] nodeName) { - this.nodeName = Arrays.copyOf(nodeName, nodeName.length); - } - - /** - * Returns object of this class with specified values. - * - * @param nodeName node name - * @return object of BgpAttrNodeName - */ - public static BgpAttrNodeName of(final byte[] nodeName) { - return new BgpAttrNodeName(nodeName); - } - - /** - * Reads the LS attribute node name. - * - * @param cb ChannelBuffer - * @return object of BgpAttrNodeName - * @throws BgpParseException while parsing BgpAttrNodeName - */ - public static BgpAttrNodeName read(ChannelBuffer cb) - throws BgpParseException { - byte[] nodeName; - - short lsAttrLength = cb.readShort(); - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - nodeName = new byte[lsAttrLength]; - cb.readBytes(nodeName); - return BgpAttrNodeName.of(nodeName); - } - - /** - * Returns LS attribute node name. - * - * @return node name - */ - public byte[] attrNodeName() { - return nodeName; - } - - @Override - public short getType() { - return ATTRNODE_NAME; - } - - @Override - public int hashCode() { - return Arrays.hashCode(nodeName); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrNodeName) { - BgpAttrNodeName other = (BgpAttrNodeName) obj; - return Arrays.equals(nodeName, other.nodeName); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("nodeName", nodeName).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java deleted file mode 100644 index 545755a7..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrOpaqueNode.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Arrays; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute opaque node. - */ -public class BgpAttrOpaqueNode implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpAttrOpaqueNode.class); - - public static final int ATTRNODE_OPAQUEDATA = 1025; - - /* Opaque Node Attribute */ - private byte[] opaqueNodeAttribute; - - /** - * Constructor to initialize parameter. - * - * @param opaqueNodeAttribute opaque node attribute - */ - public BgpAttrOpaqueNode(byte[] opaqueNodeAttribute) { - this.opaqueNodeAttribute = Arrays.copyOf(opaqueNodeAttribute, opaqueNodeAttribute.length); - } - - /** - * Returns object of this class with specified values. - * - * @param opaqueNodeAttribute Prefix Metric - * @return object of BgpAttrOpaqueNode - */ - public static BgpAttrOpaqueNode of(byte[] opaqueNodeAttribute) { - return new BgpAttrOpaqueNode(opaqueNodeAttribute); - } - - /** - * Reads the Opaque Node Properties. - * - * @param cb ChannelBuffer - * @return object of BgpAttrOpaqueNode - * @throws BgpParseException while parsing BgpAttrOpaqueNode - */ - public static BgpAttrOpaqueNode read(ChannelBuffer cb) - throws BgpParseException { - - byte[] opaqueNodeAttribute; - - short lsAttrLength = cb.readShort(); - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - opaqueNodeAttribute = new byte[lsAttrLength]; - cb.readBytes(opaqueNodeAttribute); - - return BgpAttrOpaqueNode.of(opaqueNodeAttribute); - } - - /** - * Returns opaque node attribute. - * - * @return LS node attribute value - */ - public byte[] attrOpaqueNode() { - return opaqueNodeAttribute; - } - - @Override - public short getType() { - return ATTRNODE_OPAQUEDATA; - } - - @Override - public int hashCode() { - return Arrays.hashCode(opaqueNodeAttribute); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrOpaqueNode) { - BgpAttrOpaqueNode other = (BgpAttrOpaqueNode) obj; - return Arrays - .equals(opaqueNodeAttribute, other.opaqueNodeAttribute); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("opaqueNodeAttribute", opaqueNodeAttribute).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java deleted file mode 100644 index f3c0d17b..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV4.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onlab.packet.Ip4Address; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute node router ID. - */ -public final class BgpAttrRouterIdV4 implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpAttrRouterIdV4.class); - - private final short sType; - - /* IPv4 Router-ID of Node */ - private final Ip4Address ip4RouterId; - - /** - * Constructor to initialize the value. - * - * @param ip4RouterId IPV4 address of router - * @param sType TLV type - */ - private BgpAttrRouterIdV4(Ip4Address ip4RouterId, short sType) { - this.ip4RouterId = ip4RouterId; - this.sType = sType; - } - - /** - * Returns object of this class with specified values. - * - * @param ip4RouterId IPv4 address - * @param sType Type of this TLV - * @return object of BgpAttrRouterIdV4 - */ - public static BgpAttrRouterIdV4 of(final Ip4Address ip4RouterId, - final short sType) { - return new BgpAttrRouterIdV4(ip4RouterId, sType); - } - - /** - * Reads the IPv4 Router-ID. - * - * @param cb ChannelBuffer - * @param sType tag type - * @return object of BgpAttrRouterIdV4 - * @throws BgpParseException while parsing BgpAttrRouterIdV4 - */ - public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType) - throws BgpParseException { - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - byte[] ipBytes = new byte[lsAttrLength]; - cb.readBytes(ipBytes, 0, lsAttrLength); - Ip4Address ip4RouterId = Ip4Address.valueOf(ipBytes); - return BgpAttrRouterIdV4.of(ip4RouterId, sType); - } - - /** - * Returns the IPV4 router ID. - * - * @return Router ID - */ - public Ip4Address attrRouterId() { - return ip4RouterId; - } - - @Override - public short getType() { - return sType; - } - - @Override - public int hashCode() { - return Objects.hash(ip4RouterId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrRouterIdV4) { - BgpAttrRouterIdV4 other = (BgpAttrRouterIdV4) obj; - return Objects.equals(ip4RouterId, other.ip4RouterId); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("ip4RouterId", ip4RouterId).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java deleted file mode 100644 index 648fd56e..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onlab.packet.Ip6Address; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute IPv6 router ID. - */ -public final class BgpAttrRouterIdV6 implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpAttrRouterIdV6.class); - - private final short sType; - - /* IPv4 Router-ID of Node */ - private final Ip6Address ip6RouterId; - - /** - * Constructor to initialize the value. - * - * @param ip6RouterId IPV6 address of the router ID - * @param sType TLV type - */ - private BgpAttrRouterIdV6(Ip6Address ip6RouterId, short sType) { - this.ip6RouterId = ip6RouterId; - this.sType = sType; - } - - /** - * Returns object of this class with specified values. - * - * @param ip6RouterId IPV6 address of the router ID - * @param sType TLV type - * @return object of BgpAttrRouterIdV6 - */ - public static BgpAttrRouterIdV6 of(final Ip6Address ip6RouterId, - final short sType) { - return new BgpAttrRouterIdV6(ip6RouterId, sType); - } - - /** - * Reads the IPv6 Router-ID. - * - * @param cb ChannelBuffer - * @param sType TLV type - * @return object of BgpAttrRouterIdV6 - * @throws BgpParseException while parsing BgpAttrRouterIdV6 - */ - public static BgpAttrRouterIdV6 read(ChannelBuffer cb, short sType) - throws BgpParseException { - byte[] ipBytes; - Ip6Address ip6RouterId; - - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != 16) || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - ipBytes = new byte[lsAttrLength]; - cb.readBytes(ipBytes); - ip6RouterId = Ip6Address.valueOf(ipBytes); - return BgpAttrRouterIdV6.of(ip6RouterId, sType); - } - - /** - * Returns IPV6 router ID. - * - * @return Router ID - */ - public Ip6Address attrRouterId() { - return ip6RouterId; - } - - @Override - public short getType() { - return sType; - } - - @Override - public int hashCode() { - return Objects.hash(ip6RouterId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpAttrRouterIdV6) { - BgpAttrRouterIdV6 other = (BgpAttrRouterIdV6) obj; - return Objects.equals(ip6RouterId, other.ip6RouterId); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("ip6RouterId", ip6RouterId).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java deleted file mode 100644 index 5721cf6c..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetric.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP link IGP metric attribute. - */ -public class BgpLinkAttrIgpMetric implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrIgpMetric.class); - - public static final int ATTRLINK_IGPMETRIC = 1095; - public static final int ATTRLINK_MAX_LEN = 3; - - /* Variable metric length based on protocol */ - public static final int ISIS_SMALL_METRIC = 1; - public static final int OSPF_LINK_METRIC = 2; - public static final int ISIS_WIDE_METRIC = 3; - - /* IGP Metric */ - private final int igpMetric; - private final int igpMetricLen; - - /** - * Constructor to initialize the value. - * - * @param igpMetric 3 byte IGP metric data. - * @param igpMetricLen length of IGP metric data. - */ - public BgpLinkAttrIgpMetric(final int igpMetric, final int igpMetricLen) { - this.igpMetric = igpMetric; - this.igpMetricLen = igpMetricLen; - } - - /** - * Returns object of this class with specified values. - * - * @param igpMetric 3 byte IGP metric data. - * @param igpMetricLen length of IGP metric data. - * @return object of BgpLinkAttrIgpMetric - */ - public static BgpLinkAttrIgpMetric of(final int igpMetric, - final int igpMetricLen) { - return new BgpLinkAttrIgpMetric(igpMetric, igpMetricLen); - } - - /** - * Reads the BGP link attributes IGP Metric. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrIgpMetric - * @throws BgpParseException while parsing BgpLinkAttrIgpMetric - */ - public static BgpLinkAttrIgpMetric read(ChannelBuffer cb) - throws BgpParseException { - - short linkigp; - int igpMetric = 0; - int igpMetricLen = 0; - - short lsAttrLength = cb.readShort(); - - if (cb.readableBytes() < lsAttrLength - || lsAttrLength > ATTRLINK_MAX_LEN) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - switch (lsAttrLength) { - case ISIS_SMALL_METRIC: - igpMetric = cb.readByte(); - igpMetricLen = ISIS_SMALL_METRIC; - break; - case OSPF_LINK_METRIC: - igpMetric = cb.readShort(); - igpMetricLen = OSPF_LINK_METRIC; - break; - case ISIS_WIDE_METRIC: - linkigp = cb.readShort(); - igpMetric = cb.readByte(); - igpMetric = (igpMetric << 16) | linkigp; - igpMetricLen = ISIS_WIDE_METRIC; - break; - default: // validation is already in place - break; - } - - return BgpLinkAttrIgpMetric.of(igpMetric, igpMetricLen); - } - - /** - * Returns the variable length IGP metric data. - * - * @return IGP metric data - */ - public int attrLinkIgpMetric() { - return igpMetric; - } - - /** - * Returns IGP metric data length. - * - * @return IGP metric length - */ - public int attrLinkIgpMetricLength() { - return igpMetricLen; - } - - @Override - public short getType() { - return ATTRLINK_IGPMETRIC; - } - - @Override - public int hashCode() { - return Objects.hash(igpMetric, igpMetricLen); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrIgpMetric) { - BgpLinkAttrIgpMetric other = (BgpLinkAttrIgpMetric) obj; - return Objects.equals(igpMetric, other.igpMetric) - && Objects.equals(igpMetricLen, other.igpMetricLen); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("igpMetric", igpMetric).add("igpMetricLen", igpMetricLen) - .toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java deleted file mode 100644 index 448f1e58..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIsIsAdminstGrp.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute Is Is Administrative area. - */ -public final class BgpLinkAttrIsIsAdminstGrp implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrIsIsAdminstGrp.class); - - public static final int ATTRLINK_PROTECTIONTYPE = 1088; - public static final int ISIS_ADMIN_DATA_LEN = 4; - - /* ISIS administrative group */ - private final long isisAdminGrp; - - /** - * Constructor to initialize the values. - * - * @param isisAdminGrp ISIS protocol admin group - */ - public BgpLinkAttrIsIsAdminstGrp(long isisAdminGrp) { - this.isisAdminGrp = isisAdminGrp; - } - - /** - * Returns object of this class with specified values. - * - * @param isisAdminGrp ISIS admin group - * @return object of BgpLinkAttrIsIsAdminstGrp - */ - public static BgpLinkAttrIsIsAdminstGrp of(final long isisAdminGrp) { - return new BgpLinkAttrIsIsAdminstGrp(isisAdminGrp); - } - - /** - * Reads the BGP link attributes of ISIS administrative group area. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrIsIsAdminstGrp - * @throws BgpParseException while parsing BgpLinkAttrIsIsAdminstGrp - */ - public static BgpLinkAttrIsIsAdminstGrp read(ChannelBuffer cb) - throws BgpParseException { - long isisAdminGrp; - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != ISIS_ADMIN_DATA_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - isisAdminGrp = cb.readUnsignedInt(); - - return BgpLinkAttrIsIsAdminstGrp.of(isisAdminGrp); - } - - /** - * Link attributes of ISIS administrative group area. - * - * @return long value of the administrative group area - */ - public long linkAttrIsIsAdminGrp() { - return isisAdminGrp; - } - - @Override - public short getType() { - return ATTRLINK_PROTECTIONTYPE; - } - - @Override - public int hashCode() { - return Objects.hash(isisAdminGrp); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrIsIsAdminstGrp) { - BgpLinkAttrIsIsAdminstGrp other = (BgpLinkAttrIsIsAdminstGrp) obj; - return Objects.equals(isisAdminGrp, other.isisAdminGrp); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("isisAdminGrp", isisAdminGrp).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java deleted file mode 100644 index 2711ca94..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMaxLinkBandwidth.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP attribute Max Link bandwidth. - */ -public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrMaxLinkBandwidth.class); - - public static final int MAX_BANDWIDTH_LEN = 4; - public static final int NO_OF_BITS = 8; - - public short type; - - /* ISIS administrative group */ - private final float maxBandwidth; - - /** - * Constructor to initialize the values. - * - * @param maxBandwidth Maximum link bandwidth. - * @param type TLV type - */ - private BgpLinkAttrMaxLinkBandwidth(float maxBandwidth, short type) { - this.maxBandwidth = maxBandwidth; - this.type = type; - } - - /** - * Returns object of this class with specified values. - * - * @param maxBandwidth Maximum link bandwidth. - * @param type TLV type - * @return object of BgpLinkAttrMaxLinkBandwidth - */ - public static BgpLinkAttrMaxLinkBandwidth of(final float maxBandwidth, - final short type) { - return new BgpLinkAttrMaxLinkBandwidth(maxBandwidth, type); - } - - /** - * Reads the BGP link attributes of Maximum link bandwidth. - * - * @param cb Channel buffer - * @param type type of this tlv - * @return object of type BgpLinkAttrMaxLinkBandwidth - * @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth - */ - public static BgpLinkAttrMaxLinkBandwidth read(ChannelBuffer cb, short type) - throws BgpParseException { - float maxBandwidth; - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != MAX_BANDWIDTH_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - maxBandwidth = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS; - - return BgpLinkAttrMaxLinkBandwidth.of(maxBandwidth, type); - } - - /** - * Returns Maximum link bandwidth. - * - * @return Maximum link bandwidth - */ - float linkAttrMaxLinkBandwidth() { - return maxBandwidth; - } - - /** - * Parse the IEEE floating point notation and returns it in normal float. - * - * @param iVal IEEE floating point number - * @return normal float - */ - static float ieeeToFloatRead(int iVal) { - iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8) - | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF)); - - return Float.intBitsToFloat(iVal); - } - - @Override - public short getType() { - return this.type; - } - - @Override - public int hashCode() { - return Objects.hash(maxBandwidth); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrMaxLinkBandwidth) { - BgpLinkAttrMaxLinkBandwidth other = (BgpLinkAttrMaxLinkBandwidth) obj; - return Objects.equals(maxBandwidth, other.maxBandwidth); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("maxBandwidth", maxBandwidth).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java deleted file mode 100644 index 2bf1a59d..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMask.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP MPLS protocol mask attribute. - */ -public class BgpLinkAttrMplsProtocolMask implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrMplsProtocolMask.class); - - public static final int ATTRLINK_MPLSPROTOMASK = 1094; - public static final int MASK_BYTE_LEN = 1; - - private final boolean bLdp; - private final boolean bRsvpTe; - - public static final byte FIRST_BIT = (byte) 0x80; - public static final byte SECOND_BIT = 0x40; - - /** - * Constructor to initialize the values. - * - * @param bLdp boolean value true if LDP flag is available - * @param bRsvpTe boolean value true if RSVP TE information is available - */ - public BgpLinkAttrMplsProtocolMask(boolean bLdp, boolean bRsvpTe) { - this.bLdp = bLdp; - this.bRsvpTe = bRsvpTe; - } - - /** - * Returns object of this class with specified values. - * - * @param bLdp boolean value true if LDP flag is available - * @param bRsvpTe boolean value true if RSVP TE information is available - * @return object of BgpLinkAttrMplsProtocolMask - */ - public static BgpLinkAttrMplsProtocolMask of(final boolean bLdp, - final boolean bRsvpTe) { - return new BgpLinkAttrMplsProtocolMask(bLdp, bRsvpTe); - } - - /** - * Reads the BGP link attributes MPLS protocol mask. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrMPLSProtocolMask - * @throws BgpParseException while parsing BgpLinkAttrMplsProtocolMask - */ - public static BgpLinkAttrMplsProtocolMask read(ChannelBuffer cb) - throws BgpParseException { - boolean bLdp = false; - boolean bRsvpTe = false; - - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != MASK_BYTE_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - byte flags = cb.readByte(); - - bLdp = ((flags & (byte) FIRST_BIT) == FIRST_BIT); - bRsvpTe = ((flags & (byte) SECOND_BIT) == SECOND_BIT); - - return BgpLinkAttrMplsProtocolMask.of(bLdp, bRsvpTe); - } - - /** - * Returns true if LDP bit is set. - * - * @return True if LDP information is set else false. - */ - public boolean ldpBit() { - return bLdp; - } - - /** - * Returns RSVP TE information. - * - * @return True if RSVP TE information is set else false. - */ - public boolean rsvpBit() { - return bRsvpTe; - } - - @Override - public short getType() { - return ATTRLINK_MPLSPROTOMASK; - } - - @Override - public int hashCode() { - return Objects.hash(bLdp, bRsvpTe); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrMplsProtocolMask) { - BgpLinkAttrMplsProtocolMask other = (BgpLinkAttrMplsProtocolMask) obj; - return Objects.equals(bLdp, other.bLdp) - && Objects.equals(bRsvpTe, other.bRsvpTe); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("bLdp", bLdp).add("bRsvpTe", bRsvpTe).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java deleted file mode 100644 index 856ffc36..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Arrays; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP link name attribute. - */ -public class BgpLinkAttrName implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrName.class); - - public static final int ATTRLINK_NAME = 1098; - - /* Link Name */ - private byte[] linkName; - - /** - * Constructor to initialize the values. - * - * @param linkName link name - */ - public BgpLinkAttrName(byte[] linkName) { - this.linkName = Arrays.copyOf(linkName, linkName.length); - } - - /** - * Returns object of this class with specified values. - * - * @param linkName Prefix Metric - * @return object of BgpLinkAttrName - */ - public static BgpLinkAttrName of(byte[] linkName) { - return new BgpLinkAttrName(linkName); - } - - /** - * Reads the BGP link attributes Name. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrName - * @throws BgpParseException while parsing BgpLinkAttrName - */ - public static BgpLinkAttrName read(ChannelBuffer cb) - throws BgpParseException { - byte[] linkName; - short lsAttrLength = cb.readShort(); - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - linkName = new byte[lsAttrLength]; - cb.readBytes(linkName); - return BgpLinkAttrName.of(linkName); - } - - /** - * Returns the link name. - * - * @return link name - */ - public byte[] attrLinkName() { - return linkName; - } - - @Override - public short getType() { - return ATTRLINK_NAME; - } - - @Override - public int hashCode() { - return Arrays.hashCode(linkName); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrName) { - BgpLinkAttrName other = (BgpLinkAttrName) obj; - return Arrays.equals(linkName, other.linkName); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("linkName", linkName).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java deleted file mode 100644 index 275b85be..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrOpaqLnkAttrib.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Arrays; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP link opaque attribute. - */ -public final class BgpLinkAttrOpaqLnkAttrib implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrOpaqLnkAttrib.class); - - public static final int ATTRNODE_OPAQUELNKATTRIB = 1097; - - /* Opaque Node Attribute */ - private final byte[] opaqueLinkAttribute; - - /** - * Constructor to initialize the data. - * - * @param opaqueLinkAttribute opaque link attribute - */ - private BgpLinkAttrOpaqLnkAttrib(byte[] opaqueLinkAttribute) { - this.opaqueLinkAttribute = Arrays.copyOf(opaqueLinkAttribute, - opaqueLinkAttribute.length); - } - - /** - * Returns object of this class with specified values. - * - * @param opaqueLinkAttribute opaque link attribute - * @return object of BgpLinkAttrOpaqLnkAttrib - */ - public static BgpLinkAttrOpaqLnkAttrib of(final byte[] opaqueLinkAttribute) { - return new BgpLinkAttrOpaqLnkAttrib(opaqueLinkAttribute); - } - - /** - * Reads the BGP link attributes Opaque link attribute. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrOpaqLnkAttrib - * @throws BgpParseException while parsing BgpLinkAttrOpaqLnkAttrib - */ - public static BgpLinkAttrOpaqLnkAttrib read(ChannelBuffer cb) - throws BgpParseException { - - byte[] opaqueLinkAttribute; - - short lsAttrLength = cb.readShort(); - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - opaqueLinkAttribute = new byte[lsAttrLength]; - cb.readBytes(opaqueLinkAttribute); - - return BgpLinkAttrOpaqLnkAttrib.of(opaqueLinkAttribute); - } - - /** - * Returns the Opaque link attribute. - * - * @return byte array of opaque link attribute. - */ - public byte[] attrOpaqueLnk() { - return opaqueLinkAttribute; - } - - @Override - public short getType() { - return ATTRNODE_OPAQUELNKATTRIB; - } - - @Override - public int hashCode() { - return Arrays.hashCode(opaqueLinkAttribute); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrOpaqLnkAttrib) { - BgpLinkAttrOpaqLnkAttrib other = (BgpLinkAttrOpaqLnkAttrib) obj; - return Arrays - .equals(opaqueLinkAttribute, other.opaqueLinkAttribute); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("opaqueLinkAttribute", opaqueLinkAttribute).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java deleted file mode 100644 index 59011d97..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionType.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP link protection type attribute. - */ -public final class BgpLinkAttrProtectionType implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrProtectionType.class); - - public static final int ATTRLINK_PROTECTIONTYPE = 1093; - public static final int LINK_PROTECTION_LEN = 2; - - public static final int EXTRA_TRAFFIC = 0x01; - public static final int UNPROTECTED = 0x02; - public static final int SHARED = 0x04; - public static final int DEDICATED_ONE_ISTO_ONE = 0x08; - public static final int DEDICATED_ONE_PLUS_ONE = 0x10; - public static final int ENHANCED = 0x20; - - /* Link Protection type flags */ - private final boolean bExtraTraffic; - private final boolean bUnprotected; - private final boolean bShared; - private final boolean bDedOneIstoOne; - private final boolean bDedOnePlusOne; - private final boolean bEnhanced; - - /** - * Constructor to initialize the value. - * - * @param bExtraTraffic Extra Traffic - * @param bUnprotected Unprotected - * @param bShared Shared - * @param bDedOneIstoOne Dedicated 1:1 - * @param bDedOnePlusOne Dedicated 1+1 - * @param bEnhanced Enhanced - */ - private BgpLinkAttrProtectionType(boolean bExtraTraffic, - boolean bUnprotected, - boolean bShared, boolean bDedOneIstoOne, - boolean bDedOnePlusOne, boolean bEnhanced) { - this.bExtraTraffic = bExtraTraffic; - this.bUnprotected = bUnprotected; - this.bShared = bShared; - this.bDedOneIstoOne = bDedOneIstoOne; - this.bDedOnePlusOne = bDedOnePlusOne; - this.bEnhanced = bEnhanced; - } - - /** - * Returns object of this class with specified values. - * - * @param bExtraTraffic Extra Traffic - * @param bUnprotected Unprotected - * @param bShared Shared - * @param bDedOneIstoOne Dedicated 1:1 - * @param bDedOnePlusOne Dedicated 1+1 - * @param bEnhanced Enhanced - * @return object of BgpLinkAttrProtectionType - */ - public static BgpLinkAttrProtectionType of(boolean bExtraTraffic, - boolean bUnprotected, - boolean bShared, - boolean bDedOneIstoOne, - boolean bDedOnePlusOne, - boolean bEnhanced) { - return new BgpLinkAttrProtectionType(bExtraTraffic, bUnprotected, - bShared, bDedOneIstoOne, - bDedOnePlusOne, bEnhanced); - } - - /** - * Reads the BGP link attributes protection type. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrProtectionType - * @throws BgpParseException while parsing BgpLinkAttrProtectionType - */ - public static BgpLinkAttrProtectionType read(ChannelBuffer cb) - throws BgpParseException { - short linkProtectionType; - byte higherByte; - short lsAttrLength = cb.readShort(); - - boolean bExtraTraffic; - boolean bUnprotected; - boolean bShared; - boolean bDedOneIstoOne; - boolean bDedOnePlusOne; - boolean bEnhanced; - - if ((lsAttrLength != LINK_PROTECTION_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - linkProtectionType = cb.readShort(); - higherByte = (byte) (linkProtectionType >> 8); - - bExtraTraffic = ((higherByte & (byte) EXTRA_TRAFFIC) == EXTRA_TRAFFIC); - bUnprotected = ((higherByte & (byte) UNPROTECTED) == UNPROTECTED); - bShared = ((higherByte & (byte) SHARED) == SHARED); - bDedOneIstoOne = ((higherByte & (byte) DEDICATED_ONE_ISTO_ONE) == DEDICATED_ONE_ISTO_ONE); - bDedOnePlusOne = ((higherByte & (byte) DEDICATED_ONE_PLUS_ONE) == DEDICATED_ONE_PLUS_ONE); - bEnhanced = ((higherByte & (byte) ENHANCED) == ENHANCED); - - return BgpLinkAttrProtectionType.of(bExtraTraffic, bUnprotected, - bShared, bDedOneIstoOne, - bDedOnePlusOne, bEnhanced); - } - - /** - * Returns ExtraTraffic Bit. - * - * @return ExtraTraffic Bit - */ - public boolean extraTraffic() { - return bExtraTraffic; - } - - /** - * Returns Unprotected Bit. - * - * @return Unprotected Bit - */ - public boolean unprotected() { - return bUnprotected; - } - - /** - * Returns Shared Bit. - * - * @return Shared Bit - */ - public boolean shared() { - return bShared; - } - - /** - * Returns DedOneIstoOne Bit. - * - * @return DedOneIstoOne Bit - */ - public boolean dedOneIstoOne() { - return bDedOneIstoOne; - } - - /** - * Returns DedOnePlusOne Bit. - * - * @return DedOnePlusOne Bit - */ - public boolean dedOnePlusOne() { - return bDedOnePlusOne; - } - - /** - * Returns Enhanced Bit. - * - * @return Enhanced Bit - */ - public boolean enhanced() { - return bEnhanced; - } - - @Override - public short getType() { - return ATTRLINK_PROTECTIONTYPE; - } - - @Override - public int hashCode() { - return Objects.hash(bExtraTraffic, bUnprotected, bShared, - bDedOneIstoOne, bDedOnePlusOne, bEnhanced); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrProtectionType) { - BgpLinkAttrProtectionType other = (BgpLinkAttrProtectionType) obj; - return Objects.equals(bExtraTraffic, other.bExtraTraffic) - && Objects.equals(bUnprotected, other.bUnprotected) - && Objects.equals(bShared, other.bShared) - && Objects.equals(bDedOneIstoOne, other.bDedOneIstoOne) - && Objects.equals(bDedOnePlusOne, other.bDedOnePlusOne) - && Objects.equals(bEnhanced, other.bEnhanced); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("bExtraTraffic", bExtraTraffic) - .add("bUnprotected", bUnprotected).add("bShared", bShared) - .add("bDedOneIstoOne", bDedOneIstoOne) - .add("bDedOnePlusOne", bDedOnePlusOne) - .add("bEnhanced", bEnhanced).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java deleted file mode 100644 index 4a6f23f9..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrSrlg.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP link Shared Risk Link Group attribute. - */ -public class BgpLinkAttrSrlg implements BgpValueType { - - public static final short ATTRNODE_SRLG = 1097; - - /* Shared Risk Link Group */ - private List<Integer> sRlg = new ArrayList<Integer>(); - - /** - * Constructor to initialize the date. - * - * @param sRlg Shared Risk link group data - */ - public BgpLinkAttrSrlg(List<Integer> sRlg) { - this.sRlg = sRlg; - } - - /** - * Returns object of this class with specified values. - * - * @param sRlg Shared Risk link group data - * @return object of BgpLinkAttrSrlg - */ - public static BgpLinkAttrSrlg of(ArrayList<Integer> sRlg) { - return new BgpLinkAttrSrlg(sRlg); - } - - /** - * Reads the BGP link attributes Shared Risk link group data. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrSrlg - * @throws BgpParseException while parsing BgpLinkAttrSrlg - */ - public static BgpLinkAttrSrlg read(ChannelBuffer cb) - throws BgpParseException { - int tempSrlg; - ArrayList<Integer> sRlg = new ArrayList<Integer>(); - - short lsAttrLength = cb.readShort(); - int len = lsAttrLength / Integer.SIZE; // each element is of 4 octets - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - for (int i = 0; i < len; i++) { - tempSrlg = cb.readInt(); - sRlg.add(new Integer(tempSrlg)); - } - - return BgpLinkAttrSrlg.of(sRlg); - } - - /** - * Returns the Shared Risk link group data. - * - * @return array of Shared Risk link group data - */ - public List<Integer> attrSrlg() { - return sRlg; - } - - @Override - public short getType() { - return ATTRNODE_SRLG; - } - - @Override - public int hashCode() { - return Objects.hash(sRlg); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrSrlg) { - BgpLinkAttrSrlg other = (BgpLinkAttrSrlg) obj; - return Objects.equals(sRlg, other.sRlg); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues().add("sRlg", sRlg).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java deleted file mode 100644 index 1ae7ecc5..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrTeDefaultMetric.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP link state Default TE metric link attribute. - */ -public class BgpLinkAttrTeDefaultMetric implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrTeDefaultMetric.class); - - public static final int ATTRLINK_TEDEFAULTMETRIC = 1092; - public static final int TE_DATA_LEN = 4; - - /* TE Default Metric */ - private int linkTeMetric; - - /** - * Constructor to initialize the value. - * - * @param linkTeMetric TE default metric - * - */ - public BgpLinkAttrTeDefaultMetric(int linkTeMetric) { - this.linkTeMetric = linkTeMetric; - } - - /** - * Returns object of this class with specified values. - * - * @param linkTeMetric TE default metric - * @return object of BgpLinkAttrTeDefaultMetric - */ - public static BgpLinkAttrTeDefaultMetric of(final int linkTeMetric) { - return new BgpLinkAttrTeDefaultMetric(linkTeMetric); - } - - /** - * Reads the BGP link attributes of TE default metric. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrTeDefaultMetric - * @throws BgpParseException while parsing BgpLinkAttrTeDefaultMetric - */ - public static BgpLinkAttrTeDefaultMetric read(ChannelBuffer cb) - throws BgpParseException { - int linkTeMetric; - - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != TE_DATA_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - linkTeMetric = cb.readInt(); - - return new BgpLinkAttrTeDefaultMetric(linkTeMetric); - } - - /** - * Returns the TE default metrics. - * - * @return link default metric - */ - public int attrLinkDefTeMetric() { - return linkTeMetric; - } - - @Override - public short getType() { - return ATTRLINK_TEDEFAULTMETRIC; - } - - @Override - public int hashCode() { - return Objects.hash(linkTeMetric); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrTeDefaultMetric) { - BgpLinkAttrTeDefaultMetric other = (BgpLinkAttrTeDefaultMetric) obj; - return Objects.equals(linkTeMetric, other.linkTeMetric); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("linkTEMetric", linkTeMetric).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java deleted file mode 100644 index c927eea5..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrUnRsrvdLinkBandwidth.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP unreserved bandwidth attribute. - */ -public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpLinkAttrUnRsrvdLinkBandwidth.class); - - public static final int MAX_BANDWIDTH_LEN = 4; - public static final int NO_OF_BITS = 8; - public static final int NO_OF_PRIORITY = 8; - - public short sType; - - /* ISIS administrative group */ - private List<Float> maxUnResBandwidth = new ArrayList<Float>(); - - /** - * Constructor to initialize the values. - * - * @param maxUnResBandwidth Maximum Unreserved bandwidth - * @param sType returns the tag value - */ - public BgpLinkAttrUnRsrvdLinkBandwidth(List<Float> maxUnResBandwidth, - short sType) { - this.maxUnResBandwidth = maxUnResBandwidth; - this.sType = sType; - } - - /** - * Returns object of this class with specified values. - * - * @param linkPfxMetric Prefix Metric - * @param sType returns the tag value - * @return object of BgpLinkAttrUnRsrvdLinkBandwidth - */ - public static BgpLinkAttrUnRsrvdLinkBandwidth of(List<Float> linkPfxMetric, short sType) { - return new BgpLinkAttrUnRsrvdLinkBandwidth(linkPfxMetric, sType); - } - - /** - * Reads the BGP link attributes of Maximum link bandwidth. - * - * @param cb Channel buffer - * @return object of type BgpLinkAttrMaxLinkBandwidth - * @throws BgpParseException while parsing BgpLinkAttrMaxLinkBandwidth - */ - public static BgpLinkAttrUnRsrvdLinkBandwidth read(ChannelBuffer cb, - short sType) - throws BgpParseException { - ArrayList<Float> maxUnResBandwidth = new ArrayList<Float>(); - float tmp; - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != MAX_BANDWIDTH_LEN * NO_OF_PRIORITY) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - for (int i = 0; i < NO_OF_PRIORITY; i++) { - tmp = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS; - maxUnResBandwidth.add(new Float(tmp)); - } - - return BgpLinkAttrUnRsrvdLinkBandwidth.of(maxUnResBandwidth, sType); - } - - /** - * Returns maximum unreserved bandwidth. - * - * @return unreserved bandwidth. - */ - public List<Float> getLinkAttrUnRsrvdLinkBandwidth() { - return maxUnResBandwidth; - } - - /** - * Parse the IEEE floating point notation and returns it in normal float. - * - * @param iVal IEEE floating point number - * @return normal float - */ - static float ieeeToFloatRead(int iVal) { - iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8) - | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF)); - - return Float.intBitsToFloat(iVal); - } - - @Override - public short getType() { - return this.sType; - } - - @Override - public int hashCode() { - return Objects.hash(maxUnResBandwidth); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpLinkAttrUnRsrvdLinkBandwidth) { - BgpLinkAttrUnRsrvdLinkBandwidth other = (BgpLinkAttrUnRsrvdLinkBandwidth) obj; - return Objects.equals(maxUnResBandwidth, other.maxUnResBandwidth); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("maxUnResBandwidth", maxUnResBandwidth).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java deleted file mode 100644 index a2d7c57e..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrExtRouteTag.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix route Extended tag attribute. - */ -public class BgpPrefixAttrExtRouteTag implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrExtRouteTag.class); - - public static final int ATTR_PREFIX_EXTROUTETAG = 1154; - public static final int ATTR_PREFIX_EXT_LEN = 8; - - /* Prefix Route Tag */ - private List<Long> pfxExtRouteTag = new ArrayList<Long>(); - - /** - * Constructor to initialize the values. - * - * @param pfxExtRouteTag Extended route tag - */ - public BgpPrefixAttrExtRouteTag(List<Long> pfxExtRouteTag) { - this.pfxExtRouteTag = checkNotNull(pfxExtRouteTag); - } - - /** - * Returns object of this class with specified values. - * - * @param pfxExtRouteTag Prefix Metric - * @return object of BgpPrefixAttrMetric - */ - public static BgpPrefixAttrExtRouteTag of(ArrayList<Long> pfxExtRouteTag) { - return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag); - } - - /** - * Reads the Extended Tag. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrExtRouteTag - * @throws BgpParseException while parsing BgpPrefixAttrExtRouteTag - */ - public static BgpPrefixAttrExtRouteTag read(ChannelBuffer cb) - throws BgpParseException { - ArrayList<Long> pfxExtRouteTag = new ArrayList<Long>(); - long temp; - - short lsAttrLength = cb.readShort(); - int len = lsAttrLength / ATTR_PREFIX_EXT_LEN; - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - for (int i = 0; i < len; i++) { - temp = cb.readLong(); - pfxExtRouteTag.add(new Long(temp)); - } - - return new BgpPrefixAttrExtRouteTag(pfxExtRouteTag); - } - - /** - * Returns Extended route tag. - * - * @return route tag - */ - public List<Long> pfxExtRouteTag() { - return pfxExtRouteTag; - } - - @Override - public short getType() { - return ATTR_PREFIX_EXTROUTETAG; - } - - @Override - public int hashCode() { - return Objects.hash(pfxExtRouteTag); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrExtRouteTag) { - BgpPrefixAttrExtRouteTag other = (BgpPrefixAttrExtRouteTag) obj; - return Objects.equals(pfxExtRouteTag, other.pfxExtRouteTag); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("pfxExtRouteTag", pfxExtRouteTag).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java deleted file mode 100644 index 4e84191a..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix IGP Flag attribute. - */ -public final class BgpPrefixAttrIgpFlags implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrIgpFlags.class); - - public static final int ATTR_PREFIX_FLAGBIT = 1152; - public static final int ATTR_PREFIX_FLAG_LEN = 1; - - public static final byte FIRST_BIT = (byte) 0x80; - public static final byte SECOND_BIT = 0x40; - public static final byte THIRD_BIT = 0x20; - public static final byte FOURTH_BIT = 0x01; - - /* Prefix IGP flag bit TLV */ - private final boolean bisisUpDownBit; - private final boolean bOspfNoUnicastBit; - private final boolean bOspfLclAddrBit; - private final boolean bOspfNSSABit; - - /** - * Constructor to initialize the value. - * - * @param bisisUpDownBit IS-IS Up/Down Bit - * @param bOspfNoUnicastBit OSPF no unicast Bit - * @param bOspfLclAddrBit OSPF local address Bit - * @param bOspfNSSABit OSPF propagate NSSA Bit - */ - BgpPrefixAttrIgpFlags(boolean bisisUpDownBit, - boolean bOspfNoUnicastBit, - boolean bOspfLclAddrBit, boolean bOspfNSSABit) { - this.bisisUpDownBit = bisisUpDownBit; - this.bOspfNoUnicastBit = bOspfNoUnicastBit; - this.bOspfLclAddrBit = bOspfLclAddrBit; - this.bOspfNSSABit = bOspfNSSABit; - } - - /** - * Returns object of this class with specified values. - * - * @param bisisUpDownBit IS-IS Up/Down Bit - * @param bOspfNoUnicastBit OSPF no unicast Bit - * @param bOspfLclAddrBit OSPF local address Bit - * @param bOspfNSSABit OSPF propagate NSSA Bit - * @return object of BgpPrefixAttrIGPFlags - */ - public static BgpPrefixAttrIgpFlags of(final boolean bisisUpDownBit, - final boolean bOspfNoUnicastBit, - final boolean bOspfLclAddrBit, - final boolean bOspfNSSABit) { - return new BgpPrefixAttrIgpFlags(bisisUpDownBit, bOspfNoUnicastBit, - bOspfLclAddrBit, bOspfNSSABit); - } - - /** - * Reads the IGP Flags. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrIGPFlags - * @throws BgpParseException while parsing BgpPrefixAttrIGPFlags - */ - public static BgpPrefixAttrIgpFlags read(ChannelBuffer cb) - throws BgpParseException { - boolean bisisUpDownBit = false; - boolean bOspfNoUnicastBit = false; - boolean bOspfLclAddrBit = false; - boolean bOspfNSSABit = false; - - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - byte nodeFlagBits = cb.readByte(); - - bisisUpDownBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT); - bOspfNoUnicastBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT); - bOspfLclAddrBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT); - bOspfNSSABit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT); - - return BgpPrefixAttrIgpFlags.of(bisisUpDownBit, bOspfNoUnicastBit, - bOspfLclAddrBit, bOspfNSSABit); - } - - /** - * Returns the IS-IS Up/Down Bit set or not. - * - * @return IS-IS Up/Down Bit set or not - */ - public boolean isisUpDownBit() { - return bisisUpDownBit; - } - - /** - * Returns the OSPF no unicast Bit set or not. - * - * @return OSPF no unicast Bit set or not - */ - public boolean ospfNoUnicastBit() { - return bOspfNoUnicastBit; - } - - /** - * Returns the OSPF local address Bit set or not. - * - * @return OSPF local address Bit set or not - */ - public boolean ospfLclAddrBit() { - return bOspfLclAddrBit; - } - - /** - * Returns the OSPF propagate NSSA Bit set or not. - * - * @return OSPF propagate NSSA Bit set or not - */ - public boolean ospfNSSABit() { - return bOspfNSSABit; - } - - @Override - public short getType() { - return ATTR_PREFIX_FLAGBIT; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public int hashCode() { - return Objects.hash(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit, - bOspfNSSABit); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrIgpFlags) { - BgpPrefixAttrIgpFlags other = (BgpPrefixAttrIgpFlags) obj; - return Objects.equals(bisisUpDownBit, other.bisisUpDownBit) - && Objects.equals(bOspfNoUnicastBit, - other.bOspfNoUnicastBit) - && Objects.equals(bOspfLclAddrBit, other.bOspfLclAddrBit) - && Objects.equals(bOspfNSSABit, other.bOspfNSSABit); - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("bisisUpDownBit", bisisUpDownBit) - .add("bOspfNoUnicastBit", bOspfNoUnicastBit) - .add("bOspfLclAddrBit", bOspfLclAddrBit) - .add("bOspfNSSABit", bOspfNSSABit).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java deleted file mode 100644 index 1886102c..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetric.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix metric attribute. - */ -public class BgpPrefixAttrMetric implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrMetric.class); - - public static final int ATTR_PREFIX_METRIC = 1155; - public static final int ATTR_PREFIX_LEN = 4; - - /* TE Default Metric */ - private final int linkPfxMetric; - - /** - * Constructor to initialize value. - * - * @param linkPfxMetric Prefix Metric - */ - public BgpPrefixAttrMetric(int linkPfxMetric) { - this.linkPfxMetric = linkPfxMetric; - } - - /** - * Returns object of this class with specified values. - * - * @param linkPfxMetric Prefix Metric - * @return object of BgpPrefixAttrMetric - */ - public static BgpPrefixAttrMetric of(final int linkPfxMetric) { - return new BgpPrefixAttrMetric(linkPfxMetric); - } - - /** - * Reads the Prefix Metric. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrMetric - * @throws BgpParseException while parsing BgpPrefixAttrMetric - */ - public static BgpPrefixAttrMetric read(ChannelBuffer cb) - throws BgpParseException { - int linkPfxMetric; - - short lsAttrLength = cb.readShort(); // 4 Bytes - - if ((lsAttrLength != ATTR_PREFIX_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - linkPfxMetric = cb.readInt(); - - return BgpPrefixAttrMetric.of(linkPfxMetric); - } - - /** - * Returns the Prefix Metric. - * - * @return Prefix Metric - */ - public int attrPfxMetric() { - return linkPfxMetric; - } - - @Override - public short getType() { - return ATTR_PREFIX_METRIC; - } - - @Override - public int hashCode() { - return Objects.hash(linkPfxMetric); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrMetric) { - BgpPrefixAttrMetric other = (BgpPrefixAttrMetric) obj; - return Objects.equals(linkPfxMetric, other.linkPfxMetric); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("linkPfxMetric", linkPfxMetric).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java deleted file mode 100644 index 6f7a74bb..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOpaqueData.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Arrays; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix opaque data attribute. - */ -public final class BgpPrefixAttrOpaqueData implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrOpaqueData.class); - - public static final int ATTR_PREFIX_OPAQUEDATA = 1157; - - /* Opaque Node Attribute */ - private final byte[] opaquePrefixAttribute; - - /** - * Constructor to initialize the values. - * - * @param opaquePrefixAttribute opaque prefix data - */ - public BgpPrefixAttrOpaqueData(byte[] opaquePrefixAttribute) { - this.opaquePrefixAttribute = Arrays - .copyOf(opaquePrefixAttribute, opaquePrefixAttribute.length); - } - - /** - * Returns object of this class with specified values. - * - * @param opaquePrefixAttribute opaque prefix data - * @return object of BgpPrefixAttrOpaqueData - */ - public static BgpPrefixAttrOpaqueData of(final byte[] opaquePrefixAttribute) { - return new BgpPrefixAttrOpaqueData(opaquePrefixAttribute); - } - - /** - * Reads the Opaque Prefix Attribute. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrOpaqueData - * @throws BgpParseException while parsing BgpPrefixAttrOpaqueData - */ - public static BgpPrefixAttrOpaqueData read(ChannelBuffer cb) - throws BgpParseException { - byte[] opaquePrefixAttribute; - - short lsAttrLength = cb.readShort(); - opaquePrefixAttribute = new byte[lsAttrLength]; - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - cb.readBytes(opaquePrefixAttribute); - - return BgpPrefixAttrOpaqueData.of(opaquePrefixAttribute); - } - - /** - * Returns the Opaque prefix attribute name. - * - * @return opaque prefix name - */ - public byte[] getOpaquePrefixAttribute() { - return opaquePrefixAttribute; - } - - @Override - public short getType() { - return ATTR_PREFIX_OPAQUEDATA; - } - - @Override - public int hashCode() { - return Arrays.hashCode(opaquePrefixAttribute); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrOpaqueData) { - BgpPrefixAttrOpaqueData other = (BgpPrefixAttrOpaqueData) obj; - return Arrays.equals(opaquePrefixAttribute, - other.opaquePrefixAttribute); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("opaquePrefixAttribute", getOpaquePrefixAttribute()) - .toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java deleted file mode 100644 index 4e9db1ee..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddr.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip6Address; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix OSPF Forwarding address attribute. - */ -public class BgpPrefixAttrOspfFwdAddr implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrOspfFwdAddr.class); - - public static final int ATTR_PREFIX_OSPFFWDADDR = 1156; - public static final int IPV4_LEN = 4; - public static final int IPV6_LEN = 16; - - /* OSPF Forwarding Address */ - private final short lsAttrLength; - private final Ip4Address ip4RouterId; - private final Ip6Address ip6RouterId; - - /** - * Constructor to initialize the value. - * - * @param lsAttrLength length of the IP address - * @param ip4RouterId Valid IPV4 address if length is 4 else null - * @param ip6RouterId Valid IPV6 address if length is 16 else null - */ - public BgpPrefixAttrOspfFwdAddr(short lsAttrLength, Ip4Address ip4RouterId, - Ip6Address ip6RouterId) { - this.lsAttrLength = lsAttrLength; - this.ip4RouterId = ip4RouterId; - this.ip6RouterId = ip6RouterId; - } - - /** - * Returns object of this class with specified values. - * - * @param lsAttrLength length of the IP address - * @param ip4RouterId Valid IPV4 address if length is 4 else null - * @param ip6RouterId Valid IPV6 address if length is 16 else null - * @return object of BgpPrefixAttrOspfFwdAddr - */ - public static BgpPrefixAttrOspfFwdAddr of(final short lsAttrLength, - final Ip4Address ip4RouterId, - final Ip6Address ip6RouterId) { - return new BgpPrefixAttrOspfFwdAddr(lsAttrLength, ip4RouterId, - ip6RouterId); - } - - /** - * Reads the OSPF Forwarding Address. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrOSPFFwdAddr - * @throws BgpParseException while parsing BgpPrefixAttrOspfFwdAddr - */ - public static BgpPrefixAttrOspfFwdAddr read(ChannelBuffer cb) - throws BgpParseException { - short lsAttrLength; - byte[] ipBytes; - Ip4Address ip4RouterId = null; - Ip6Address ip6RouterId = null; - - lsAttrLength = cb.readShort(); - ipBytes = new byte[lsAttrLength]; - - if ((cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - cb.readBytes(ipBytes); - - if (IPV4_LEN == lsAttrLength) { - ip4RouterId = Ip4Address.valueOf(ipBytes); - } else if (IPV6_LEN == lsAttrLength) { - ip6RouterId = Ip6Address.valueOf(ipBytes); - } - - return BgpPrefixAttrOspfFwdAddr.of(lsAttrLength, ip4RouterId, - ip6RouterId); - } - - /** - * Returns IPV4 Address of OSPF forwarding address. - * - * @return IPV4 address - */ - public Ip4Address ospfv4FwdAddr() { - return ip4RouterId; - } - - /** - * Returns IPV6 Address of OSPF forwarding address. - * - * @return IPV6 address - */ - public Ip6Address ospfv6FwdAddr() { - return ip6RouterId; - } - - /** - * Returns OSPF forwarding address length. - * - * @return length of the ip address - */ - public short ospfFwdAddrLen() { - return lsAttrLength; - } - - @Override - public short getType() { - return ATTR_PREFIX_OSPFFWDADDR; - } - - @Override - public int hashCode() { - if (IPV4_LEN == lsAttrLength) { - return Objects.hash(ip4RouterId); - } else { - return Objects.hash(ip6RouterId); - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrOspfFwdAddr) { - BgpPrefixAttrOspfFwdAddr other = (BgpPrefixAttrOspfFwdAddr) obj; - if (IPV4_LEN == lsAttrLength) { - return Objects.equals(ip4RouterId, other.ip4RouterId); - } else { - return Objects.equals(ip6RouterId, other.ip6RouterId); - } - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - if (IPV4_LEN == lsAttrLength) { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("ip4RouterId", ip4RouterId).toString(); - } else { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("ip6RouterId", ip6RouterId).toString(); - } - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java deleted file mode 100644 index 3894c003..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrRouteTag.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.bgpio.types.attr; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BgpParseException; -import org.onosproject.bgpio.types.BgpErrorType; -import org.onosproject.bgpio.types.BgpValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix route tag attribute. - */ -public class BgpPrefixAttrRouteTag implements BgpValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrRouteTag.class); - - public static final short ATTR_PREFIX_ROUTETAG = 1153; - - /* Prefix Route Tag */ - private List<Integer> pfxRouteTag = new ArrayList<Integer>(); - - /** - * Constructor to initialize the values. - * - * @param pfxRouteTag prefix route tag - */ - public BgpPrefixAttrRouteTag(List<Integer> pfxRouteTag) { - this.pfxRouteTag = pfxRouteTag; - } - - /** - * Returns object of this class with specified values. - * - * @param pfxRouteTag Prefix Metric - * @return object of BgpPrefixAttrRouteTag - */ - public static BgpPrefixAttrRouteTag of(ArrayList<Integer> pfxRouteTag) { - return new BgpPrefixAttrRouteTag(pfxRouteTag); - } - - /** - * Reads the Route Tag. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrRouteTag - * @throws BgpParseException while parsing BgpPrefixAttrRouteTag - */ - public static BgpPrefixAttrRouteTag read(ChannelBuffer cb) - throws BgpParseException { - int tmp; - ArrayList<Integer> pfxRouteTag = new ArrayList<Integer>(); - - short lsAttrLength = cb.readShort(); - int len = lsAttrLength / Integer.SIZE; - - if (cb.readableBytes() < lsAttrLength) { - Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, - BgpErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - for (int i = 0; i < len; i++) { - tmp = cb.readInt(); - pfxRouteTag.add(new Integer(tmp)); - } - - return BgpPrefixAttrRouteTag.of(pfxRouteTag); - } - - /** - * Returns the prefix route tag. - * - * @return route tag - */ - public List<Integer> getPfxRouteTag() { - return pfxRouteTag; - } - - @Override - public short getType() { - return ATTR_PREFIX_ROUTETAG; - } - - @Override - public int hashCode() { - return Objects.hash(pfxRouteTag); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrRouteTag) { - BgpPrefixAttrRouteTag other = (BgpPrefixAttrRouteTag) obj; - return Objects.equals(pfxRouteTag, other.pfxRouteTag); - } - return false; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()).omitNullValues() - .add("pfxRouteTag", pfxRouteTag).toString(); - } - - @Override - public int compareTo(Object o) { - // TODO Auto-generated method stub - return 0; - } -} diff --git a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java b/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java deleted file mode 100755 index e2a74dbc..00000000 --- a/framework/src/onos/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -/** - * Implementation of BGP Link state attribute Tlvs. - */ -package org.onosproject.bgpio.types.attr; |