Committed by
Gerrit Code Review
[ONOS-3857] BGP sourceprefix packetlength protocol flow specification components.
Change-Id: I4a8a209c07db954bb7fb3dcbc236bc3a8018a4b4
Showing
14 changed files
with
1095 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
22 | +import org.onosproject.bgpio.util.Constants; | ||
23 | +import java.util.List; | ||
24 | +import com.google.common.base.MoreObjects; | ||
25 | + | ||
26 | +/** | ||
27 | + * Provides implementation of BGP flow specification component. | ||
28 | + */ | ||
29 | +public class BgpFsIcmpCode implements BgpValueType { | ||
30 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_ICMP_CD; | ||
31 | + private List<BgpFsOperatorValue> operatorValue; | ||
32 | + | ||
33 | + /** | ||
34 | + * Constructor to initialize the value. | ||
35 | + * | ||
36 | + * @param operatorValue list of operator and value | ||
37 | + */ | ||
38 | + public BgpFsIcmpCode(List<BgpFsOperatorValue> operatorValue) { | ||
39 | + this.operatorValue = operatorValue; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public short getType() { | ||
44 | + return this.FLOW_SPEC_TYPE; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public int hashCode() { | ||
49 | + return Objects.hash(operatorValue); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public boolean equals(Object obj) { | ||
54 | + if (this == obj) { | ||
55 | + return true; | ||
56 | + } | ||
57 | + if (obj instanceof BgpFsIcmpCode) { | ||
58 | + BgpFsIcmpCode other = (BgpFsIcmpCode) obj; | ||
59 | + return this.operatorValue.equals(other.operatorValue); | ||
60 | + } | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public int write(ChannelBuffer cb) { | ||
66 | + int iLenStartIndex = cb.writerIndex(); | ||
67 | + | ||
68 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
69 | + | ||
70 | + for (BgpFsOperatorValue fsOperVal : operatorValue) { | ||
71 | + cb.writeByte(fsOperVal.option()); | ||
72 | + cb.writeBytes(fsOperVal.value()); | ||
73 | + } | ||
74 | + | ||
75 | + return cb.writerIndex() - iLenStartIndex; | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Reads the channel buffer and returns object. | ||
80 | + * | ||
81 | + * @param cb channelBuffer | ||
82 | + * @param type address type | ||
83 | + * @return object of flow spec ICMP code | ||
84 | + * @throws BgpParseException while parsing BgpFsIcmpCode | ||
85 | + */ | ||
86 | + public static BgpFsIcmpCode read(ChannelBuffer cb, short type) throws BgpParseException { | ||
87 | + return null; | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public String toString() { | ||
92 | + return MoreObjects.toStringHelper(getClass()) | ||
93 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE) | ||
94 | + .add("operatorValue", operatorValue).toString(); | ||
95 | + } | ||
96 | + | ||
97 | + @Override | ||
98 | + public int compareTo(Object o) { | ||
99 | + // TODO Auto-generated method stub | ||
100 | + return 0; | ||
101 | + } | ||
102 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
22 | +import org.onosproject.bgpio.util.Constants; | ||
23 | +import java.util.List; | ||
24 | +import com.google.common.base.MoreObjects; | ||
25 | + | ||
26 | +/** | ||
27 | + * Provides implementation of BGP flow specification component. | ||
28 | + */ | ||
29 | +public class BgpFsIcmpType implements BgpValueType { | ||
30 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_ICMP_TP; | ||
31 | + private List<BgpFsOperatorValue> operatorValue; | ||
32 | + | ||
33 | + /** | ||
34 | + * Constructor to initialize the value. | ||
35 | + * | ||
36 | + * @param operatorValue list of operator and value | ||
37 | + */ | ||
38 | + public BgpFsIcmpType(List<BgpFsOperatorValue> operatorValue) { | ||
39 | + this.operatorValue = operatorValue; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public short getType() { | ||
44 | + return this.FLOW_SPEC_TYPE; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public int hashCode() { | ||
49 | + return Objects.hash(operatorValue); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public boolean equals(Object obj) { | ||
54 | + if (this == obj) { | ||
55 | + return true; | ||
56 | + } | ||
57 | + if (obj instanceof BgpFsIcmpType) { | ||
58 | + BgpFsIcmpType other = (BgpFsIcmpType) obj; | ||
59 | + return this.operatorValue.equals(other.operatorValue); | ||
60 | + } | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public int write(ChannelBuffer cb) { | ||
66 | + int iLenStartIndex = cb.writerIndex(); | ||
67 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
68 | + | ||
69 | + for (BgpFsOperatorValue fsOperVal : operatorValue) { | ||
70 | + cb.writeByte(fsOperVal.option()); | ||
71 | + cb.writeBytes(fsOperVal.value()); | ||
72 | + } | ||
73 | + | ||
74 | + return cb.writerIndex() - iLenStartIndex; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Reads the channel buffer and returns object. | ||
79 | + * | ||
80 | + * @param cb channelBuffer | ||
81 | + * @param type address type | ||
82 | + * @return object of flow spec ICMP type | ||
83 | + * @throws BgpParseException while parsing BgpFsIcmpType | ||
84 | + */ | ||
85 | + public static BgpFsIcmpType read(ChannelBuffer cb, short type) throws BgpParseException { | ||
86 | + return null; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public String toString() { | ||
91 | + return MoreObjects.toStringHelper(getClass()) | ||
92 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE) | ||
93 | + .add("operatorValue", operatorValue).toString(); | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public int compareTo(Object o) { | ||
98 | + // TODO Auto-generated method stub | ||
99 | + return 0; | ||
100 | + } | ||
101 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.List; | ||
19 | +import java.util.Objects; | ||
20 | + | ||
21 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
22 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
23 | +import org.onosproject.bgpio.util.Constants; | ||
24 | + | ||
25 | +import com.google.common.base.MoreObjects; | ||
26 | + | ||
27 | +/** | ||
28 | + * Provides implementation of BGP flow specification component. | ||
29 | + */ | ||
30 | +public class BgpFsIpProtocol implements BgpValueType { | ||
31 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_IP_PROTO; | ||
32 | + private List<BgpFsOperatorValue> operatorValue; | ||
33 | + | ||
34 | + /** | ||
35 | + * Constructor to initialize the value. | ||
36 | + * | ||
37 | + * @param operatorValue list of operator and value | ||
38 | + */ | ||
39 | + public BgpFsIpProtocol(List<BgpFsOperatorValue> operatorValue) { | ||
40 | + this.operatorValue = operatorValue; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Returns flow type operator and value. | ||
45 | + * | ||
46 | + * @return flow type value | ||
47 | + */ | ||
48 | + public List<BgpFsOperatorValue> operatorValue() { | ||
49 | + return operatorValue; | ||
50 | + } | ||
51 | + | ||
52 | + | ||
53 | + @Override | ||
54 | + public short getType() { | ||
55 | + return this.FLOW_SPEC_TYPE; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(operatorValue); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof BgpFsIpProtocol) { | ||
69 | + BgpFsIpProtocol other = (BgpFsIpProtocol) obj; | ||
70 | + return Objects.equals(this.operatorValue, other.operatorValue); | ||
71 | + } | ||
72 | + return false; | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public int write(ChannelBuffer cb) { | ||
77 | + int iLenStartIndex = cb.writerIndex(); | ||
78 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
79 | + | ||
80 | + for (BgpFsOperatorValue fsOperVal : operatorValue) { | ||
81 | + cb.writeByte(fsOperVal.option()); | ||
82 | + cb.writeBytes(fsOperVal.value()); | ||
83 | + } | ||
84 | + | ||
85 | + return cb.writerIndex() - iLenStartIndex; | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Reads the channel buffer and returns object. | ||
90 | + * | ||
91 | + * @param cb channelBuffer | ||
92 | + * @param type address type | ||
93 | + * @return object of flow spec IP protocol | ||
94 | + * @throws BgpParseException while parsing BgpFsIpProtocol | ||
95 | + */ | ||
96 | + public static BgpFsIpProtocol read(ChannelBuffer cb, short type) throws BgpParseException { | ||
97 | + return null; | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public String toString() { | ||
102 | + return MoreObjects.toStringHelper(getClass()) | ||
103 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE) | ||
104 | + .add("operatorValue", operatorValue).toString(); | ||
105 | + } | ||
106 | + | ||
107 | + @Override | ||
108 | + public int compareTo(Object o) { | ||
109 | + // TODO Auto-generated method stub | ||
110 | + return 0; | ||
111 | + } | ||
112 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | +import java.util.List; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
22 | +import org.onosproject.bgpio.util.Constants; | ||
23 | +import com.google.common.base.MoreObjects; | ||
24 | + | ||
25 | +/** | ||
26 | + * Provides implementation of BGP flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsPacketLength implements BgpValueType { | ||
29 | + | ||
30 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_PCK_LEN; | ||
31 | + private List<BgpFsOperatorValue> operatorValue; | ||
32 | + | ||
33 | + /** | ||
34 | + * Constructor to initialize the value. | ||
35 | + * | ||
36 | + * @param operatorValue list of operator and value | ||
37 | + */ | ||
38 | + public BgpFsPacketLength(List<BgpFsOperatorValue> operatorValue) { | ||
39 | + this.operatorValue = operatorValue; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public short getType() { | ||
44 | + return this.FLOW_SPEC_TYPE; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public int hashCode() { | ||
49 | + return Objects.hash(operatorValue); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public boolean equals(Object obj) { | ||
54 | + if (this == obj) { | ||
55 | + return true; | ||
56 | + } | ||
57 | + if (obj instanceof BgpFsPacketLength) { | ||
58 | + BgpFsPacketLength other = (BgpFsPacketLength) obj; | ||
59 | + return this.operatorValue.equals(other.operatorValue); | ||
60 | + } | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public int write(ChannelBuffer cb) { | ||
66 | + int iLenStartIndex = cb.writerIndex(); | ||
67 | + | ||
68 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
69 | + | ||
70 | + for (BgpFsOperatorValue fsOperVal : operatorValue) { | ||
71 | + cb.writeByte(fsOperVal.option()); | ||
72 | + cb.writeBytes(fsOperVal.value()); | ||
73 | + } | ||
74 | + | ||
75 | + return cb.writerIndex() - iLenStartIndex; | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Reads the channel buffer and returns object. | ||
80 | + * | ||
81 | + * @param cb channelBuffer | ||
82 | + * @param type address type | ||
83 | + * @return object of flow spec packet length | ||
84 | + * @throws BgpParseException while parsing BgpFsPacketLength | ||
85 | + */ | ||
86 | + public static BgpFsPacketLength read(ChannelBuffer cb, short type) throws BgpParseException { | ||
87 | + return null; | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public String toString() { | ||
92 | + return MoreObjects.toStringHelper(getClass()) | ||
93 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE) | ||
94 | + .add("operatorValue", operatorValue).toString(); | ||
95 | + } | ||
96 | + | ||
97 | + @Override | ||
98 | + public int compareTo(Object o) { | ||
99 | + // TODO Auto-generated method stub | ||
100 | + return 0; | ||
101 | + } | ||
102 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | +import java.util.List; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
22 | +import org.onosproject.bgpio.util.Constants; | ||
23 | +import com.google.common.base.MoreObjects; | ||
24 | + | ||
25 | +/** | ||
26 | + * Provides implementation of BGP flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsSourcePortNum implements BgpValueType { | ||
29 | + | ||
30 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PORT; | ||
31 | + private List<BgpFsOperatorValue> operatorValue; | ||
32 | + | ||
33 | + /** | ||
34 | + * Constructor to initialize the value. | ||
35 | + * | ||
36 | + * @param operatorValue list of operator and value | ||
37 | + */ | ||
38 | + public BgpFsSourcePortNum(List<BgpFsOperatorValue> operatorValue) { | ||
39 | + this.operatorValue = operatorValue; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public short getType() { | ||
44 | + return this.FLOW_SPEC_TYPE; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public int hashCode() { | ||
49 | + return Objects.hash(operatorValue); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public boolean equals(Object obj) { | ||
54 | + if (this == obj) { | ||
55 | + return true; | ||
56 | + } | ||
57 | + if (obj instanceof BgpFsSourcePortNum) { | ||
58 | + BgpFsSourcePortNum other = (BgpFsSourcePortNum) obj; | ||
59 | + return this.operatorValue.equals(other.operatorValue); | ||
60 | + } | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public int write(ChannelBuffer cb) { | ||
66 | + int iLenStartIndex = cb.writerIndex(); | ||
67 | + | ||
68 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
69 | + | ||
70 | + for (BgpFsOperatorValue fsOperVal : operatorValue) { | ||
71 | + cb.writeByte(fsOperVal.option()); | ||
72 | + cb.writeBytes(fsOperVal.value()); | ||
73 | + } | ||
74 | + | ||
75 | + return cb.writerIndex() - iLenStartIndex; | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Reads the channel buffer and returns object. | ||
80 | + * | ||
81 | + * @param cb channelBuffer | ||
82 | + * @param type address type | ||
83 | + * @return object of flow spec source port number | ||
84 | + * @throws BgpParseException while parsing BgpFsSourcePortNum | ||
85 | + */ | ||
86 | + public static BgpFsSourcePortNum read(ChannelBuffer cb, short type) throws BgpParseException { | ||
87 | + return null; | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public String toString() { | ||
92 | + return MoreObjects.toStringHelper(getClass()) | ||
93 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE) | ||
94 | + .add("operatorValue", operatorValue).toString(); | ||
95 | + } | ||
96 | + | ||
97 | + @Override | ||
98 | + public int compareTo(Object o) { | ||
99 | + // TODO Auto-generated method stub | ||
100 | + return 0; | ||
101 | + } | ||
102 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.nio.ByteBuffer; | ||
19 | +import java.util.Objects; | ||
20 | + | ||
21 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
22 | +import org.onlab.packet.IpPrefix; | ||
23 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
24 | +import org.onosproject.bgpio.util.Constants; | ||
25 | + | ||
26 | +import com.google.common.base.MoreObjects; | ||
27 | +import com.google.common.base.Preconditions; | ||
28 | + | ||
29 | +/** | ||
30 | + * Provides implementation of IPv4AddressTlv. | ||
31 | + */ | ||
32 | +public class BgpFsSourcePrefix implements BgpValueType { | ||
33 | + | ||
34 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PREFIX; | ||
35 | + private byte length; | ||
36 | + private IpPrefix ipPrefix; | ||
37 | + | ||
38 | + /** | ||
39 | + * Constructor to initialize parameters. | ||
40 | + * | ||
41 | + * @param length length of the prefix | ||
42 | + * @param ipPrefix ip prefix | ||
43 | + */ | ||
44 | + public BgpFsSourcePrefix(byte length, IpPrefix ipPrefix) { | ||
45 | + this.ipPrefix = Preconditions.checkNotNull(ipPrefix); | ||
46 | + this.length = length; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Returns ip prefix. | ||
51 | + * | ||
52 | + * @return ipPrefix ip prefix | ||
53 | + */ | ||
54 | + public IpPrefix ipPrefix() { | ||
55 | + return ipPrefix; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public short getType() { | ||
60 | + return this.FLOW_SPEC_TYPE; | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(ipPrefix); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof BgpFsSourcePrefix) { | ||
74 | + BgpFsSourcePrefix other = (BgpFsSourcePrefix) obj; | ||
75 | + return Objects.equals(this.ipPrefix, other.ipPrefix) && Objects.equals(this.length, other.length); | ||
76 | + } | ||
77 | + return false; | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public int write(ChannelBuffer cb) { | ||
82 | + int iLenStartIndex = cb.writerIndex(); | ||
83 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
84 | + cb.writeByte(length); | ||
85 | + cb.writeInt(ipPrefix.getIp4Prefix().address().toInt()); | ||
86 | + return cb.writerIndex() - iLenStartIndex; | ||
87 | + } | ||
88 | + | ||
89 | + /** | ||
90 | + * Reads the channel buffer and returns object of IPv4AddressTlv. | ||
91 | + * | ||
92 | + * @param cb channelBuffer | ||
93 | + * @param type address type | ||
94 | + * @return object of flow spec source prefix | ||
95 | + * @throws BgpParseException while parsing BgpFsSourcePrefix | ||
96 | + */ | ||
97 | + public static BgpFsSourcePrefix read(ChannelBuffer cb, short type) throws BgpParseException { | ||
98 | + return null; | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Returns object of this class with specified values. | ||
103 | + * | ||
104 | + * @param ipPrefix ip prefix | ||
105 | + * @param length length of ip prefix | ||
106 | + * @return object of this class | ||
107 | + */ | ||
108 | + public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) { | ||
109 | + return new BgpFsSourcePrefix(length, ipPrefix); | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public int compareTo(Object o) { | ||
114 | + if (this.equals(o)) { | ||
115 | + return 0; | ||
116 | + } | ||
117 | + | ||
118 | + if (o instanceof BgpFsSourcePrefix) { | ||
119 | + BgpFsSourcePrefix that = (BgpFsSourcePrefix) o; | ||
120 | + | ||
121 | + if (this.ipPrefix().prefixLength() == that.ipPrefix().prefixLength()) { | ||
122 | + ByteBuffer value1 = ByteBuffer.wrap(this.ipPrefix.address().toOctets()); | ||
123 | + ByteBuffer value2 = ByteBuffer.wrap(that.ipPrefix.address().toOctets()); | ||
124 | + return value1.compareTo(value2); | ||
125 | + } | ||
126 | + | ||
127 | + if (this.ipPrefix().prefixLength() > that.ipPrefix().prefixLength()) { | ||
128 | + return 1; | ||
129 | + } else if (this.ipPrefix().prefixLength() < that.ipPrefix().prefixLength()) { | ||
130 | + return -1; | ||
131 | + } | ||
132 | + } | ||
133 | + return 1; | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public String toString() { | ||
138 | + return MoreObjects.toStringHelper(getClass()) | ||
139 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE).add("length", length) | ||
140 | + .add("ipPrefix", ipPrefix).toString(); | ||
141 | + } | ||
142 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | +import java.util.List; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onosproject.bgpio.exceptions.BgpParseException; | ||
22 | +import org.onosproject.bgpio.util.Constants; | ||
23 | +import com.google.common.base.MoreObjects; | ||
24 | + | ||
25 | +/** | ||
26 | + * Provides implementation of BGP flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsTcpFlags implements BgpValueType { | ||
29 | + | ||
30 | + public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_TCP_FLAGS; | ||
31 | + private List<BgpFsOperatorValue> operatorValue; | ||
32 | + | ||
33 | + /** | ||
34 | + * Constructor to initialize the value. | ||
35 | + * | ||
36 | + * @param operatorValue list of operator and value | ||
37 | + */ | ||
38 | + public BgpFsTcpFlags(List<BgpFsOperatorValue> operatorValue) { | ||
39 | + this.operatorValue = operatorValue; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public short getType() { | ||
44 | + return this.FLOW_SPEC_TYPE; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public int hashCode() { | ||
49 | + return Objects.hash(operatorValue); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public boolean equals(Object obj) { | ||
54 | + if (this == obj) { | ||
55 | + return true; | ||
56 | + } | ||
57 | + if (obj instanceof BgpFsTcpFlags) { | ||
58 | + BgpFsTcpFlags other = (BgpFsTcpFlags) obj; | ||
59 | + return this.operatorValue.equals(other.operatorValue); | ||
60 | + } | ||
61 | + return false; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public int write(ChannelBuffer cb) { | ||
66 | + int iLenStartIndex = cb.writerIndex(); | ||
67 | + cb.writeByte(FLOW_SPEC_TYPE); | ||
68 | + | ||
69 | + for (BgpFsOperatorValue fsOperVal : operatorValue) { | ||
70 | + cb.writeByte(fsOperVal.option()); | ||
71 | + cb.writeBytes(fsOperVal.value()); | ||
72 | + } | ||
73 | + | ||
74 | + return cb.writerIndex() - iLenStartIndex; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Reads the channel buffer and returns object. | ||
79 | + * | ||
80 | + * @param cb channelBuffer | ||
81 | + * @param type address type | ||
82 | + * @return object of flow spec TCP flags | ||
83 | + * @throws BgpParseException while parsing BgpFsTcpFlags | ||
84 | + */ | ||
85 | + public static BgpFsTcpFlags read(ChannelBuffer cb, short type) throws BgpParseException { | ||
86 | + return null; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public String toString() { | ||
91 | + return MoreObjects.toStringHelper(getClass()) | ||
92 | + .add("FLOW_SPEC_TYPE", FLOW_SPEC_TYPE) | ||
93 | + .add("operatorValue", operatorValue).toString(); | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public int compareTo(Object o) { | ||
98 | + // TODO Auto-generated method stub | ||
99 | + return 0; | ||
100 | + } | ||
101 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import com.google.common.testing.EqualsTester; | ||
24 | + | ||
25 | +/** | ||
26 | + * Test for ICMP code flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsIcmpCodeTest { | ||
29 | + List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>(); | ||
30 | + List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>(); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void testEquality() { | ||
34 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
35 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
36 | + operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100])); | ||
37 | + operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
38 | + | ||
39 | + BgpFsIcmpCode tlv1 = new BgpFsIcmpCode(operatorValue1); | ||
40 | + BgpFsIcmpCode sameAsTlv1 = new BgpFsIcmpCode(operatorValue1); | ||
41 | + BgpFsIcmpCode tlv2 = new BgpFsIcmpCode(operatorValue2); | ||
42 | + | ||
43 | + new EqualsTester() | ||
44 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
45 | + .addEqualityGroup(tlv2) | ||
46 | + .testEquals(); | ||
47 | + } | ||
48 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import com.google.common.testing.EqualsTester; | ||
24 | + | ||
25 | +/** | ||
26 | + * Test for ICMP type flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsIcmpTypeTest { | ||
29 | + List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>(); | ||
30 | + List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>(); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void testEquality() { | ||
34 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
35 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
36 | + operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100])); | ||
37 | + operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
38 | + | ||
39 | + BgpFsIcmpType tlv1 = new BgpFsIcmpType(operatorValue1); | ||
40 | + BgpFsIcmpType sameAsTlv1 = new BgpFsIcmpType(operatorValue1); | ||
41 | + BgpFsIcmpType tlv2 = new BgpFsIcmpType(operatorValue2); | ||
42 | + | ||
43 | + new EqualsTester() | ||
44 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
45 | + .addEqualityGroup(tlv2) | ||
46 | + .testEquals(); | ||
47 | + } | ||
48 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import com.google.common.testing.EqualsTester; | ||
24 | + | ||
25 | +/** | ||
26 | + * Test for IP protocol flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsIpProtocolTest { | ||
29 | + List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>(); | ||
30 | + List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>(); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void testEquality() { | ||
34 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
35 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
36 | + operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100])); | ||
37 | + operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
38 | + | ||
39 | + BgpFsIpProtocol tlv1 = new BgpFsIpProtocol(operatorValue1); | ||
40 | + BgpFsIpProtocol sameAsTlv1 = new BgpFsIpProtocol(operatorValue1); | ||
41 | + BgpFsIpProtocol tlv2 = new BgpFsIpProtocol(operatorValue2); | ||
42 | + | ||
43 | + new EqualsTester() | ||
44 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
45 | + .addEqualityGroup(tlv2) | ||
46 | + .testEquals(); | ||
47 | + } | ||
48 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import com.google.common.testing.EqualsTester; | ||
24 | + | ||
25 | +/** | ||
26 | + * Test for packet length flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsPacketLengthTest { | ||
29 | + List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>(); | ||
30 | + List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>(); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void testEquality() { | ||
34 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
35 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
36 | + operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100])); | ||
37 | + operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
38 | + | ||
39 | + BgpFsPacketLength tlv1 = new BgpFsPacketLength(operatorValue1); | ||
40 | + BgpFsPacketLength sameAsTlv1 = new BgpFsPacketLength(operatorValue1); | ||
41 | + BgpFsPacketLength tlv2 = new BgpFsPacketLength(operatorValue2); | ||
42 | + | ||
43 | + new EqualsTester() | ||
44 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
45 | + .addEqualityGroup(tlv2) | ||
46 | + .testEquals(); | ||
47 | + } | ||
48 | +} |
protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpFsSourcePortNumTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import com.google.common.testing.EqualsTester; | ||
24 | + | ||
25 | +/** | ||
26 | + * Test for source port number flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsSourcePortNumTest { | ||
29 | + List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>(); | ||
30 | + List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>(); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void testEquality() { | ||
34 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
35 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
36 | + operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100])); | ||
37 | + operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
38 | + | ||
39 | + BgpFsSourcePortNum tlv1 = new BgpFsSourcePortNum(operatorValue1); | ||
40 | + BgpFsSourcePortNum sameAsTlv1 = new BgpFsSourcePortNum(operatorValue1); | ||
41 | + BgpFsSourcePortNum tlv2 = new BgpFsSourcePortNum(operatorValue2); | ||
42 | + | ||
43 | + new EqualsTester() | ||
44 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
45 | + .addEqualityGroup(tlv2) | ||
46 | + .testEquals(); | ||
47 | + } | ||
48 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import org.junit.Test; | ||
19 | +import org.onlab.packet.IpAddress; | ||
20 | +import org.onlab.packet.IpPrefix; | ||
21 | +import com.google.common.testing.EqualsTester; | ||
22 | + | ||
23 | +/** | ||
24 | + * Test for source prefix flow specification component. | ||
25 | + */ | ||
26 | +public class BgpFsSourcePrefixTest { | ||
27 | + private final byte length = 4; | ||
28 | + | ||
29 | + private final IpPrefix prefix = IpPrefix.valueOf(IpAddress.valueOf("10.0.1.1"), 32); | ||
30 | + | ||
31 | + private final byte length2 = 4; | ||
32 | + private final IpPrefix prefix2 = IpPrefix.valueOf(IpAddress.valueOf("10.0.1.2"), 32); | ||
33 | + | ||
34 | + private final BgpFsSourcePrefix tlv1 = new BgpFsSourcePrefix(length, prefix); | ||
35 | + private final BgpFsSourcePrefix sameAsTlv1 = new BgpFsSourcePrefix(length, prefix); | ||
36 | + private final BgpFsSourcePrefix tlv2 = new BgpFsSourcePrefix(length2, prefix2); | ||
37 | + | ||
38 | + @Test | ||
39 | + public void testEquality() { | ||
40 | + new EqualsTester() | ||
41 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
42 | + .addEqualityGroup(tlv2) | ||
43 | + .testEquals(); | ||
44 | + } | ||
45 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.bgpio.types; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +import org.junit.Test; | ||
22 | + | ||
23 | +import com.google.common.testing.EqualsTester; | ||
24 | + | ||
25 | +/** | ||
26 | + * Test for TCP flags flow specification component. | ||
27 | + */ | ||
28 | +public class BgpFsTcpFlagsTest { | ||
29 | + List<BgpFsOperatorValue> operatorValue1 = new ArrayList<>(); | ||
30 | + List<BgpFsOperatorValue> operatorValue2 = new ArrayList<>(); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void testEquality() { | ||
34 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
35 | + operatorValue1.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
36 | + operatorValue2.add(new BgpFsOperatorValue((byte) 2, new byte[100])); | ||
37 | + operatorValue2.add(new BgpFsOperatorValue((byte) 1, new byte[100])); | ||
38 | + | ||
39 | + BgpFsTcpFlags tlv1 = new BgpFsTcpFlags(operatorValue1); | ||
40 | + BgpFsTcpFlags sameAsTlv1 = new BgpFsTcpFlags(operatorValue1); | ||
41 | + BgpFsTcpFlags tlv2 = new BgpFsTcpFlags(operatorValue2); | ||
42 | + | ||
43 | + new EqualsTester() | ||
44 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
45 | + .addEqualityGroup(tlv2) | ||
46 | + .testEquals(); | ||
47 | + } | ||
48 | +} |
-
Please register or login to post a comment