Thejaswi N K
Committed by Gerrit Code Review

BGP Route policy distribution and flow spec

Change-Id: I8903efd225a24db6ccc85a4a3148a4dd6076e042
Showing 94 changed files with 4782 additions and 0 deletions
1 +BUNDLES = [
2 + '//apps/bgpflowspec/flowapi:onos-apps-bgpflowspec-flowapi',
3 + '//apps/bgpflowspec/flowmgr:onos-apps-bgpflowspec-flowmgr',
4 + '//apps/bgpflowspec/bgpweb:onos-apps-bgpflowspec-web',
5 +]
6 +
7 +onos_app (
8 + title = 'BGP App',
9 + url = 'http://onosproject.org',
10 + included_bundles = BUNDLES,
11 + description = 'ONOS framework applications',
12 +)
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<app name="org.onosproject.bgpflow" origin="ON.Lab" version="${project.version}"
18 + category="default" url="http://onosproject.org"
19 + featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
20 + features="${project.artifactId}">
21 + <description>${project.description}</description>
22 + <artifact>mvn:${project.groupId}/onos-app-bgp-flowmgr/${project.version}</artifact>
23 + <artifact>mvn:${project.groupId}/onos-app-bgp-web/${project.version}</artifact>
24 + <artifact>mvn:${project.groupId}/onos-app-bgp-flowapi/${project.version}</artifact>
25 +</app>
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
18 + <feature name="${project.artifactId}" version="${project.version}"
19 + description="${project.description}">
20 + <feature>onos-api</feature>
21 + <feature>onos-drivers</feature>
22 + <bundle>mvn:${project.groupId}/onos-app-bgp-flowapi/${project.version}</bundle>
23 + <bundle>mvn:${project.groupId}/onos-app-bgp-flowmgr/${project.version}</bundle>
24 + <bundle>mvn:${project.groupId}/onos-app-bgp-web/${project.version}</bundle>
25 + </feature>
26 +</features>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19 + <modelVersion>4.0.0</modelVersion>
20 +
21 + <parent>
22 + <groupId>org.onosproject</groupId>
23 + <artifactId>onos-app-bgpflow</artifactId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + <relativePath>../pom.xml</relativePath>
26 + </parent>
27 +
28 + <artifactId>onos-app-bgp-flow</artifactId>
29 + <packaging>pom</packaging>
30 +
31 + <description>ONOS framework applications</description>
32 +
33 + <dependencies>
34 + <dependency>
35 + <groupId>org.onosproject</groupId>
36 + <artifactId>onos-app-bgp-flowapi</artifactId>
37 + <version>${project.version}</version>
38 + </dependency>
39 + <dependency>
40 + <groupId>org.onosproject</groupId>
41 + <artifactId>onos-app-bgp-flowmgr</artifactId>
42 + <version>${project.version}</version>
43 + </dependency>
44 + <dependency>
45 + <groupId>org.onosproject</groupId>
46 + <artifactId>onos-app-bgp-web</artifactId>
47 + <version>${project.version}</version>
48 + </dependency>
49 + </dependencies>
50 +
51 +</project>
1 +COMPILE_DEPS = [
2 + '//lib:CORE_DEPS',
3 + '//lib:javax.ws.rs-api',
4 + '//utils/rest:onlab-rest',
5 + '//apps/bgpflowspec/flowapi:onos-apps-bgpflowspec-flowapi',
6 + '//apps/bgpflowspec/flowmgr:onos-apps-bgpflowspec-flowmgr',
7 +]
8 +
9 +osgi_jar_with_tests (
10 + name = 'onos-apps-bgpflowspec-web',
11 + deps = COMPILE_DEPS,
12 +)
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project
18 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
19 + xmlns="http://maven.apache.org/POM/4.0.0"
20 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
21 + <modelVersion>4.0.0</modelVersion>
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-app-bgpflow</artifactId>
25 + <version>1.6.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-bgp-web</artifactId>
30 + <packaging>bundle</packaging>
31 + <properties>
32 + <web.context>/onos/bgp</web.context>
33 + </properties>
34 +
35 + <dependencies>
36 + <dependency>
37 + <groupId>javax.ws.rs</groupId>
38 + <artifactId>javax.ws.rs-api</artifactId>
39 + <version>2.0.1</version>
40 + </dependency>
41 + <dependency>
42 + <groupId>org.onosproject</groupId>
43 + <artifactId>onos-app-bgp-flowmgr</artifactId>
44 + <version>${project.version}</version>
45 + </dependency>
46 + <dependency>
47 + <groupId>org.onosproject</groupId>
48 + <artifactId>onos-rest</artifactId>
49 + <version>${project.version}</version>
50 + </dependency>
51 + <dependency>
52 + <groupId>com.google.guava</groupId>
53 + <artifactId>guava-testlib</artifactId>
54 + </dependency>
55 + </dependencies>
56 + <build>
57 + <plugins>
58 + <plugin>
59 + <groupId>org.apache.felix</groupId>
60 + <artifactId>maven-bundle-plugin</artifactId>
61 + <extensions>true</extensions>
62 + <configuration>
63 + <instructions>
64 + <_wab>src/main/webapp/</_wab>
65 + <Bundle-SymbolicName>
66 + ${project.groupId}.${project.artifactId}
67 + </Bundle-SymbolicName>
68 + <Import-Package>
69 + *,org.glassfish.jersey.servlet
70 + </Import-Package>
71 + <Web-ContextPath>${web.context}</Web-ContextPath>
72 + </instructions>
73 + </configuration>
74 + </plugin>
75 + </plugins>
76 + </build>
77 +
78 +</project>
1 +/*
2 + * Copyright 2016-present 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 +
17 +package org.onosproject.bgpweb.resources;
18 +
19 +import org.onlab.rest.AbstractWebApplication;
20 +import java.util.Set;
21 +
22 +/**
23 + * BGP REST API web application.
24 + */
25 +public class BgpWebApplication extends AbstractWebApplication {
26 + @Override
27 + public Set<Class<?>> getClasses() {
28 + return getClasses(BgpFlowWebResource.class);
29 + }
30 +}
31 +
1 +/*
2 + * Copyright 2016-present 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 +
17 +/**
18 + * BGP web that used rest to create BGP resources.
19 + */
20 +package org.onosproject.bgpweb.resources;
1 +/*
2 + * Copyright 2016-present 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.bgpweb.web;
17 +
18 +import org.apache.felix.scr.annotations.Activate;
19 +import org.apache.felix.scr.annotations.Component;
20 +import org.apache.felix.scr.annotations.Deactivate;
21 +import org.apache.felix.scr.annotations.Reference;
22 +import org.apache.felix.scr.annotations.ReferenceCardinality;
23 +import org.onosproject.codec.CodecService;
24 +import org.onosproject.flowapi.ExtFlowTypes;
25 +import org.slf4j.Logger;
26 +import org.slf4j.LoggerFactory;
27 +
28 +/**
29 + * Implementation of the JSON codec brokering service for BGP app.
30 + */
31 +@Component(immediate = true)
32 +public class BgpCodecRegistrator {
33 +
34 + private static Logger log = LoggerFactory.getLogger(BgpCodecRegistrator.class);
35 +
36 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
37 + protected CodecService codecService;
38 +
39 + @Activate
40 + public void activate() {
41 + codecService.registerCodec(ExtFlowTypes.class, new BgpFlowExtensionCodec());
42 + System.out.print("BgpCodecRegistrator started");
43 + log.info("Started");
44 + }
45 +
46 + @Deactivate
47 + public void deactivate() {
48 + log.info("Stopped");
49 + }
50 +}
1 +/*
2 + * Copyright 2016-present 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.bgpweb.web;
17 +
18 +import com.fasterxml.jackson.databind.node.ObjectNode;
19 +import org.onosproject.codec.CodecContext;
20 +import org.onosproject.codec.JsonCodec;
21 +import org.onosproject.flowapi.ExtFlowTypes;
22 +import org.slf4j.Logger;
23 +import org.slf4j.LoggerFactory;
24 +
25 +public final class BgpFlowExtensionCodec extends JsonCodec<ExtFlowTypes> {
26 +
27 + protected static final Logger log =
28 + LoggerFactory.getLogger(BgpFlowExtensionCodec.class);
29 +
30 + protected static final String TYPE = "type";
31 + protected static final String NAME = "name";
32 + protected static final String PREFIX = "prefix";
33 + protected static final String PROTOCOLS = "protocols";
34 + protected static final String PORT = "port";
35 + protected static final String DST_PORT = "destinationPort";
36 + protected static final String SRC_PORT = "sourcePort";
37 + protected static final String ICMP_TYPE = "icmpType";
38 + protected static final String ICMP_CODE = "icmpCode";
39 + protected static final String TCP_FLAG = "tcpFlag";
40 + protected static final String PACKET_LENGTH = "packetLength";
41 + protected static final String DSCP_VALUE = "dscpValue";
42 + protected static final String FRAGMENT = "fragment";
43 +
44 + protected static final String TRAFFIC_RATE = "trafficRate";
45 + protected static final String TRAFFIC_ACTION = "trafficAction";
46 + protected static final String TRAFFIC_REDIRECTION = "trafficRedirection";
47 + protected static final String TRAFFIC_MARKING = "trafficMarking";
48 +
49 + protected static final String TRAFFIC_RATE_ASN = "asn";
50 + protected static final String TRAFFIC_RATE_RATE = "rate";
51 + protected static final String TRAFFIC_ACTION_TERMINAL = "terminal";
52 + protected static final String TRAFFIC_ACTION_SAMPLE = "sample";
53 + protected static final String TRAFFIC_ACTION_RPD = "rpd";
54 +
55 + protected static final String WIDE_COMM_FLAGS = "widecommunityFlags";
56 + protected static final String WIDE_COMM_HOP_COUNT = "widecommunityHopCount";
57 + protected static final String WIDE_COMM_COMMUNITY = "widecommunityCommunity";
58 + protected static final String WIDE_COMM_CONTEXT_AS = "widecommunityContextAs";
59 + protected static final String WIDE_COMM_LOCAL_AS = "widecommunityLocalAs";
60 + protected static final String WIDE_COMM_TARGET = "widecommunityTarget";
61 + protected static final String WIDE_COMM_EXT_TARGET = "widecommunityExtTarget";
62 + protected static final String WIDE_COMM_PARAMETER = "widecommunityParameter";
63 +
64 + protected static final String WIDE_COMM_TGT_LOCAL_SP = "localSpeaker";
65 + protected static final String WIDE_COMM_TGT_REMOTE_SP = "remoteSpeaker";
66 +
67 + @Override
68 + public ObjectNode encode(ExtFlowTypes flowTypes, CodecContext context) {
69 + return null;
70 + }
71 +
72 + @Override
73 + public ExtFlowTypes decode(ObjectNode json, CodecContext context) {
74 + DecodeBgpFlowExtnCodecHelper decoder = new DecodeBgpFlowExtnCodecHelper(json);
75 + return decoder.decode();
76 + }
77 +}
1 +/*
2 + * Copyright 2016-prensent 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 +
17 +/**
18 + * Codec for bgp flow.
19 + */
20 +package org.onosproject.bgpweb.web;
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18 + xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19 + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20 + id="ONOS" version="2.5">
21 + <display-name>BGP REST API v1.0</display-name>
22 +
23 +
24 + <servlet>
25 + <servlet-name>JAX-RS Service</servlet-name>
26 + <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
27 + <init-param>
28 + <param-name>javax.ws.rs.Application</param-name>
29 + <param-value>org.onosproject.bgpweb.resources.BgpWebApplication</param-value>
30 + </init-param>
31 + <load-on-startup>1</load-on-startup>
32 + </servlet>
33 +
34 + <servlet-mapping>
35 + <servlet-name>JAX-RS Service</servlet-name>
36 + <url-pattern>/*</url-pattern>
37 + </servlet-mapping>
38 +</web-app>
1 +COMPILE_DEPS = [
2 + '//utils/osgi:onlab-osgi',
3 + '//utils/misc:onlab-misc',
4 + '//lib:commons-io',
5 + '//lib:guava',
6 + '//lib:kryo',
7 + '//lib:slf4j-api',
8 +]
9 +
10 +TEST_DEPS = [
11 + '//lib:TEST_ADAPTERS',
12 +]
13 +
14 +osgi_jar_with_tests (
15 + name = 'onos-apps-bgpflowspec-flowapi',
16 + deps = COMPILE_DEPS,
17 + test_deps = TEST_DEPS,
18 + visibility = ['PUBLIC'],
19 +)
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-present Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-app-bgpflow</artifactId>
25 + <version>1.6.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-bgp-flowapi</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>api bundle to be accessible across the layers</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>org.onosproject</groupId>
37 + <artifactId>onlab-misc</artifactId>
38 + <version>1.6.0-SNAPSHOT</version>
39 + </dependency>
40 + <dependency>
41 + <groupId>com.google.guava</groupId>
42 + <artifactId>guava-testlib</artifactId>
43 + <scope>test</scope>
44 + </dependency>
45 + </dependencies>
46 +
47 +</project>
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * DSCP value extension implementation.
26 + */
27 +public class DefaultExtDscpValue implements ExtDscpValue {
28 +
29 + private List<ExtOperatorValue> dscpValue;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtDscpValue which contains dscp operator value list.
34 + *
35 + * @param dscpValue is a dscp value rule list
36 + * @param type ExtType type
37 + */
38 + DefaultExtDscpValue(List<ExtOperatorValue> dscpValue, ExtType type) {
39 + this.dscpValue = dscpValue;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> dscpValue() {
50 + return dscpValue;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtDscpValue value) {
55 + return this.equals(value) &&
56 + Objects.equals(this.dscpValue, value.dscpValue())
57 + && Objects.equals(this.type, value.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(dscpValue, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtDscpValue) {
71 + DefaultExtDscpValue that = (DefaultExtDscpValue) obj;
72 + return Objects.equals(dscpValue, that.dscpValue())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("dscpValue", dscpValue.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension dscp value.
88 + */
89 + public static class Builder implements ExtDscpValue.Builder {
90 + private List<ExtOperatorValue> dscpValue;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setDscpValue(List<ExtOperatorValue> dscpValue) {
95 + this.dscpValue = dscpValue;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtDscpValue build() {
107 + checkNotNull(dscpValue, "dscpValue cannot be null");
108 + return new DefaultExtDscpValue(dscpValue, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Fragment extension implementation.
26 + */
27 +public class DefaultExtFragment implements ExtFragment {
28 +
29 + private List<ExtOperatorValue> fragment;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtFragment which contains fragment operator value list.
34 + *
35 + * @param fragment is a fragment value rule list
36 + * @param type ExtType type
37 + */
38 + DefaultExtFragment(List<ExtOperatorValue> fragment, ExtType type) {
39 + this.fragment = fragment;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> fragment() {
50 + return fragment;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtFragment value) {
55 + return this.equals(value) &&
56 + Objects.equals(this.fragment, value.fragment())
57 + && Objects.equals(this.type, value.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(fragment, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtFragment) {
71 + DefaultExtFragment that = (DefaultExtFragment) obj;
72 + return Objects.equals(fragment, that.fragment())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("fragment", fragment.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension fragment value.
88 + */
89 + public static class Builder implements ExtFragment.Builder {
90 + private List<ExtOperatorValue> fragment;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setFragment(List<ExtOperatorValue> fragment) {
95 + this.fragment = fragment;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtFragment build() {
107 + checkNotNull(fragment, "fragment cannot be null");
108 + return new DefaultExtFragment(fragment, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Icmp code extension implementation.
26 + */
27 +public class DefaultExtIcmpCode implements ExtIcmpCode {
28 +
29 + private List<ExtOperatorValue> icmpCode;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtIcmpCode which contains ICMP code operator value list.
34 + *
35 + * @param icmpCode is a icmp code rule list
36 + * @param type ExtType type
37 + */
38 + DefaultExtIcmpCode(List<ExtOperatorValue> icmpCode, ExtType type) {
39 + this.icmpCode = icmpCode;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> icmpCode() {
50 + return icmpCode;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtIcmpCode icmpCode) {
55 + return this.equals(icmpCode) &&
56 + Objects.equals(this.icmpCode, icmpCode.icmpCode())
57 + && Objects.equals(this.type, icmpCode.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(icmpCode, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtIcmpCode) {
71 + DefaultExtIcmpCode that = (DefaultExtIcmpCode) obj;
72 + return Objects.equals(icmpCode, that.icmpCode())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("icmpCode", icmpCode.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension icmp type.
88 + */
89 + public static class Builder implements ExtIcmpCode.Builder {
90 + private List<ExtOperatorValue> icmpCode;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setIcmpCode(List<ExtOperatorValue> icmpCode) {
95 + this.icmpCode = icmpCode;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtIcmpCode build() {
107 + checkNotNull(icmpCode, "icmpCode cannot be null");
108 + return new DefaultExtIcmpCode(icmpCode, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Icmp type extension implementation.
26 + */
27 +public class DefaultExtIcmpType implements ExtIcmpType {
28 +
29 + private List<ExtOperatorValue> icmpType;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtIcmpType which contains ICMP type operator value list.
34 + *
35 + * @param icmpType is a icmp type rule list
36 + * @param type ExtType type
37 + */
38 + DefaultExtIcmpType(List<ExtOperatorValue> icmpType, ExtType type) {
39 + this.icmpType = icmpType;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> icmpType() {
50 + return icmpType;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtIcmpType icmpType) {
55 + return this.equals(icmpType) &&
56 + Objects.equals(this.icmpType, icmpType.icmpType())
57 + && Objects.equals(this.type, icmpType.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(icmpType, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtIcmpType) {
71 + DefaultExtIcmpType that = (DefaultExtIcmpType) obj;
72 + return Objects.equals(icmpType, that.icmpType())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("icmpType", icmpType.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension icmp type.
88 + */
89 + public static class Builder implements ExtIcmpType.Builder {
90 + private List<ExtOperatorValue> icmpType;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setIcmpType(List<ExtOperatorValue> icmpType) {
95 + this.icmpType = icmpType;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtIcmpType build() {
107 + checkNotNull(icmpType, "icmpType cannot be null");
108 + return new DefaultExtIcmpType(icmpType, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Ip protocol extension implementation.
26 + */
27 +public final class DefaultExtIpProtocol implements ExtIpProtocol {
28 +
29 + private List<ExtOperatorValue> ipProtocol;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtIpProtocol which contains Ip protocol list.
34 + *
35 + * @param ipProtocol Ip protocol operator value list
36 + * @param type BgpType type
37 + */
38 + DefaultExtIpProtocol(List<ExtOperatorValue> ipProtocol, ExtType type) {
39 + this.ipProtocol = ipProtocol;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> ipProtocol() {
50 + return ipProtocol;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtIpProtocol ipProto) {
55 + return this.equals(ipProto) &&
56 + Objects.equals(this.ipProtocol, ipProto.ipProtocol())
57 + && Objects.equals(this.type, ipProto.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(ipProtocol, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtIpProtocol) {
71 + DefaultExtIpProtocol that = (DefaultExtIpProtocol) obj;
72 + return Objects.equals(ipProtocol, that.ipProtocol())
73 + && Objects.equals(this.type, that.type);
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("ipProtocol", ipProtocol.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension Ip protocol.
88 + */
89 + public static class Builder implements ExtIpProtocol.Builder {
90 + private List<ExtOperatorValue> ipProtocol;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setIpProtocol(List<ExtOperatorValue> ipProtocol) {
95 + this.ipProtocol = ipProtocol;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtIpProtocol build() {
107 + checkNotNull(ipProtocol, "Ip protocol cannot be null");
108 + return new DefaultExtIpProtocol(ipProtocol, type);
109 + }
110 + }
111 +}
112 +
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.Objects;
19 +import static com.google.common.base.MoreObjects.toStringHelper;
20 +import static com.google.common.base.Preconditions.checkNotNull;
21 +
22 +/**
23 + * Key Name for the extension implementation.
24 + */
25 +public class DefaultExtKeyName implements ExtKeyName {
26 +
27 + private String keyName;
28 + private ExtType type;
29 +
30 + /**
31 + * Creates an object of type DefaultExtKeyName which name for the flow rule.
32 + *
33 + * @param keyName is a key for the extended rule
34 + * @param type ExtType type
35 + */
36 + DefaultExtKeyName(String keyName, ExtType type) {
37 + this.keyName = keyName;
38 + this.type = type;
39 + }
40 +
41 + @Override
42 + public ExtType type() {
43 + return type;
44 + }
45 +
46 + @Override
47 + public String keyName() {
48 + return keyName;
49 + }
50 +
51 + @Override
52 + public boolean exactMatch(ExtKeyName value) {
53 + return this.equals(value) &&
54 + Objects.equals(this.keyName, value.keyName())
55 + && Objects.equals(this.type, value.type());
56 + }
57 +
58 + @Override
59 + public int hashCode() {
60 + return Objects.hash(keyName, type);
61 + }
62 +
63 + @Override
64 + public boolean equals(Object obj) {
65 + if (this == obj) {
66 + return true;
67 + }
68 + if (obj instanceof DefaultExtKeyName) {
69 + DefaultExtKeyName that = (DefaultExtKeyName) obj;
70 + return Objects.equals(keyName, that.keyName())
71 + && Objects.equals(this.type, that.type());
72 + }
73 + return false;
74 + }
75 +
76 + @Override
77 + public String toString() {
78 + return toStringHelper(this)
79 + .add("keyName", keyName.toString())
80 + .add("type", type.toString())
81 + .toString();
82 + }
83 +
84 + /**
85 + * Builder class for Extended key name for the rule.
86 + */
87 + public static class Builder implements ExtKeyName.Builder {
88 + private String keyName;
89 + private ExtType type;
90 +
91 + @Override
92 + public Builder setKeyName(String keyName) {
93 + this.keyName = keyName;
94 + return this;
95 + }
96 +
97 + @Override
98 + public Builder setType(ExtType type) {
99 + this.type = type;
100 + return this;
101 + }
102 +
103 + @Override
104 + public ExtKeyName build() {
105 + checkNotNull(keyName, "keyName cannot be null");
106 + return new DefaultExtKeyName(keyName, type);
107 + }
108 + }
109 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Packet length extension implementation.
26 + */
27 +public class DefaultExtPacketLength implements ExtPacketLength {
28 +
29 + private List<ExtOperatorValue> packetLength;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtPacketLength which contains packet length list..
34 + *
35 + * @param packetLength is a packet length rule
36 + * @param type ExtType type
37 + */
38 + DefaultExtPacketLength(List<ExtOperatorValue> packetLength, ExtType type) {
39 + this.packetLength = packetLength;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> packetLength() {
50 + return packetLength;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtPacketLength length) {
55 + return this.equals(packetLength) &&
56 + Objects.equals(this.packetLength, length.packetLength())
57 + && Objects.equals(this.type, length.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(packetLength, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtPacketLength) {
71 + DefaultExtPacketLength that = (DefaultExtPacketLength) obj;
72 + return Objects.equals(packetLength, that.packetLength())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("packetLength", packetLength.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension packet length.
88 + */
89 + public static class Builder implements ExtPacketLength.Builder {
90 + private List<ExtOperatorValue> packetLength;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setPacketLength(List<ExtOperatorValue> packetLength) {
95 + this.packetLength = packetLength;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtPacketLength build() {
107 + checkNotNull(packetLength, "packetLength cannot be null");
108 + return new DefaultExtPacketLength(packetLength, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Port extension implementation.
26 + */
27 +public class DefaultExtPort implements ExtPort {
28 +
29 + private List<ExtOperatorValue> port;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtPort which contains port list.
34 + *
35 + * @param port is a port rule list
36 + * @param type ExtType type
37 + */
38 + DefaultExtPort(List<ExtOperatorValue> port, ExtType type) {
39 + this.port = port;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> port() {
50 + return port;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtPort port) {
55 + return this.equals(port) &&
56 + Objects.equals(this.port, port.port())
57 + && Objects.equals(this.type, port.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(port, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtPort) {
71 + DefaultExtPort that = (DefaultExtPort) obj;
72 + return Objects.equals(port, that.port())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("port", port.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension port.
88 + */
89 + public static class Builder implements ExtPort.Builder {
90 + private List<ExtOperatorValue> port;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setPort(List<ExtOperatorValue> port) {
95 + this.port = port;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtPort build() {
107 + checkNotNull(port, "port cannot be null");
108 + return new DefaultExtPort(port, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import org.onlab.packet.IpPrefix;
19 +
20 +import java.util.ArrayList;
21 +import java.util.List;
22 +import java.util.Objects;
23 +
24 +import static com.google.common.base.MoreObjects.toStringHelper;
25 +import static com.google.common.base.Preconditions.checkNotNull;
26 +
27 +/**
28 + * Ip prefix extension implementation.
29 + */
30 +public final class DefaultExtPrefix implements ExtPrefix {
31 +
32 + private List<IpPrefix> prefix;
33 + private ExtType type;
34 +
35 + /**
36 + * Creates an object of type DefaultExtPrefix which contains Ip prefix list.
37 + *
38 + * @param prefix Ip prefix list
39 + * @param type ExtType type
40 + */
41 + DefaultExtPrefix(List<IpPrefix> prefix, ExtType type) {
42 + this.prefix = prefix;
43 + this.type = type;
44 + }
45 +
46 + @Override
47 + public ExtType type() {
48 + return type;
49 + }
50 +
51 + @Override
52 + public List<IpPrefix> prefix() {
53 + return prefix;
54 + }
55 +
56 + @Override
57 + public boolean exactMatch(ExtPrefix prefix) {
58 + return this.equals(prefix) &&
59 + Objects.equals(this.prefix, prefix.prefix())
60 + && Objects.equals(this.type, prefix.type());
61 + }
62 +
63 + @Override
64 + public int hashCode() {
65 + return Objects.hash(prefix, type);
66 + }
67 +
68 + @Override
69 + public boolean equals(Object obj) {
70 + if (this == obj) {
71 + return true;
72 + }
73 + if (obj instanceof DefaultExtPrefix) {
74 + DefaultExtPrefix that = (DefaultExtPrefix) obj;
75 + return Objects.equals(prefix, that.prefix())
76 + && Objects.equals(this.type, that.type);
77 + }
78 + return false;
79 + }
80 +
81 + @Override
82 + public String toString() {
83 + return toStringHelper(this)
84 + .add("prefix", prefix.toString())
85 + .add("type", type.toString())
86 + .toString();
87 + }
88 +
89 + /**
90 + * Builder class for extension Ip prefix.
91 + */
92 + public static class Builder implements ExtPrefix.Builder {
93 + private List<IpPrefix> prefix = new ArrayList<>();
94 + private ExtType type;
95 +
96 + @Override
97 + public Builder setPrefix(IpPrefix ip) {
98 + this.prefix.add(ip);
99 + return this;
100 + }
101 +
102 + @Override
103 + public Builder setType(ExtType type) {
104 + this.type = type;
105 + return this;
106 + }
107 +
108 + @Override
109 + public ExtPrefix build() {
110 + checkNotNull(prefix, "Ip prefix cannot be null");
111 + return new DefaultExtPrefix(prefix, type);
112 + }
113 + }
114 +}
115 +
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +
23 +/**
24 + * Target local and remote speaker implementation for wide community.
25 + */
26 +public final class DefaultExtTarget implements ExtTarget {
27 +
28 + private ExtPrefix localSpeaker;
29 + private ExtPrefix remoteSpeaker;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtTarget which contains local and remote speakers.
34 + *
35 + * @param localSpeaker local speaker prefix list
36 + * @param remoteSpeaker remoteSpeaker speaker prefix list
37 + * @param type ExtType type
38 + */
39 + DefaultExtTarget(ExtPrefix localSpeaker, ExtPrefix remoteSpeaker, ExtType type) {
40 + this.localSpeaker = localSpeaker;
41 + this.remoteSpeaker = remoteSpeaker;
42 + this.type = type;
43 + }
44 +
45 + @Override
46 + public ExtType type() {
47 + return type;
48 + }
49 +
50 + /**
51 + * Returns the local speaker prefix list.
52 + *
53 + * @return the ExtPrefix
54 + */
55 + @Override
56 + public ExtPrefix localSpeaker() {
57 + return localSpeaker;
58 + }
59 +
60 + /**
61 + * Returns the remote speaker prefix list.
62 + *
63 + * @return the ExtPrefix
64 + */
65 + @Override
66 + public ExtPrefix remoteSpeaker() {
67 + return remoteSpeaker;
68 + }
69 +
70 + /**
71 + * Returns whether this target is an exact match to the target given
72 + * in the argument.
73 + *
74 + * @param target other target to match
75 + * @return true if the target are an exact match, otherwise false
76 + */
77 + @Override
78 + public boolean exactMatch(ExtTarget target) {
79 + return this.equals(target) &&
80 + Objects.equals(this.localSpeaker, target.localSpeaker())
81 + && Objects.equals(this.remoteSpeaker, target.remoteSpeaker())
82 + && Objects.equals(this.type, target.type());
83 + }
84 +
85 + @Override
86 + public int hashCode() {
87 + return Objects.hash(localSpeaker, remoteSpeaker, type);
88 + }
89 +
90 + @Override
91 + public boolean equals(Object obj) {
92 + if (this == obj) {
93 + return true;
94 + }
95 + if (obj instanceof DefaultExtTarget) {
96 + DefaultExtTarget that = (DefaultExtTarget) obj;
97 + return Objects.equals(localSpeaker, that.localSpeaker())
98 + && Objects.equals(remoteSpeaker, that.remoteSpeaker())
99 + && Objects.equals(this.type, that.type);
100 + }
101 + return false;
102 + }
103 +
104 + @Override
105 + public String toString() {
106 + return toStringHelper(this)
107 + .add("localSpeaker", localSpeaker)
108 + .add("remoteSpeaker", remoteSpeaker)
109 + .add("type", type)
110 + .toString();
111 + }
112 +
113 + /**
114 + * Builder class for wide community target.
115 + */
116 + public static class Builder implements ExtTarget.Builder {
117 + private ExtPrefix localSpeaker;
118 + private ExtPrefix remoteSpeaker;
119 + private ExtType type;
120 +
121 + @Override
122 + public Builder setLocalSpeaker(ExtPrefix localSpeaker) {
123 + this.localSpeaker = localSpeaker;
124 + return this;
125 + }
126 +
127 + @Override
128 + public Builder setRemoteSpeaker(ExtPrefix remoteSpeaker) {
129 + this.remoteSpeaker = remoteSpeaker;
130 + return this;
131 + }
132 +
133 + @Override
134 + public Builder setType(ExtType type) {
135 + this.type = type;
136 + return this;
137 + }
138 +
139 + @Override
140 + public ExtTarget build() {
141 + checkNotNull(localSpeaker, "localSpeaker cannot be null");
142 + checkNotNull(remoteSpeaker, "remoteSpeaker cannot be null");
143 + return new DefaultExtTarget(localSpeaker, remoteSpeaker, type);
144 + }
145 + }
146 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +import java.util.Objects;
20 +
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 +/**
25 + * Tcp flag extension implementation.
26 + */
27 +public class DefaultExtTcpFlag implements ExtTcpFlag {
28 +
29 + private List<ExtOperatorValue> tcpFlag;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtTcpFlag which contains tcp flag.
34 + *
35 + * @param tcpFlag is a Tcp Flag rule list
36 + * @param type ExtType type
37 + */
38 + DefaultExtTcpFlag(List<ExtOperatorValue> tcpFlag, ExtType type) {
39 + this.tcpFlag = tcpFlag;
40 + this.type = type;
41 + }
42 +
43 + @Override
44 + public ExtType type() {
45 + return type;
46 + }
47 +
48 + @Override
49 + public List<ExtOperatorValue> tcpFlag() {
50 + return tcpFlag;
51 + }
52 +
53 + @Override
54 + public boolean exactMatch(ExtTcpFlag flag) {
55 + return this.equals(tcpFlag) &&
56 + Objects.equals(this.tcpFlag, flag.tcpFlag())
57 + && Objects.equals(this.type, flag.type());
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(tcpFlag, type);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultExtTcpFlag) {
71 + DefaultExtTcpFlag that = (DefaultExtTcpFlag) obj;
72 + return Objects.equals(tcpFlag, that.tcpFlag())
73 + && Objects.equals(this.type, that.type());
74 + }
75 + return false;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return toStringHelper(this)
81 + .add("tcpFlag", tcpFlag.toString())
82 + .add("type", type.toString())
83 + .toString();
84 + }
85 +
86 + /**
87 + * Builder class for extension tcp flag.
88 + */
89 + public static class Builder implements ExtTcpFlag.Builder {
90 + private List<ExtOperatorValue> tcpFlag;
91 + private ExtType type;
92 +
93 + @Override
94 + public Builder setTcpFlag(List<ExtOperatorValue> tcpFlag) {
95 + this.tcpFlag = tcpFlag;
96 + return this;
97 + }
98 +
99 + @Override
100 + public Builder setType(ExtType type) {
101 + this.type = type;
102 + return this;
103 + }
104 +
105 + @Override
106 + public ExtTcpFlag build() {
107 + checkNotNull(tcpFlag, "tcpFlag cannot be null");
108 + return new DefaultExtTcpFlag(tcpFlag, type);
109 + }
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +
23 +/**
24 + * Extended traffic action implementation.
25 + */
26 +public class DefaultExtTrafficAction implements ExtTrafficAction {
27 +
28 + private boolean terminal;
29 + private boolean sample;
30 + private boolean rpd;
31 + private ExtType type;
32 +
33 + /**
34 + * Creates an object of type DefaultExtTrafficAction which contains traffic action flag.
35 + *
36 + * @param terminal traffic action terminal bit
37 + * @param sample is a traffic action sampling
38 + * @param rpd traffic action rpd bit
39 + * @param type ExtType type
40 + */
41 + DefaultExtTrafficAction(boolean terminal, boolean sample, boolean rpd, ExtType type) {
42 + this.terminal = terminal;
43 + this.sample = sample;
44 + this.rpd = rpd;
45 + this.type = type;
46 + }
47 +
48 + @Override
49 + public ExtType type() {
50 + return type;
51 + }
52 +
53 + @Override
54 + public boolean terminal() {
55 + return terminal;
56 + }
57 +
58 + @Override
59 + public boolean sample() {
60 + return sample;
61 + }
62 +
63 + @Override
64 + public boolean rpd() {
65 + return rpd;
66 + }
67 +
68 + @Override
69 + public boolean exactMatch(ExtTrafficAction value) {
70 + return this.equals(value) &&
71 + Objects.equals(this.terminal, value.terminal())
72 + && Objects.equals(this.sample, value.sample())
73 + && Objects.equals(this.rpd, value.rpd())
74 + && Objects.equals(this.type, value.type());
75 + }
76 +
77 + @Override
78 + public int hashCode() {
79 + return Objects.hash(terminal, sample, rpd, type);
80 + }
81 +
82 + @Override
83 + public boolean equals(Object obj) {
84 + if (this == obj) {
85 + return true;
86 + }
87 + if (obj instanceof DefaultExtTrafficAction) {
88 + DefaultExtTrafficAction that = (DefaultExtTrafficAction) obj;
89 + return Objects.equals(terminal, that.terminal())
90 + && Objects.equals(this.sample, that.sample())
91 + && Objects.equals(this.rpd, that.rpd())
92 + && Objects.equals(this.type, that.type());
93 + }
94 + return false;
95 + }
96 +
97 + @Override
98 + public String toString() {
99 + return toStringHelper(this)
100 + .add("terminal", Boolean.valueOf(terminal).toString())
101 + .add("sample", Boolean.valueOf(sample).toString())
102 + .add("rpd", Boolean.valueOf(rpd).toString())
103 + .add("type", type.toString())
104 + .toString();
105 + }
106 +
107 + /**
108 + * Builder class for extended traffic rate rule.
109 + */
110 + public static class Builder implements ExtTrafficAction.Builder {
111 + private boolean terminal;
112 + private boolean sample;
113 + private boolean rpd;
114 + private ExtType type;
115 +
116 + @Override
117 + public Builder setTerminal(boolean terminal) {
118 + this.terminal = terminal;
119 + return this;
120 + }
121 +
122 + @Override
123 + public Builder setSample(boolean sample) {
124 + this.sample = sample;
125 + return this;
126 + }
127 +
128 + @Override
129 + public Builder setRpd(boolean rpd) {
130 + this.rpd = rpd;
131 + return this;
132 + }
133 +
134 + @Override
135 + public Builder setType(ExtType type) {
136 + this.type = type;
137 + return this;
138 + }
139 +
140 + @Override
141 + public ExtTrafficAction build() {
142 + checkNotNull(terminal, "terminal cannot be null");
143 + checkNotNull(sample, "sample cannot be null");
144 + checkNotNull(rpd, "rpd cannot be null");
145 + return new DefaultExtTrafficAction(terminal, sample, rpd, type);
146 + }
147 + }
148 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +
23 +/**
24 + * Extended traffic marking implementation.
25 + */
26 +public class DefaultExtTrafficMarking implements ExtTrafficMarking {
27 +
28 + private byte marking;
29 + private ExtType type;
30 +
31 + /**
32 + * Creates an object of type DefaultExtTrafficMarking which contains traffic marking byte.
33 + *
34 + * @param marking is a marking rule
35 + * @param type ExtType type
36 + */
37 + DefaultExtTrafficMarking(byte marking, ExtType type) {
38 + this.marking = marking;
39 + this.type = type;
40 + }
41 +
42 + @Override
43 + public ExtType type() {
44 + return type;
45 + }
46 +
47 + @Override
48 + public byte marking() {
49 + return marking;
50 + }
51 +
52 + @Override
53 + public boolean exactMatch(ExtTrafficMarking value) {
54 + return this.equals(value) &&
55 + Objects.equals(this.marking, value.marking())
56 + && Objects.equals(this.type, value.type());
57 + }
58 +
59 + @Override
60 + public int hashCode() {
61 + return Objects.hash(marking, type);
62 + }
63 +
64 + @Override
65 + public boolean equals(Object obj) {
66 + if (this == obj) {
67 + return true;
68 + }
69 + if (obj instanceof DefaultExtTrafficMarking) {
70 + DefaultExtTrafficMarking that = (DefaultExtTrafficMarking) obj;
71 + return Objects.equals(marking, that.marking())
72 + && Objects.equals(this.type, that.type());
73 + }
74 + return false;
75 + }
76 +
77 + @Override
78 + public String toString() {
79 + return toStringHelper(this)
80 + .add("marking", marking)
81 + .add("type", type.toString())
82 + .toString();
83 + }
84 +
85 + /**
86 + * Builder class for extended traffic marking value rule.
87 + */
88 + public static class Builder implements ExtTrafficMarking.Builder {
89 + private byte marking;
90 + private ExtType type;
91 +
92 + @Override
93 + public Builder setMarking(byte marking) {
94 + this.marking = marking;
95 + return this;
96 + }
97 +
98 + @Override
99 + public Builder setType(ExtType type) {
100 + this.type = type;
101 + return this;
102 + }
103 +
104 + @Override
105 + public ExtTrafficMarking build() {
106 + checkNotNull(marking, "marking cannot be null");
107 + return new DefaultExtTrafficMarking(marking, type);
108 + }
109 + }
110 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +
23 +/**
24 + * Extended traffic rate implementation.
25 + */
26 +public class DefaultExtTrafficRate implements ExtTrafficRate {
27 +
28 + private Short asn;
29 + private Float rate;
30 + private ExtType type;
31 +
32 + /**
33 + * Creates an object of type DefaultExtTrafficRate which contains traffic rate action.
34 + *
35 + * @param asn is a AS number
36 + * @param rate is a traffic rate in bytes per second
37 + * @param type ExtType type
38 + */
39 + DefaultExtTrafficRate(short asn, float rate, ExtType type) {
40 + this.asn = Short.valueOf(asn);
41 + this.rate = Float.valueOf(rate);
42 + this.type = type;
43 + }
44 +
45 + @Override
46 + public ExtType type() {
47 + return type;
48 + }
49 +
50 + @Override
51 + public Short asn() {
52 + return asn;
53 + }
54 +
55 + @Override
56 + public Float rate() {
57 + return rate;
58 + }
59 +
60 + @Override
61 + public boolean exactMatch(ExtTrafficRate value) {
62 + return this.equals(value) &&
63 + Objects.equals(this.asn, value.asn())
64 + && Objects.equals(this.rate, value.rate())
65 + && Objects.equals(this.type, value.type());
66 + }
67 +
68 + @Override
69 + public int hashCode() {
70 + return Objects.hash(asn, rate, type);
71 + }
72 +
73 + @Override
74 + public boolean equals(Object obj) {
75 + if (this == obj) {
76 + return true;
77 + }
78 + if (obj instanceof DefaultExtTrafficRate) {
79 + DefaultExtTrafficRate that = (DefaultExtTrafficRate) obj;
80 + return Objects.equals(asn, that.asn())
81 + && Objects.equals(this.rate, that.rate())
82 + && Objects.equals(this.type, that.type());
83 + }
84 + return false;
85 + }
86 +
87 + @Override
88 + public String toString() {
89 + return toStringHelper(this)
90 + .add("asn", asn.toString())
91 + .add("rate", rate.toString())
92 + .add("type", type.toString())
93 + .toString();
94 + }
95 +
96 + /**
97 + * Builder class for extended traffic rate rule.
98 + */
99 + public static class Builder implements ExtTrafficRate.Builder {
100 + private Short asn;
101 + private Float rate;
102 + private ExtType type;
103 +
104 + @Override
105 + public Builder setAsn(short asn) {
106 + this.asn = Short.valueOf(asn);
107 + return this;
108 + }
109 +
110 + @Override
111 + public Builder setRate(float rate) {
112 + this.rate = Float.valueOf(rate);
113 + return this;
114 + }
115 +
116 + @Override
117 + public Builder setType(ExtType type) {
118 + this.type = type;
119 + return this;
120 + }
121 +
122 + @Override
123 + public ExtTrafficRate build() {
124 + checkNotNull(asn, "asn cannot be null");
125 + checkNotNull(rate, "rate cannot be null");
126 + return new DefaultExtTrafficRate(asn, rate, type);
127 + }
128 + }
129 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +
23 +/**
24 + * Extended traffic redirect implementation.
25 + */
26 +public class DefaultExtTrafficRedirect implements ExtTrafficRedirect {
27 +
28 + private String redirect;
29 + private ExtType type;
30 +
31 + /**
32 + * Creates an object of type DefaultExtTrafficRedirect which contains traffic redirect action.
33 + *
34 + * @param redirect is a redirect rule
35 + * @param type ExtType type
36 + */
37 + DefaultExtTrafficRedirect(String redirect, ExtType type) {
38 + this.redirect = redirect;
39 + this.type = type;
40 + }
41 +
42 + @Override
43 + public ExtType type() {
44 + return type;
45 + }
46 +
47 + @Override
48 + public String redirect() {
49 + return redirect;
50 + }
51 +
52 + @Override
53 + public boolean exactMatch(ExtTrafficRedirect value) {
54 + return this.equals(value) &&
55 + Objects.equals(this.redirect, value.redirect())
56 + && Objects.equals(this.type, value.type());
57 + }
58 +
59 + @Override
60 + public int hashCode() {
61 + return Objects.hash(redirect, type);
62 + }
63 +
64 + @Override
65 + public boolean equals(Object obj) {
66 + if (this == obj) {
67 + return true;
68 + }
69 + if (obj instanceof DefaultExtTrafficRedirect) {
70 + DefaultExtTrafficRedirect that = (DefaultExtTrafficRedirect) obj;
71 + return Objects.equals(redirect, that.redirect())
72 + && Objects.equals(this.type, that.type());
73 + }
74 + return false;
75 + }
76 +
77 + @Override
78 + public String toString() {
79 + return toStringHelper(this)
80 + .add("redirect", redirect.toString())
81 + .add("type", type.toString())
82 + .toString();
83 + }
84 +
85 + /**
86 + * Builder class for extended redirect value rule.
87 + */
88 + public static class Builder implements ExtTrafficRedirect.Builder {
89 + private String redirect;
90 + private ExtType type;
91 +
92 + @Override
93 + public Builder setRedirect(String redirect) {
94 + this.redirect = redirect;
95 + return this;
96 + }
97 +
98 + @Override
99 + public Builder setType(ExtType type) {
100 + this.type = type;
101 + return this;
102 + }
103 +
104 + @Override
105 + public ExtTrafficRedirect build() {
106 + checkNotNull(redirect, "redirect cannot be null");
107 + return new DefaultExtTrafficRedirect(redirect, type);
108 + }
109 + }
110 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.ArrayList;
19 +import java.util.List;
20 +import java.util.Objects;
21 +
22 +import static com.google.common.base.MoreObjects.toStringHelper;
23 +import static com.google.common.base.Preconditions.checkNotNull;
24 +
25 +/**
26 + * Wide community attributes for RPD implementation.
27 + */
28 +public class DefaultExtWideCommunityInt implements ExtWideCommunityInt {
29 +
30 + private List<Integer> wCommInt;
31 + private ExtType type;
32 +
33 + /**
34 + * Creates an object of type DefaultExtWideCommunityInt which contains wide community attributes.
35 + *
36 + * @param wCommInt is a wide community value
37 + * @param type ExtType type
38 + */
39 + DefaultExtWideCommunityInt(List<Integer> wCommInt, ExtType type) {
40 + this.wCommInt = wCommInt;
41 + this.type = type;
42 + }
43 +
44 + @Override
45 + public ExtType type() {
46 + return type;
47 + }
48 +
49 + @Override
50 + public List<Integer> communityInt() {
51 + return wCommInt;
52 + }
53 +
54 + @Override
55 + public boolean exactMatch(ExtWideCommunityInt value) {
56 + return this.equals(value) &&
57 + Objects.equals(this.wCommInt, value.communityInt())
58 + && Objects.equals(this.type, value.type());
59 + }
60 +
61 + @Override
62 + public int hashCode() {
63 + return Objects.hash(wCommInt, type);
64 + }
65 +
66 + @Override
67 + public boolean equals(Object obj) {
68 + if (this == obj) {
69 + return true;
70 + }
71 + if (obj instanceof DefaultExtWideCommunityInt) {
72 + DefaultExtWideCommunityInt that = (DefaultExtWideCommunityInt) obj;
73 + return Objects.equals(wCommInt, that.communityInt())
74 + && Objects.equals(this.type, that.type());
75 + }
76 + return false;
77 + }
78 +
79 + @Override
80 + public String toString() {
81 + return toStringHelper(this)
82 + .add("value", wCommInt.toString())
83 + .add("type", type.toString())
84 + .toString();
85 + }
86 +
87 + /**
88 + * Builder class for wide community value rule.
89 + */
90 + public static class Builder implements ExtWideCommunityInt.Builder {
91 + private List<Integer> wCommInt = new ArrayList<>();
92 + private ExtType type;
93 +
94 + @Override
95 + public Builder setwCommInt(Integer wCommInt) {
96 + this.wCommInt.add(wCommInt);
97 + return this;
98 + }
99 +
100 + @Override
101 + public Builder setType(ExtType type) {
102 + this.type = type;
103 + return this;
104 + }
105 +
106 + @Override
107 + public ExtWideCommunityInt build() {
108 + checkNotNull(wCommInt, "value cannot be null");
109 + return new DefaultExtWideCommunityInt(wCommInt, type);
110 + }
111 + }
112 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue Dscp value class.
22 + */
23 +public interface ExtDscpValue extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the dscp value operator value list.
34 + *
35 + * @return the dscp value operator value list
36 + */
37 + List<ExtOperatorValue> dscpValue();
38 +
39 + /**
40 + * Returns whether this dscp value list is an exact match to the dscp value list given
41 + * in the argument.
42 + *
43 + * @param dscpValue other dscp value to match against
44 + * @return true if the dscp value list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtDscpValue dscpValue);
47 +
48 + /**
49 + * A dscp value extended builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the dscp operator value to this object.
63 + *
64 + * @param dscpValue the dscp value
65 + * @return this the builder object
66 + */
67 + Builder setDscpValue(List<ExtOperatorValue> dscpValue);
68 +
69 + /**
70 + * Builds a dscp value object.
71 + *
72 + * @return a dscp value object.
73 + */
74 + ExtDscpValue build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.base.MoreObjects;
19 +
20 +import java.util.ArrayList;
21 +import java.util.List;
22 +import java.util.Objects;
23 +
24 +/**
25 + * Representation of Multi value flow container having custom rules.
26 + */
27 +public final class ExtFlowContainer {
28 +
29 + private List<ExtFlowTypes> container = new ArrayList<>();
30 + private String deviceId;
31 +
32 + /**
33 + * Creates an object of type ExtFlowContainer.
34 + */
35 + public ExtFlowContainer(List<ExtFlowTypes> container) {
36 + this.container = container;
37 + }
38 +
39 + /**
40 + * Returns the ExtFlowContainer by setting its value.
41 + *
42 + * @return ExtFlowContainer
43 + */
44 + public static ExtFlowContainer of(List<ExtFlowTypes> container) {
45 + return new ExtFlowContainer(container);
46 + }
47 +
48 + /**
49 + * Returns the list of ExtFlowTypes value.
50 + *
51 + * @return list of ExtFlowTypes
52 + */
53 + public List<ExtFlowTypes> container() {
54 + return container;
55 + }
56 +
57 + /**
58 + * Returns the device Id.
59 + *
60 + * @return deviceId
61 + */
62 + public String deviceId() {
63 + return deviceId;
64 + }
65 +
66 + /**
67 + * Adds the flow type to the container list.
68 + *
69 + * @param obj of ExtFlowTypes type
70 + */
71 + public void add(ExtFlowTypes obj) {
72 + container.add(obj);
73 + }
74 +
75 + /**
76 + * Removes the flow type from the container list.
77 + *
78 + * @param obj of ExtFlowTypes type
79 + */
80 + public void remove(ExtFlowTypes obj) {
81 + container.remove(obj);
82 + }
83 +
84 + /**
85 + * Sets the device Id to this container.
86 + *
87 + * @param deviceId to be set to this container
88 + */
89 + public void setDeviceId(String deviceId) {
90 + this.deviceId = deviceId;
91 + }
92 +
93 + @Override
94 + public int hashCode() {
95 + return Objects.hash(container);
96 + }
97 +
98 + @Override
99 + public boolean equals(Object obj) {
100 + if (this == obj) {
101 + return true;
102 + }
103 + if (!(obj instanceof ExtFlowContainer)) {
104 + return false;
105 + }
106 + final ExtFlowContainer other = (ExtFlowContainer) obj;
107 + return Objects.equals(this.container, other.container)
108 + && Objects.equals(this.deviceId, other.deviceId);
109 + }
110 +
111 + @Override
112 + public String toString() {
113 + return MoreObjects.toStringHelper(this)
114 + .add("container", container)
115 + .add("deviceId", deviceId)
116 + .toString();
117 + }
118 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Representation of BgpFlow container having custom rules.
20 + */
21 +public interface ExtFlowTypes {
22 +
23 + /**
24 + * Bgp types.
25 + */
26 + public enum ExtType {
27 +
28 + /** Extended flow rule key. */
29 + EXT_FLOW_RULE_KEY(0),
30 +
31 + /** IPv4 destination address. */
32 + IPV4_DST_PFX(1),
33 +
34 + /** IPv4 source address. */
35 + IPV4_SRC_PFX(2),
36 +
37 + /** IP protocol list. */
38 + IP_PROTO_LIST(3),
39 +
40 + /** Input port list. */
41 + IN_PORT_LIST(4),
42 +
43 + /** Destination port list. */
44 + DST_PORT_LIST(5),
45 +
46 + /** Source port list. */
47 + SRC_PORT_LIST(6),
48 +
49 + /** ICMP type list. */
50 + ICMP_TYPE_LIST(7),
51 +
52 + /** ICMP code list. */
53 + ICMP_CODE_LIST(8),
54 +
55 + /** TCP flag list. */
56 + TCP_FLAG_LIST(9),
57 +
58 + /** Packet length list. */
59 + PACKET_LENGTH_LIST(10),
60 +
61 + /** DSCP Value component. */
62 + DSCP_VALUE_LIST(11),
63 +
64 + /** Fragment list. */
65 + FRAGMENT_LIST(12),
66 +
67 + /** Wide community flags. */
68 + WIDE_COMM_FLAGS(13),
69 +
70 + /** Wide community hop count. */
71 + WIDE_COMM_HOP_COUNT(14),
72 +
73 + /** Wide community community attribute. */
74 + WIDE_COMM_COMMUNITY(15),
75 +
76 + /** Wide community context AS. */
77 + WIDE_COMM_CONTEXT_AS(16),
78 +
79 + /** Wide community local AS. */
80 + WIDE_COMM_LOCAL_AS(17),
81 +
82 + /** Wide community target prefixes. */
83 + WIDE_COMM_TARGET(18),
84 +
85 + /** Wide community extended target prefixes. */
86 + WIDE_COMM_EXT_TARGET(19),
87 +
88 + /** Wide community parameter. */
89 + WIDE_COMM_PARAMETER(20),
90 +
91 + /** Traffic filtering actions. */
92 +
93 + TRAFFIC_RATE(0x8006),
94 + TRAFFIC_ACTION(0x8007),
95 + TRAFFIC_REDIRECT(0x8008),
96 + TRAFFIC_MARKING(0x8009);
97 +
98 + private int type;
99 +
100 + /**
101 + * Creates a new type.
102 + *
103 + * @param type type code
104 + */
105 + ExtType(int type) {
106 + this.type = type;
107 + }
108 +
109 + /**
110 + * Returns the type object for this type code.
111 + *
112 + * @return ExtType object
113 + */
114 + public int type() {
115 + return (type);
116 + }
117 + }
118 +
119 + ExtType type();
120 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue Fragment value list class.
22 + */
23 +public interface ExtFragment extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the fragment operator value list.
34 + *
35 + * @return the fragment operator value list
36 + */
37 + List<ExtOperatorValue> fragment();
38 +
39 + /**
40 + * Returns whether this fragment value list is an exact match to the fragment value list given
41 + * in the argument.
42 + *
43 + * @param fragment other fragment value to match against
44 + * @return true if the fragment value list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtFragment fragment);
47 +
48 + /**
49 + * Extended fragment value builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the fragment operator value to this object.
63 + *
64 + * @param fragment the fragment value
65 + * @return this the builder object
66 + */
67 + Builder setFragment(List<ExtOperatorValue> fragment);
68 +
69 + /**
70 + * Builds a fragment value object.
71 + *
72 + * @return a fragment value object.
73 + */
74 + ExtFragment build();
75 + }
76 +}
77 +
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue ICMP code class.
22 + */
23 +public interface ExtIcmpCode extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the Icmp code operator value list.
34 + *
35 + * @return the Icmp code operator value list
36 + */
37 + List<ExtOperatorValue> icmpCode();
38 +
39 + /**
40 + * Returns whether this Icmp code list is an exact match to the Icmp code list given
41 + * in the argument.
42 + *
43 + * @param icmpCode other Icmp code to match against
44 + * @return true if the Icmp code list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtIcmpCode icmpCode);
47 +
48 + /**
49 + * An Icmp code extension builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the Icmp code operator value to this object.
63 + *
64 + * @param icmpCode the Icmp code operator value combination
65 + * @return this the builder object
66 + */
67 + Builder setIcmpCode(List<ExtOperatorValue> icmpCode);
68 +
69 + /**
70 + * Builds a Icmp code object.
71 + *
72 + * @return a Tcmp code object.
73 + */
74 + ExtIcmpCode build();
75 + }
76 +}
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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue ICMP type class.
22 + */
23 +public interface ExtIcmpType extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the Icmp type operator value list.
34 + *
35 + * @return the Icmp type operator value list
36 + */
37 + List<ExtOperatorValue> icmpType();
38 +
39 + /**
40 + * Returns whether this Icmp type list is an exact match to the Icmp type list given
41 + * in the argument.
42 + *
43 + * @param icmpType other Icmp type to match against
44 + * @return true if the Icmp type list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtIcmpType icmpType);
47 +
48 + /**
49 + * An Icmp type extension builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the Icmp type operator value to this object.
63 + *
64 + * @param icmpType the Icmp type operator value combination
65 + * @return this the builder object
66 + */
67 + Builder setIcmpType(List<ExtOperatorValue> icmpType);
68 +
69 + /**
70 + * Builds a Icmp type object.
71 + *
72 + * @return a Tcmp type object.
73 + */
74 + ExtIcmpType build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue Ip protocol class.
22 + */
23 +public interface ExtIpProtocol extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the Ip protocol operator value list.
34 + *
35 + * @return the Ip protocol operator value list
36 + */
37 + List<ExtOperatorValue> ipProtocol();
38 +
39 + /**
40 + * Returns whether this Ip protocol list is an exact match to the Ip protocol list given
41 + * in the argument.
42 + *
43 + * @param ipProto other Ip protocols list to match against
44 + * @return true if the Ip protocols list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtIpProtocol ipProto);
47 +
48 + /**
49 + * Ip protocol extension builder.
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Adds the Ip protocol operator value to this object.
63 + *
64 + * @param ipProto is the operator-value combination
65 + * @return this the builder object
66 + */
67 + Builder setIpProtocol(List<ExtOperatorValue> ipProto);
68 +
69 + /**
70 + * Builds a Ip protocol object.
71 + *
72 + * @return a Ip protocol object.
73 + */
74 + ExtIpProtocol build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Ext flwo key name class.
20 + */
21 +public interface ExtKeyName extends ExtFlowTypes {
22 +
23 + /**
24 + * Returns the ExtType.
25 + *
26 + * @return the ExtType
27 + */
28 + ExtType type();
29 +
30 + /**
31 + * Returns the key name identifier for the flow.
32 + *
33 + * @return the key name
34 + */
35 + String keyName();
36 +
37 + /**
38 + * Returns whether this key name is an exact match to the key name given
39 + * in the argument.
40 + *
41 + * @param key other key name to match against
42 + * @return true if the key name are an exact match, otherwise false
43 + */
44 + boolean exactMatch(ExtKeyName key);
45 +
46 + /**
47 + * A key name value list builder..
48 + */
49 + interface Builder {
50 +
51 + /**
52 + * Assigns the ExtType to this object.
53 + *
54 + * @param type extended type
55 + * @return this the builder object
56 + */
57 + Builder setType(ExtType type);
58 +
59 + /**
60 + * Assigns the key name to this object.
61 + *
62 + * @param key the key name
63 + * @return this the builder object
64 + */
65 + Builder setKeyName(String key);
66 +
67 + /**
68 + * Builds a key name object.
69 + *
70 + * @return a key name object.
71 + */
72 + ExtKeyName build();
73 + }
74 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.base.MoreObjects;
19 +import org.slf4j.Logger;
20 +import org.slf4j.LoggerFactory;
21 +
22 +import java.util.Arrays;
23 +import java.util.Objects;
24 +
25 +/**
26 + * Flow specification type operator and value implementation.
27 + */
28 +public class ExtOperatorValue {
29 +
30 + protected static final Logger log = LoggerFactory.getLogger(ExtOperatorValue.class);
31 +
32 + private final byte option;
33 + private final byte[] value;
34 +
35 + /**
36 + * Creates an object of type ExtOperatorValue.
37 + *
38 + * @param option for a specific flow type
39 + * @param value for a specific flow type
40 + */
41 + public ExtOperatorValue(byte option, byte[] value) {
42 + this.option = option;
43 + this.value = Arrays.copyOf(value, value.length);
44 + }
45 +
46 + /**
47 + * Returns option of the flow type.
48 + *
49 + * @return option of the flow type
50 + */
51 + public byte option() {
52 + return option;
53 + }
54 +
55 + /**
56 + * Returns value of the flow type.
57 + *
58 + * @return value of the flow type
59 + */
60 + public byte[] value() {
61 + return value;
62 + }
63 +
64 + @Override
65 + public int hashCode() {
66 + return Objects.hash(option, Arrays.hashCode(value));
67 + }
68 +
69 + @Override
70 + public boolean equals(Object obj) {
71 + if (this == obj) {
72 + return true;
73 + }
74 + if (obj instanceof ExtOperatorValue) {
75 + ExtOperatorValue other = (ExtOperatorValue) obj;
76 + return Objects.equals(this.option, other.option) && Arrays.equals(this.value, other.value);
77 + }
78 + return false;
79 + }
80 +
81 + @Override
82 + public String toString() {
83 + return MoreObjects.toStringHelper(getClass()).add("option", option).add("value", value).toString();
84 + }
85 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue packet length list class.
22 + */
23 +public interface ExtPacketLength extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the packet length operator value list.
34 + *
35 + * @return the packet length operator value list
36 + */
37 + List<ExtOperatorValue> packetLength();
38 +
39 + /**
40 + * Returns whether this packet length list is an exact match to the packet length list given
41 + * in the argument.
42 + *
43 + * @param packetLength other packet length to match against
44 + * @return true if the packet length list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtPacketLength packetLength);
47 +
48 + /**
49 + * A packet length extended builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the packet length list to this object.
63 + *
64 + * @param packetLength the packet length
65 + * @return this the builder object
66 + */
67 + Builder setPacketLength(List<ExtOperatorValue> packetLength);
68 +
69 + /**
70 + * Builds a packet length object.
71 + *
72 + * @return a packet length object.
73 + */
74 + ExtPacketLength build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue port class.
22 + */
23 +public interface ExtPort extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the port operator value list.
34 + *
35 + * @return the port operator value list
36 + */
37 + List<ExtOperatorValue> port();
38 +
39 + /**
40 + * Returns whether this port list is an exact match to the port list given
41 + * in the argument.
42 + *
43 + * @param port other port to match against
44 + * @return true if the port list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtPort port);
47 +
48 + /**
49 + * An extended port extension builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the port list operator value to this object.
63 + *
64 + * @param port is the operator-value combination
65 + * @return this the builder object
66 + */
67 + Builder setPort(List<ExtOperatorValue> port);
68 +
69 + /**
70 + * Builds a port object.
71 + *
72 + * @return a port object.
73 + */
74 + ExtPort build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import org.onlab.packet.IpPrefix;
19 +
20 +import java.util.List;
21 +
22 +/**
23 + * Ext Prefix class.
24 + */
25 +public interface ExtPrefix extends ExtFlowTypes {
26 +
27 + /**
28 + * Returns the ExtType.
29 + *
30 + * @return the ExtType
31 + */
32 + ExtType type();
33 +
34 + /**
35 + * Returns the prefix list.
36 + *
37 + * @return the IpPrefix list
38 + */
39 + List<IpPrefix> prefix();
40 +
41 + /**
42 + * Returns whether this prefix list is an exact match to the prefix list given
43 + * in the argument.
44 + *
45 + * @param prefix other prefix to match against
46 + * @return true if the prefix are an exact match, otherwise false
47 + */
48 + boolean exactMatch(ExtPrefix prefix);
49 +
50 + /**
51 + * A prefix builder..
52 + */
53 + interface Builder {
54 +
55 + /**
56 + * Assigns the ExtType to this object.
57 + *
58 + * @param type the prefix
59 + * @return this the builder object
60 + */
61 + Builder setType(ExtType type);
62 +
63 + /**
64 + * Add the prefix to this object.
65 + *
66 + * @param prefix the prefix
67 + * @return this the builder object
68 + */
69 + Builder setPrefix(IpPrefix prefix);
70 +
71 + /**
72 + * Builds a prefix object.
73 + *
74 + * @return a port chain.
75 + */
76 + ExtPrefix build();
77 + }
78 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Ext target prefix class class.
20 + */
21 +public interface ExtTarget extends ExtFlowTypes {
22 +
23 + /**
24 + * Returns the ExtType.
25 + *
26 + * @return the ExtType
27 + */
28 + ExtType type();
29 +
30 + /**
31 + * Returns the local speaker prefix list.
32 + *
33 + * @return the prefix list
34 + */
35 + ExtPrefix localSpeaker();
36 +
37 + /**
38 + * Returns the remote speaker prefix list.
39 + *
40 + * @return the prefix list
41 + */
42 + ExtPrefix remoteSpeaker();
43 +
44 + /**
45 + * Returns whether this prefix list is an exact match to the prefix list given
46 + * in the argument.
47 + *
48 + * @param prefix other prefix to match against
49 + * @return true if the prefix are an exact match, otherwise false
50 + */
51 + boolean exactMatch(ExtTarget prefix);
52 +
53 + /**
54 + * A prefix builder..
55 + */
56 + interface Builder {
57 +
58 + /**
59 + * Assigns the ExtType to this object.
60 + *
61 + * @param type the prefix
62 + * @return this the builder object
63 + */
64 + Builder setType(ExtType type);
65 +
66 + /**
67 + * Add the local speaker prefix to this object.
68 + *
69 + * @param localSpeaker list of local speakers
70 + * @return this the builder object
71 + */
72 + Builder setLocalSpeaker(ExtPrefix localSpeaker);
73 +
74 + /**
75 + * Add the remote speaker prefix to this object.
76 + *
77 + * @param remoteSpeaker list of remote speakers
78 + * @return this the builder object
79 + */
80 + Builder setRemoteSpeaker(ExtPrefix remoteSpeaker);
81 +
82 + /**
83 + * Builds a prefix object.
84 + *
85 + * @return a port chain.
86 + */
87 + ExtTarget build();
88 + }
89 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended multivalue Tcp Flags list class.
22 + */
23 +public interface ExtTcpFlag extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the Tcp flag Extended multivalue.
34 + *
35 + * @return the Tcp flag Extended multivalue
36 + */
37 + List<ExtOperatorValue> tcpFlag();
38 +
39 + /**
40 + * Returns whether this Tcp flag list is an exact match to the Tcp flag list given
41 + * in the argument.
42 + *
43 + * @param tcpFlag other Tcp flag to match against
44 + * @return true if the Tcp flag list are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtTcpFlag tcpFlag);
47 +
48 + /**
49 + * A Tcp flag extended builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the Tcp flag operator value to this object.
63 + *
64 + * @param tcpFlag the Tcp flag
65 + * @return this the builder object
66 + */
67 + Builder setTcpFlag(List<ExtOperatorValue> tcpFlag);
68 +
69 + /**
70 + * Builds a Tcp flag object.
71 + *
72 + * @return a Tcp flag object.
73 + */
74 + ExtTcpFlag build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Extended flow traffic action class.
20 + */
21 +public interface ExtTrafficAction extends ExtFlowTypes {
22 +
23 + /**
24 + * Returns the ExtType.
25 + *
26 + * @return the ExtType
27 + */
28 + ExtType type();
29 +
30 + /**
31 + * Returns the terminal action.
32 + *
33 + * @return the terminal action is set or not
34 + */
35 + boolean terminal();
36 +
37 + /**
38 + * Returns the traffic sampling.
39 + *
40 + * @return the traffic sampling set or not
41 + */
42 + boolean sample();
43 +
44 + /**
45 + * Returns the traffic action to be taken is rpd.
46 + *
47 + * @return the traffic action rpd is set or not
48 + */
49 + boolean rpd();
50 +
51 + /**
52 + * Returns whether this traffic action is an exact match to the traffic action given
53 + * in the argument.
54 + *
55 + * @param trafficAction other traffic action to match against
56 + * @return true if the traffic action are an exact match, otherwise false
57 + */
58 + boolean exactMatch(ExtTrafficAction trafficAction);
59 +
60 + /**
61 + * A traffic action builder..
62 + */
63 + interface Builder {
64 +
65 + /**
66 + * Assigns the ExtType to this object.
67 + *
68 + * @param type extended type
69 + * @return this the builder object
70 + */
71 + Builder setType(ExtType type);
72 +
73 + /**
74 + * Assigns the terminal action to this object.
75 + *
76 + * @param terminal action
77 + * @return this the builder object
78 + */
79 + Builder setTerminal(boolean terminal);
80 +
81 + /**
82 + * Assigns the traffic sampling to this object.
83 + *
84 + * @param sample to be done or not
85 + * @return this the builder object
86 + */
87 + Builder setSample(boolean sample);
88 +
89 + /**
90 + * Assigns the traffic action rpd to this object.
91 + *
92 + * @param rpd rpd or not
93 + * @return this the builder object
94 + */
95 + Builder setRpd(boolean rpd);
96 +
97 + /**
98 + * Builds a traffic action object.
99 + *
100 + * @return a traffic action object.
101 + */
102 + ExtTrafficAction build();
103 + }
104 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Extended traffic marking class.
20 + */
21 +public interface ExtTrafficMarking extends ExtFlowTypes {
22 +
23 + /**
24 + * Returns the ExtType.
25 + *
26 + * @return the ExtType
27 + */
28 + ExtType type();
29 +
30 + /**
31 + * Returns the traffic marking DSCP value.
32 + *
33 + * @return the marking rule
34 + */
35 + byte marking();
36 +
37 + /**
38 + * Returns whether this traffic marking is an exact match to the traffic marking given
39 + * in the argument.
40 + *
41 + * @param marking other traffic marking to match against
42 + * @return true if the traffic marking are an exact match, otherwise false
43 + */
44 + boolean exactMatch(ExtTrafficMarking marking);
45 +
46 + /**
47 + * A traffic marking builder..
48 + */
49 + interface Builder {
50 +
51 + /**
52 + * Assigns the ExtType to this object.
53 + *
54 + * @param type extended type
55 + * @return this the builder object
56 + */
57 + Builder setType(ExtType type);
58 +
59 + /**
60 + * Assigns the traffic marking to this object.
61 + *
62 + * @param marking the marking value
63 + * @return this the builder object
64 + */
65 + Builder setMarking(byte marking);
66 +
67 + /**
68 + * Builds a traffic marking object.
69 + *
70 + * @return a marking value object.
71 + */
72 + ExtTrafficMarking build();
73 + }
74 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Extended flow traffic rate class.
20 + */
21 +public interface ExtTrafficRate extends ExtFlowTypes {
22 +
23 + /**
24 + * Returns the ExtType.
25 + *
26 + * @return the ExtType
27 + */
28 + ExtType type();
29 +
30 + /**
31 + * Returns the AS number.
32 + *
33 + * @return the 2 byte ASN
34 + */
35 + Short asn();
36 +
37 + /**
38 + * Returns the traffic rate.
39 + *
40 + * @return the floating point traffic rate
41 + */
42 + Float rate();
43 +
44 + /**
45 + * Returns whether this traffic rate is an exact match to the traffic rate given
46 + * in the argument.
47 + *
48 + * @param trafficRate other traffic rate to match against
49 + * @return true if the traffic rate list are an exact match, otherwise false
50 + */
51 + boolean exactMatch(ExtTrafficRate trafficRate);
52 +
53 + /**
54 + * A traffic rate builder..
55 + */
56 + interface Builder {
57 +
58 + /**
59 + * Assigns the ExtType to this object.
60 + *
61 + * @param type extended type
62 + * @return this the builder object
63 + */
64 + Builder setType(ExtType type);
65 +
66 + /**
67 + * Assigns the AS number to this object.
68 + *
69 + * @param asn the ASN
70 + * @return this the builder object
71 + */
72 + Builder setAsn(short asn);
73 +
74 + /**
75 + * Assigns the traffic rate to this object.
76 + *
77 + * @param rate in floating point number bytes per second
78 + * @return this the builder object
79 + */
80 + Builder setRate(float rate);
81 +
82 + /**
83 + * Builds a traffic rate object.
84 + *
85 + * @return a traffic rate object.
86 + */
87 + ExtTrafficRate build();
88 + }
89 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +/**
19 + * Extended flow traffic redirect class.
20 + */
21 +public interface ExtTrafficRedirect extends ExtFlowTypes {
22 +
23 + /**
24 + * Returns the ExtType.
25 + *
26 + * @return the ExtType
27 + */
28 + ExtType type();
29 +
30 + /**
31 + * Returns the traffic redirect in human readable format.
32 + *
33 + * @return the redirect rule
34 + */
35 + String redirect();
36 +
37 + /**
38 + * Returns whether this traffic redirect is an exact match to the traffic redirect given
39 + * in the argument.
40 + *
41 + * @param redirect other traffic redirect to match against
42 + * @return true if the traffic redirect are an exact match, otherwise false
43 + */
44 + boolean exactMatch(ExtTrafficRedirect redirect);
45 +
46 + /**
47 + * A dscp value list builder..
48 + */
49 + interface Builder {
50 +
51 + /**
52 + * Assigns the ExtType to this object.
53 + *
54 + * @param type extended type
55 + * @return this the builder object
56 + */
57 + Builder setType(ExtType type);
58 +
59 + /**
60 + * Assigns the traffic redirect to this object.
61 + *
62 + * @param redirect the redirect value
63 + * @return this the builder object
64 + */
65 + Builder setRedirect(String redirect);
66 +
67 + /**
68 + * Builds a traffic redirect object.
69 + *
70 + * @return a redirect value object.
71 + */
72 + ExtTrafficRedirect build();
73 + }
74 +}
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Extended wide community integer class.
22 + */
23 +public interface ExtWideCommunityInt extends ExtFlowTypes {
24 +
25 + /**
26 + * Returns the ExtType.
27 + *
28 + * @return the ExtType
29 + */
30 + ExtType type();
31 +
32 + /**
33 + * Returns the wide community integer list.
34 + *
35 + * @return the wide community integer list
36 + */
37 + List<Integer> communityInt();
38 +
39 + /**
40 + * Returns whether this wide community integer is an exact match to the wide community int given
41 + * in the argument.
42 + *
43 + * @param wCommInt other wide community integer to match against
44 + * @return true if the wide community integer are an exact match, otherwise false
45 + */
46 + boolean exactMatch(ExtWideCommunityInt wCommInt);
47 +
48 + /**
49 + * A wide community integer list builder..
50 + */
51 + interface Builder {
52 +
53 + /**
54 + * Assigns the ExtType to this object.
55 + *
56 + * @param type extended type
57 + * @return this the builder object
58 + */
59 + Builder setType(ExtType type);
60 +
61 + /**
62 + * Assigns the wide community integer to this object.
63 + *
64 + * @param wCommInt the wide community integer
65 + * @return this the builder object
66 + */
67 + Builder setwCommInt(Integer wCommInt);
68 +
69 + /**
70 + * Builds a wide community integer object.
71 + *
72 + * @return a wide community integer value object.
73 + */
74 + ExtWideCommunityInt build();
75 + }
76 +}
1 +/*
2 + * Copyright 2016-present 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 +
17 +/**
18 + * API bundle.
19 + */
20 +package org.onosproject.flowapi;
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended dscp value attribute.
26 + */
27 +public class DefaultExtDscpValueTest {
28 +
29 + private List<ExtOperatorValue> dscpValue = new ArrayList<>();
30 + private List<ExtOperatorValue> dscpValue1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.DSCP_VALUE_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + dscpValue.add(opVal);
38 + dscpValue1.add(opVal1);
39 + DefaultExtDscpValue data = new DefaultExtDscpValue(dscpValue, type);
40 + DefaultExtDscpValue sameAsData = new DefaultExtDscpValue(dscpValue, type);
41 + DefaultExtDscpValue diffData = new DefaultExtDscpValue(dscpValue1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended fragment value attribute.
26 + */
27 +public class DefaultExtFragmentTest {
28 +
29 + private List<ExtOperatorValue> fragment = new ArrayList<>();
30 + private List<ExtOperatorValue> fragment1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.FRAGMENT_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + fragment.add(opVal);
38 + fragment1.add(opVal1);
39 + DefaultExtFragment data = new DefaultExtFragment(fragment, type);
40 + DefaultExtFragment sameAsData = new DefaultExtFragment(fragment, type);
41 + DefaultExtFragment diffData = new DefaultExtFragment(fragment1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended icmp code value attribute.
26 + */
27 +public class DefaultExtIcmpCodeTest {
28 +
29 + private List<ExtOperatorValue> icmpCode = new ArrayList<>();
30 + private List<ExtOperatorValue> icmpCode1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.ICMP_CODE_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + icmpCode.add(opVal);
38 + icmpCode1.add(opVal1);
39 + DefaultExtIcmpCode data = new DefaultExtIcmpCode(icmpCode, type);
40 + DefaultExtIcmpCode sameAsData = new DefaultExtIcmpCode(icmpCode, type);
41 + DefaultExtIcmpCode diffData = new DefaultExtIcmpCode(icmpCode1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 + import com.google.common.testing.EqualsTester;
19 + import org.junit.Test;
20 +
21 + import java.util.ArrayList;
22 + import java.util.List;
23 +
24 +/**
25 + * Test for extended icmp type value attribute.
26 + */
27 +public class DefaultExtIcmpTypeTest {
28 +
29 + private List<ExtOperatorValue> icmpType = new ArrayList<>();
30 + private List<ExtOperatorValue> icmpType1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.ICMP_TYPE_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + icmpType.add(opVal);
38 + icmpType1.add(opVal1);
39 + DefaultExtIcmpType data = new DefaultExtIcmpType(icmpType, type);
40 + DefaultExtIcmpType sameAsData = new DefaultExtIcmpType(icmpType, type);
41 + DefaultExtIcmpType diffData = new DefaultExtIcmpType(icmpType1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended icmp type value attribute.
26 + */
27 +public class DefaultExtIpProtocolTest {
28 +
29 + private List<ExtOperatorValue> ipProtocol = new ArrayList<>();
30 + private List<ExtOperatorValue> ipProtocol1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.IP_PROTO_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + ipProtocol.add(opVal);
38 + ipProtocol1.add(opVal1);
39 + DefaultExtIpProtocol data = new DefaultExtIpProtocol(ipProtocol, type);
40 + DefaultExtIpProtocol sameAsData = new DefaultExtIpProtocol(ipProtocol, type);
41 + DefaultExtIpProtocol diffData = new DefaultExtIpProtocol(ipProtocol1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +/**
22 + * Test for extended key name value attribute.
23 + */
24 +public class DefaultExtKeyNameTest {
25 +
26 + private String keyName = new String("hello");
27 + private String keyName1 = new String("Hi");
28 +
29 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.EXT_FLOW_RULE_KEY;
30 +
31 + @Test
32 + public void basics() {
33 +
34 + DefaultExtKeyName data = new DefaultExtKeyName(keyName, type);
35 + DefaultExtKeyName sameAsData = new DefaultExtKeyName(keyName, type);
36 + DefaultExtKeyName diffData = new DefaultExtKeyName(keyName1, type);
37 + new EqualsTester().addEqualityGroup(data, sameAsData)
38 + .addEqualityGroup(diffData).testEquals();
39 + }
40 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended packet length value attribute.
26 + */
27 +public class DefaultExtPacketLengthTest {
28 +
29 + private List<ExtOperatorValue> packetLength = new ArrayList<>();
30 + private List<ExtOperatorValue> packetLength1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.PACKET_LENGTH_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + packetLength.add(opVal);
38 + packetLength1.add(opVal1);
39 + DefaultExtPacketLength data = new DefaultExtPacketLength(packetLength, type);
40 + DefaultExtPacketLength sameAsData = new DefaultExtPacketLength(packetLength, type);
41 + DefaultExtPacketLength diffData = new DefaultExtPacketLength(packetLength1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 + import com.google.common.testing.EqualsTester;
19 + import org.junit.Test;
20 +
21 + import java.util.ArrayList;
22 + import java.util.List;
23 +
24 +/**
25 + * Test for extended icmp type value attribute.
26 + */
27 +public class DefaultExtPortTest {
28 +
29 + private List<ExtOperatorValue> port = new ArrayList<>();
30 + private List<ExtOperatorValue> port1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.IN_PORT_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + port.add(opVal);
38 + port1.add(opVal1);
39 + DefaultExtPort data = new DefaultExtPort(port, type);
40 + DefaultExtPort sameAsData = new DefaultExtPort(port, type);
41 + DefaultExtPort diffData = new DefaultExtPort(port1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 + import com.google.common.testing.EqualsTester;
19 + import org.junit.Test;
20 + import org.onlab.packet.IpAddress;
21 + import org.onlab.packet.IpPrefix;
22 +
23 + import java.util.ArrayList;
24 + import java.util.List;
25 +
26 +/**
27 + * Test for extended prefix value attribute.
28 + */
29 +public class DefaultExtPrefixTest {
30 +
31 + private List<IpPrefix> prefix = new ArrayList<>();
32 + private List<IpPrefix> prefix1 = new ArrayList<>();
33 + private IpAddress address = IpAddress.valueOf("192.168.1.1");
34 + private IpPrefix opVal = IpPrefix.valueOf(address, 16);
35 + private IpPrefix opVal1 = IpPrefix.valueOf(address, 20);
36 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.IPV4_DST_PFX;
37 +
38 + @Test
39 + public void basics() {
40 + prefix.add(opVal);
41 + prefix1.add(opVal1);
42 + DefaultExtPrefix data = new DefaultExtPrefix(prefix, type);
43 + DefaultExtPrefix sameAsData = new DefaultExtPrefix(prefix, type);
44 + DefaultExtPrefix diffData = new DefaultExtPrefix(prefix1, type);
45 + new EqualsTester().addEqualityGroup(data, sameAsData)
46 + .addEqualityGroup(diffData).testEquals();
47 + }
48 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +import org.onlab.packet.IpAddress;
21 +import org.onlab.packet.IpPrefix;
22 +
23 +import java.util.ArrayList;
24 +import java.util.List;
25 +
26 +/**
27 + * Test for extended t value target ttribute.
28 + */
29 +public class DefaultExtTargetTest {
30 + private List<IpPrefix> prefix = new ArrayList<>();
31 + private List<IpPrefix> prefix1 = new ArrayList<>();
32 + private IpAddress address = IpAddress.valueOf("192.168.1.1");
33 + private IpPrefix opVal = IpPrefix.valueOf(address, 16);
34 + private IpPrefix opVal1 = IpPrefix.valueOf(address, 20);
35 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.IPV4_DST_PFX;
36 + private ExtFlowTypes.ExtType typeThis = ExtFlowTypes.ExtType.WIDE_COMM_TARGET;
37 +
38 + @Test
39 + public void basics() {
40 + prefix.add(opVal);
41 + prefix1.add(opVal1);
42 + DefaultExtPrefix localSpeaker = new DefaultExtPrefix(prefix, type);
43 + DefaultExtPrefix remoteSpeaker = new DefaultExtPrefix(prefix, type);
44 + DefaultExtPrefix localSpeaker1 = new DefaultExtPrefix(prefix1, type);
45 + DefaultExtPrefix remoteSpeaker1 = new DefaultExtPrefix(prefix1, type);
46 +
47 + DefaultExtTarget data = new DefaultExtTarget(localSpeaker, remoteSpeaker, typeThis);
48 + DefaultExtTarget sameAsData = new DefaultExtTarget(localSpeaker, remoteSpeaker, typeThis);
49 + DefaultExtTarget diffData = new DefaultExtTarget(localSpeaker1, remoteSpeaker1, typeThis);
50 + new EqualsTester().addEqualityGroup(data, sameAsData)
51 + .addEqualityGroup(diffData).testEquals();
52 + }
53 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended tcp flag value attribute.
26 + */
27 +public class DefaultExtTcpFlagTest {
28 +
29 + private List<ExtOperatorValue> tcpFlag = new ArrayList<>();
30 + private List<ExtOperatorValue> tcpFlag1 = new ArrayList<>();
31 + private ExtOperatorValue opVal = new ExtOperatorValue((byte) 1, new byte[100]);
32 + private ExtOperatorValue opVal1 = new ExtOperatorValue((byte) 1, new byte[200]);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.TCP_FLAG_LIST;
34 +
35 + @Test
36 + public void basics() {
37 + tcpFlag.add(opVal);
38 + tcpFlag1.add(opVal1);
39 + DefaultExtTcpFlag data = new DefaultExtTcpFlag(tcpFlag, type);
40 + DefaultExtTcpFlag sameAsData = new DefaultExtTcpFlag(tcpFlag, type);
41 + DefaultExtTcpFlag diffData = new DefaultExtTcpFlag(tcpFlag1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +/**
22 + * Test for extended traffic action value attribute.
23 + */
24 +public class DefaultExtTrafficActionTest {
25 +
26 + private boolean terminal = true;
27 + private boolean sample = true;
28 + private boolean rpd = true;
29 + private boolean terminal1 = false;
30 + private boolean sample1 = false;
31 + private boolean rpd1 = false;
32 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.TRAFFIC_ACTION;
33 +
34 + @Test
35 + public void basics() {
36 +
37 + DefaultExtTrafficAction data = new DefaultExtTrafficAction(terminal, sample, rpd, type);
38 + DefaultExtTrafficAction sameAsData = new DefaultExtTrafficAction(terminal, sample, rpd, type);
39 + DefaultExtTrafficAction diffData = new DefaultExtTrafficAction(terminal1, sample1, rpd1, type);
40 + new EqualsTester().addEqualityGroup(data, sameAsData)
41 + .addEqualityGroup(diffData).testEquals();
42 + }
43 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +/**
22 + * Test for extended traffic marking value attribute.
23 + */
24 +public class DefaultExtTrafficMarkingTest {
25 +
26 + private byte marking = 01;
27 + private byte marking1 = 02;
28 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.TRAFFIC_MARKING;
29 +
30 + @Test
31 + public void basics() {
32 + DefaultExtTrafficMarking data = new DefaultExtTrafficMarking(marking, type);
33 + DefaultExtTrafficMarking sameAsData = new DefaultExtTrafficMarking(marking, type);
34 + DefaultExtTrafficMarking diffData = new DefaultExtTrafficMarking(marking1, type);
35 + new EqualsTester().addEqualityGroup(data, sameAsData)
36 + .addEqualityGroup(diffData).testEquals();
37 + }
38 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +/**
22 + * Test for extended traffic rate value attribute.
23 + */
24 +public class DefaultExtTrafficRateTest {
25 +
26 + private Short asn = new Short((short) 1);
27 + private Float rate = new Float(1.0);
28 + private Short asn1 = new Short((short) 2);
29 + private Float rate1 = new Float(1.0);
30 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.TRAFFIC_RATE;
31 +
32 + @Test
33 + public void basics() {
34 + DefaultExtTrafficRate data = new DefaultExtTrafficRate(asn, rate, type);
35 + DefaultExtTrafficRate sameAsData = new DefaultExtTrafficRate(asn, rate, type);
36 + DefaultExtTrafficRate diffData = new DefaultExtTrafficRate(asn1, rate1, type);
37 + new EqualsTester().addEqualityGroup(data, sameAsData)
38 + .addEqualityGroup(diffData).testEquals();
39 + }
40 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +/**
22 + * Test for extended traffic redirect value attribute.
23 + */
24 +public class DefaultExtTrafficRedirectTest {
25 +
26 + String redirect = new String("vpnid1");
27 + String redirect1 = new String("vpnid2");
28 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.TRAFFIC_REDIRECT;
29 +
30 + @Test
31 + public void basics() {
32 +
33 + DefaultExtTrafficRedirect data = new DefaultExtTrafficRedirect(redirect, type);
34 + DefaultExtTrafficRedirect sameAsData = new DefaultExtTrafficRedirect(redirect, type);
35 + DefaultExtTrafficRedirect diffData = new DefaultExtTrafficRedirect(redirect1, type);
36 + new EqualsTester().addEqualityGroup(data, sameAsData)
37 + .addEqualityGroup(diffData).testEquals();
38 + }
39 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended wide community value attribute.
26 + */
27 +public class DefaultExtWideCommunityIntTest {
28 +
29 + private List<Integer> wCommInt = new ArrayList<>();
30 + private List<Integer> wCommInt1 = new ArrayList<>();
31 + private Integer opVal = new Integer(1);
32 + private Integer opVal1 = new Integer(2);
33 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.WIDE_COMM_COMMUNITY;
34 +
35 + @Test
36 + public void basics() {
37 + wCommInt.add(opVal);
38 + wCommInt1.add(opVal1);
39 + DefaultExtWideCommunityInt data = new DefaultExtWideCommunityInt(wCommInt, type);
40 + DefaultExtWideCommunityInt sameAsData = new DefaultExtWideCommunityInt(wCommInt, type);
41 + DefaultExtWideCommunityInt diffData = new DefaultExtWideCommunityInt(wCommInt1, type);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import com.google.common.testing.EqualsTester;
19 +import org.junit.Test;
20 +
21 +import java.util.ArrayList;
22 +import java.util.List;
23 +
24 +/**
25 + * Test for extended flow container value attribute.
26 + */
27 +public class ExtFlowContainerTest {
28 +
29 + private List<ExtFlowTypes> container = new ArrayList<>();
30 + private List<ExtFlowTypes> container1 = new ArrayList<>();
31 + private ExtFlowTypes.ExtType type = ExtFlowTypes.ExtType.EXT_FLOW_RULE_KEY;
32 + ExtFlowTypes val = new DefaultExtKeyName("Name", type);
33 + ExtFlowTypes val1 = new DefaultExtKeyName("Name1", type);
34 +
35 + @Test
36 + public void basics() {
37 + container.add(val);
38 + container1.add(val1);
39 + ExtFlowContainer data = new ExtFlowContainer(container);
40 + ExtFlowContainer sameAsData = new ExtFlowContainer(container);
41 + ExtFlowContainer diffData = new ExtFlowContainer(container1);
42 + new EqualsTester().addEqualityGroup(data, sameAsData)
43 + .addEqualityGroup(diffData).testEquals();
44 + }
45 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016-present 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.flowapi;
17 +
18 +import org.junit.Test;
19 +
20 +import com.google.common.testing.EqualsTester;
21 +
22 +/**
23 + * Test for ExtOperatorValue flow specification component.
24 + */
25 +public class ExtOperatorValueTest {
26 + ExtOperatorValue tlv1 = new ExtOperatorValue((byte) 1, new byte[100]);
27 + ExtOperatorValue sameAsTlv1 = new ExtOperatorValue((byte) 1, new byte[100]);
28 + ExtOperatorValue tlv2 = new ExtOperatorValue((byte) 1, new byte[200]);
29 +
30 + @Test
31 + public void testEquality() {
32 + new EqualsTester()
33 + .addEqualityGroup(tlv1, sameAsTlv1)
34 + .addEqualityGroup(tlv2)
35 + .testEquals();
36 + }
37 +}
1 +COMPILE_DEPS = [
2 + '//lib:CORE_DEPS',
3 + '//core/store/serializers:onos-core-serializers',
4 + '//apps/bgpflowspec/flowapi:onos-apps-bgpflowspec-flowapi',
5 +]
6 +
7 +osgi_jar_with_tests (
8 + name = 'onos-apps-bgpflowspec-flowmgr',
9 + deps = COMPILE_DEPS,
10 +)
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.