Shashikanth VH
Committed by Gerrit Code Review

[ONOS-3857] BGP sourceprefix packetlength protocol flow specification components.

Change-Id: I4a8a209c07db954bb7fb3dcbc236bc3a8018a4b4
/*
* Copyright 2016 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;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import java.util.List;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of BGP flow specification component.
*/
public class BgpFsIcmpCode implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_ICMP_CD;
private List<BgpFsOperatorValue> operatorValue;
/**
* Constructor to initialize the value.
*
* @param operatorValue list of operator and value
*/
public BgpFsIcmpCode(List<BgpFsOperatorValue> operatorValue) {
this.operatorValue = operatorValue;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(operatorValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsIcmpCode) {
BgpFsIcmpCode other = (BgpFsIcmpCode) obj;
return this.operatorValue.equals(other.operatorValue);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
for (BgpFsOperatorValue fsOperVal : operatorValue) {
cb.writeByte(fsOperVal.option());
cb.writeBytes(fsOperVal.value());
}
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec ICMP code
* @throws BgpParseException while parsing BgpFsIcmpCode
*/
public static BgpFsIcmpCode read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE)
.add("operatorValue", operatorValue).toString();
}
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
}
/*
* Copyright 2016 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;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import java.util.List;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of BGP flow specification component.
*/
public class BgpFsIcmpType implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_ICMP_TP;
private List<BgpFsOperatorValue> operatorValue;
/**
* Constructor to initialize the value.
*
* @param operatorValue list of operator and value
*/
public BgpFsIcmpType(List<BgpFsOperatorValue> operatorValue) {
this.operatorValue = operatorValue;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(operatorValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsIcmpType) {
BgpFsIcmpType other = (BgpFsIcmpType) obj;
return this.operatorValue.equals(other.operatorValue);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
for (BgpFsOperatorValue fsOperVal : operatorValue) {
cb.writeByte(fsOperVal.option());
cb.writeBytes(fsOperVal.value());
}
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec ICMP type
* @throws BgpParseException while parsing BgpFsIcmpType
*/
public static BgpFsIcmpType read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE)
.add("operatorValue", operatorValue).toString();
}
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
}
/*
* Copyright 2016 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;
import java.util.List;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of BGP flow specification component.
*/
public class BgpFsIpProtocol implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_IP_PROTO;
private List<BgpFsOperatorValue> operatorValue;
/**
* Constructor to initialize the value.
*
* @param operatorValue list of operator and value
*/
public BgpFsIpProtocol(List<BgpFsOperatorValue> operatorValue) {
this.operatorValue = operatorValue;
}
/**
* Returns flow type operator and value.
*
* @return flow type value
*/
public List<BgpFsOperatorValue> operatorValue() {
return operatorValue;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(operatorValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsIpProtocol) {
BgpFsIpProtocol other = (BgpFsIpProtocol) obj;
return Objects.equals(this.operatorValue, other.operatorValue);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
for (BgpFsOperatorValue fsOperVal : operatorValue) {
cb.writeByte(fsOperVal.option());
cb.writeBytes(fsOperVal.value());
}
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec IP protocol
* @throws BgpParseException while parsing BgpFsIpProtocol
*/
public static BgpFsIpProtocol read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE)
.add("operatorValue", operatorValue).toString();
}
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
}
/*
* Copyright 2016 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;
import java.util.Objects;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of BGP flow specification component.
*/
public class BgpFsPacketLength implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_PCK_LEN;
private List<BgpFsOperatorValue> operatorValue;
/**
* Constructor to initialize the value.
*
* @param operatorValue list of operator and value
*/
public BgpFsPacketLength(List<BgpFsOperatorValue> operatorValue) {
this.operatorValue = operatorValue;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(operatorValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsPacketLength) {
BgpFsPacketLength other = (BgpFsPacketLength) obj;
return this.operatorValue.equals(other.operatorValue);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
for (BgpFsOperatorValue fsOperVal : operatorValue) {
cb.writeByte(fsOperVal.option());
cb.writeBytes(fsOperVal.value());
}
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec packet length
* @throws BgpParseException while parsing BgpFsPacketLength
*/
public static BgpFsPacketLength read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE)
.add("operatorValue", operatorValue).toString();
}
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
}
/*
* Copyright 2016 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;
import java.util.Objects;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of BGP flow specification component.
*/
public class BgpFsSourcePortNum implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PORT;
private List<BgpFsOperatorValue> operatorValue;
/**
* Constructor to initialize the value.
*
* @param operatorValue list of operator and value
*/
public BgpFsSourcePortNum(List<BgpFsOperatorValue> operatorValue) {
this.operatorValue = operatorValue;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(operatorValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsSourcePortNum) {
BgpFsSourcePortNum other = (BgpFsSourcePortNum) obj;
return this.operatorValue.equals(other.operatorValue);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
for (BgpFsOperatorValue fsOperVal : operatorValue) {
cb.writeByte(fsOperVal.option());
cb.writeBytes(fsOperVal.value());
}
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec source port number
* @throws BgpParseException while parsing BgpFsSourcePortNum
*/
public static BgpFsSourcePortNum read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE)
.add("operatorValue", operatorValue).toString();
}
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
}
/*
* Copyright 2016 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;
import java.nio.ByteBuffer;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.IpPrefix;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
/**
* Provides implementation of IPv4AddressTlv.
*/
public class BgpFsSourcePrefix implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PREFIX;
private byte length;
private IpPrefix ipPrefix;
/**
* Constructor to initialize parameters.
*
* @param length length of the prefix
* @param ipPrefix ip prefix
*/
public BgpFsSourcePrefix(byte length, IpPrefix ipPrefix) {
this.ipPrefix = Preconditions.checkNotNull(ipPrefix);
this.length = length;
}
/**
* Returns ip prefix.
*
* @return ipPrefix ip prefix
*/
public IpPrefix ipPrefix() {
return ipPrefix;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(ipPrefix);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsSourcePrefix) {
BgpFsSourcePrefix other = (BgpFsSourcePrefix) obj;
return Objects.equals(this.ipPrefix, other.ipPrefix) && Objects.equals(this.length, other.length);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
cb.writeByte(length);
cb.writeInt(ipPrefix.getIp4Prefix().address().toInt());
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object of IPv4AddressTlv.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec source prefix
* @throws BgpParseException while parsing BgpFsSourcePrefix
*/
public static BgpFsSourcePrefix read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
/**
* Returns object of this class with specified values.
*
* @param ipPrefix ip prefix
* @param length length of ip prefix
* @return object of this class
*/
public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
return new BgpFsSourcePrefix(length, ipPrefix);
}
@Override
public int compareTo(Object o) {
if (this.equals(o)) {
return 0;
}
if (o instanceof BgpFsSourcePrefix) {
BgpFsSourcePrefix that = (BgpFsSourcePrefix) o;
if (this.ipPrefix().prefixLength() == that.ipPrefix().prefixLength()) {
ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix.address().toOctets());
ByteBuffer value2 = ByteBuffer.wrap(that.ipPrefix.address().toOctets());
return value1.compareTo(value2);
}
if (this.ipPrefix().prefixLength() > that.ipPrefix().prefixLength()) {
return 1;
} else if (this.ipPrefix().prefixLength() < that.ipPrefix().prefixLength()) {
return -1;
}
}
return 1;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE).add("length", length)
.add("ipPrefix", ipPrefix).toString();
}
}
/*
* Copyright 2016 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;
import java.util.Objects;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import com.google.common.base.MoreObjects;
/**
* Provides implementation of BGP flow specification component.
*/
public class BgpFsTcpFlags implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_TCP_FLAGS;
private List<BgpFsOperatorValue> operatorValue;
/**
* Constructor to initialize the value.
*
* @param operatorValue list of operator and value
*/
public BgpFsTcpFlags(List<BgpFsOperatorValue> operatorValue) {
this.operatorValue = operatorValue;
}
@Override
public short getType() {
return this.FLOW_SPEC_TYPE;
}
@Override
public int hashCode() {
return Objects.hash(operatorValue);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpFsTcpFlags) {
BgpFsTcpFlags other = (BgpFsTcpFlags) obj;
return this.operatorValue.equals(other.operatorValue);
}
return false;
}
@Override
public int write(ChannelBuffer cb) {
int iLenStartIndex = cb.writerIndex();
cb.writeByte(FLOW_SPEC_TYPE);
for (BgpFsOperatorValue fsOperVal : operatorValue) {
cb.writeByte(fsOperVal.option());
cb.writeBytes(fsOperVal.value());
}
return cb.writerIndex() - iLenStartIndex;
}
/**
* Reads the channel buffer and returns object.
*
* @param cb channelBuffer
* @param type address type
* @return object of flow spec TCP flags
* @throws BgpParseException while parsing BgpFsTcpFlags
*/
public static BgpFsTcpFlags read(ChannelBuffer cb, short type) throws BgpParseException {
return null;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE)
.add("operatorValue", operatorValue).toString();
}
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
}
/*
* Copyright 2016 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;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for ICMP code flow specification component.
*/
public class BgpFsIcmpCodeTest {
List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>();
@Test
public void testEquality() {
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
BgpFsIcmpCode tlv1 = new BgpFsIcmpCode(operatorValue1);
BgpFsIcmpCode sameAsTlv1 = new BgpFsIcmpCode(operatorValue1);
BgpFsIcmpCode tlv2 = new BgpFsIcmpCode(operatorValue2);
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}
/*
* Copyright 2016 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;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for ICMP type flow specification component.
*/
public class BgpFsIcmpTypeTest {
List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>();
@Test
public void testEquality() {
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
BgpFsIcmpType tlv1 = new BgpFsIcmpType(operatorValue1);
BgpFsIcmpType sameAsTlv1 = new BgpFsIcmpType(operatorValue1);
BgpFsIcmpType tlv2 = new BgpFsIcmpType(operatorValue2);
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}
/*
* Copyright 2016 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;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for IP protocol flow specification component.
*/
public class BgpFsIpProtocolTest {
List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>();
@Test
public void testEquality() {
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
BgpFsIpProtocol tlv1 = new BgpFsIpProtocol(operatorValue1);
BgpFsIpProtocol sameAsTlv1 = new BgpFsIpProtocol(operatorValue1);
BgpFsIpProtocol tlv2 = new BgpFsIpProtocol(operatorValue2);
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}
/*
* Copyright 2016 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;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for packet length flow specification component.
*/
public class BgpFsPacketLengthTest {
List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>();
@Test
public void testEquality() {
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
BgpFsPacketLength tlv1 = new BgpFsPacketLength(operatorValue1);
BgpFsPacketLength sameAsTlv1 = new BgpFsPacketLength(operatorValue1);
BgpFsPacketLength tlv2 = new BgpFsPacketLength(operatorValue2);
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}
/*
* Copyright 2016 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;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for source port number flow specification component.
*/
public class BgpFsSourcePortNumTest {
List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>();
@Test
public void testEquality() {
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
BgpFsSourcePortNum tlv1 = new BgpFsSourcePortNum(operatorValue1);
BgpFsSourcePortNum sameAsTlv1 = new BgpFsSourcePortNum(operatorValue1);
BgpFsSourcePortNum tlv2 = new BgpFsSourcePortNum(operatorValue2);
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}
/*
* Copyright 2016 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;
import org.junit.Test;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import com.google.common.testing.EqualsTester;
/**
* Test for source prefix flow specification component.
*/
public class BgpFsSourcePrefixTest {
private final byte length = 4;
private final IpPrefix prefix = IpPrefix.valueOf(IpAddress.valueOf("10.0.1.1"), 32);
private final byte length2 = 4;
private final IpPrefix prefix2 = IpPrefix.valueOf(IpAddress.valueOf("10.0.1.2"), 32);
private final BgpFsSourcePrefix tlv1 = new BgpFsSourcePrefix(length, prefix);
private final BgpFsSourcePrefix sameAsTlv1 = new BgpFsSourcePrefix(length, prefix);
private final BgpFsSourcePrefix tlv2 = new BgpFsSourcePrefix(length2, prefix2);
@Test
public void testEquality() {
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}
/*
* Copyright 2016 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;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for TCP flags flow specification component.
*/
public class BgpFsTcpFlagsTest {
List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>();
@Test
public void testEquality() {
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100]));
operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100]));
BgpFsTcpFlags tlv1 = new BgpFsTcpFlags(operatorValue1);
BgpFsTcpFlags sameAsTlv1 = new BgpFsTcpFlags(operatorValue1);
BgpFsTcpFlags tlv2 = new BgpFsTcpFlags(operatorValue2);
new EqualsTester()
.addEqualityGroup(tlv1, sameAsTlv1)
.addEqualityGroup(tlv2)
.testEquals();
}
}