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