Thejaswi N K
Committed by Gerrit Code Review

BGP Route policy distribution and flow spec

Change-Id: I8903efd225a24db6ccc85a4a3148a4dd6076e042
Showing 94 changed files with 7416 additions and 4 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 com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.flow.manager.BgpFlowService;
import org.onosproject.flowapi.DefaultExtWideCommunityInt;
import org.onosproject.flowapi.ExtFlowContainer;
import org.onosproject.flowapi.ExtFlowTypes;
import org.onosproject.flowapi.ExtTrafficAction;
import org.onosproject.flowapi.ExtWideCommunityInt;
import org.onosproject.rest.AbstractWebResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.ListIterator;
import static javax.ws.rs.core.Response.Status.NOT_ACCEPTABLE;
import static javax.ws.rs.core.Response.Status.OK;
/**
* Bgp flow web resource.
*/
@Path("flow")
public class BgpFlowWebResource extends AbstractWebResource {
private BgpFlowService flowService = get(BgpFlowService.class);
protected static final String BGPFLOW = "bgp_flow";
protected static final String DEVICEID = "deviceId";
protected static final int LOCAL_PERF = 20;
private final Logger log = LoggerFactory.getLogger(BgpFlowWebResource.class);
/**
* Get the Bgp flow.
*
* @return 200 OK
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getBgpFlow() {
Boolean result = true;
//TODO
return ok(result.toString()).build();
}
/**
* Push the the Bgp flow spec.
*
* @param stream bgp flow spec in JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createBgpFlow(InputStream stream) {
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode flow = jsonTree.get(BGPFLOW);
String devId = jsonTree.get(DEVICEID).asText();
boolean status;
List<ExtFlowTypes> list;
ExtFlowContainer container;
list = codec(ExtFlowTypes.class).decode((ArrayNode) flow, this);
if (!validateRpd(list)) {
return Response.status(NOT_ACCEPTABLE).entity(Boolean.FALSE.toString()).build();
}
container = new ExtFlowContainer(list);
container.setDeviceId(devId);
status = flowService.onBgpFlowCreated(container);
Boolean isSuccess = Boolean.valueOf(status);
if (!status) {
return Response.status(NOT_ACCEPTABLE).entity(isSuccess.toString()).build();
}
return Response.status(OK).entity(isSuccess.toString()).build();
} catch (IOException e) {
log.error("Exception while parsing bgp flow.", e.toString());
throw new IllegalArgumentException(e);
}
}
/**
* Validates the rpd and flow spec classes.
*
* @param list list of types
* @return a true if the validation succeeds else false
*/
boolean validateRpd(List<ExtFlowTypes> list) {
ListIterator<ExtFlowTypes> iterator = list.listIterator();
ExtFlowTypes flow;
boolean key = false;
boolean rpd = false;
boolean nonRpd = false;
ExtTrafficAction flowAction = null;
boolean dstPfx = false;
boolean wcFlg = false;
boolean wcHop = false;
boolean wcWc = false;
boolean wcCAs = false;
boolean wcLAs = false;
boolean wcTarget = false;
boolean wcETarget = false;
boolean wcParm = false;
while (iterator.hasNext()) {
flow = iterator.next();
switch (flow.type()) {
case EXT_FLOW_RULE_KEY:
key = true;
break;
case IPV4_DST_PFX:
dstPfx = true;
break;
case IPV4_SRC_PFX:
nonRpd = true;
break;
case IP_PROTO_LIST:
nonRpd = true;
break;
case IN_PORT_LIST:
nonRpd = true;
break;
case DST_PORT_LIST:
nonRpd = true;
break;
case SRC_PORT_LIST:
nonRpd = true;
break;
case ICMP_TYPE_LIST:
nonRpd = true;
break;
case ICMP_CODE_LIST:
nonRpd = true;
break;
case TCP_FLAG_LIST:
nonRpd = true;
break;
case PACKET_LENGTH_LIST:
nonRpd = true;
break;
case DSCP_VALUE_LIST:
nonRpd = true;
break;
case FRAGMENT_LIST:
nonRpd = true;
break;
case TRAFFIC_ACTION:
flowAction = (ExtTrafficAction) flow;
if (flowAction.rpd()) {
rpd = true;
}
break;
case TRAFFIC_RATE:
nonRpd = true;
break;
case TRAFFIC_REDIRECT:
nonRpd = true;
break;
case TRAFFIC_MARKING:
nonRpd = true;
break;
case WIDE_COMM_FLAGS:
wcFlg = true;
break;
case WIDE_COMM_HOP_COUNT:
wcHop = true;
break;
case WIDE_COMM_COMMUNITY:
wcWc = true;
break;
case WIDE_COMM_CONTEXT_AS:
wcCAs = true;
break;
case WIDE_COMM_LOCAL_AS:
wcLAs = true;
break;
case WIDE_COMM_TARGET:
wcTarget = true;
break;
case WIDE_COMM_EXT_TARGET:
wcETarget = true;
break;
case WIDE_COMM_PARAMETER:
wcParm = true;
break;
default:
log.error("error: this type is not supported");
break;
}
}
if (!key) {
return false;
}
/** checking for non Rpd. */
if (!rpd) {
if (wcFlg || wcHop || wcWc
|| wcCAs || wcLAs || wcParm) {
return false;
}
}
/** checking for Rpd. */
if (nonRpd || !dstPfx || !wcFlg || !wcHop
|| !wcWc || !wcCAs || !wcLAs || !wcParm) {
return false;
}
/** If it is rpd then either of these two or both should be present.*/
if (!wcTarget && !wcETarget) {
rpd = false;
}
if (!handleRpdLocalPerf(list)) {
return false;
}
return rpd;
}
/**
* Validate and format the rpd local perf.
*
* @param list list of types
* @return a true if the validation succeeds else false
*/
boolean handleRpdLocalPerf(List<ExtFlowTypes> list) {
ListIterator<ExtFlowTypes> iterator = list.listIterator();
ExtFlowTypes flow;
ExtWideCommunityInt wcComm = null;
ExtWideCommunityInt wcParam = null;
ListIterator<Integer> wcInt = null;
int community = 0;
int param = 0;
while (iterator.hasNext()) {
flow = iterator.next();
switch (flow.type()) {
case WIDE_COMM_COMMUNITY:
wcComm = (ExtWideCommunityInt) flow;
wcInt = wcComm.communityInt().listIterator();
community = wcInt.next().intValue();
break;
case WIDE_COMM_PARAMETER:
wcParam = (ExtWideCommunityInt) flow;
wcInt = wcParam.communityInt().listIterator();
param = wcInt.next().intValue();
break;
default:
log.error("error: this type is not supported");
break;
}
}
if (community == LOCAL_PERF) {
if (param > 127 || param < -127) {
return false;
}
/** if -ve then make it 1 bye value and set it, if it is positive then no issue.*/
if (param < 0) {
param = ~param + 129;
list.remove(wcParam);
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
resultBuilder.setwCommInt(Integer.valueOf(param));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_PARAMETER);
list.add(resultBuilder.build());
}
}
return true;
}
/**
* Delete the the Bgp flow spec.
*
* @param stream bgp flow spec in JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteBgpFlow(InputStream stream) {
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode flow = jsonTree.get(BGPFLOW);
String devId = jsonTree.get(DEVICEID).asText();
boolean status;
List<ExtFlowTypes> list;
ExtFlowContainer container;
list = codec(ExtFlowTypes.class).decode((ArrayNode) flow, this);
if (!validateRpd(list)) {
return Response.status(NOT_ACCEPTABLE).entity(Boolean.FALSE.toString()).build();
}
container = new ExtFlowContainer(list);
container.setDeviceId(devId);
status = flowService.onBgpFlowDeleted(container);
Boolean isSuccess = Boolean.valueOf(status);
if (!status) {
return Response.status(NOT_ACCEPTABLE).entity(isSuccess.toString()).build();
}
return Response.status(OK).entity(isSuccess.toString()).build();
} catch (IOException e) {
log.error("Exception while parsing bgp flow.", e.toString());
throw new IllegalArgumentException(e);
}
}
}
/*
* 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-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.onosproject.flowapi.ExtOperatorValue;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import static org.slf4j.LoggerFactory.getLogger;
public class BgpParseAttributes {
private final Logger log = getLogger(getClass());
/** Bits as per flow spec rfc 5575.*/
final byte endBit = (byte) 0x80;
final byte andBit = 0x40;
final byte twoByteLen = (byte) (0x01 << 4);
final byte fourByteLen = (byte) (0x02 << 4);
final byte lessThan = 0x04;
final byte greaterThan = 0x02;
final byte equal = 0x01;
/** Protocol types.*/
protected static final byte ICMP = 1;
protected static final byte IGMP = 2;
protected static final byte TCP = 6;
protected static final byte UDP = 17;
protected static final byte IPV4 = 4;
protected static final byte IPV6 = 41;
/** TCP Flags.*/
static final byte FIN = (1 << 0);
static final byte SYN = (1 << 1);
static final byte RST = (1 << 2);
static final byte PSH = (1 << 3);
static final byte ACK = (1 << 4);
static final byte URG = (1 << 5);
final byte notBit = 0x02;
final byte matchBit = 0x01;
/** Fragment Flags.*/
static final byte DF = (1 << 0);
static final byte IF = (1 << 1);
static final byte FF = (1 << 2);
static final byte LF = (1 << 3);
List<ExtOperatorValue> parsePort(String string) {
List<ExtOperatorValue> operatorValue = null;
operatorValue = createOperatorValue(string);
return operatorValue;
}
List<ExtOperatorValue> parseIpProtocol(String string) {
List<ExtOperatorValue> operatorValue = null;
string = string.replaceAll("ICMP", Byte.valueOf(ICMP).toString());
string = string.replaceAll("icmp", Byte.valueOf(ICMP).toString());
string = string.replaceAll("IPv4", Byte.valueOf(IPV4).toString());
string = string.replaceAll("ipv4", Byte.valueOf(IPV4).toString());
string = string.replaceAll("TCP", Byte.valueOf(TCP).toString());
string = string.replaceAll("tcp", Byte.valueOf(TCP).toString());
string = string.replaceAll("UDP", Byte.valueOf(UDP).toString());
string = string.replaceAll("udp", Byte.valueOf(UDP).toString());
string = string.replaceAll("IPv6", Byte.valueOf(IPV6).toString());
string = string.replaceAll("ipv6", Byte.valueOf(IPV6).toString());
string = string.replaceAll("igmp", Byte.valueOf(IGMP).toString());
string = string.replaceAll("IGMP", Byte.valueOf(IGMP).toString());
operatorValue = createOperatorValue(string);
return operatorValue;
}
List<ExtOperatorValue> parseIcmpType(String string) {
List<ExtOperatorValue> operatorValue = null;
operatorValue = createOperatorValue(string);
return operatorValue;
}
List<ExtOperatorValue> parseIcmpCode(String string) {
List<ExtOperatorValue> operatorValue = null;
operatorValue = createOperatorValue(string);
return operatorValue;
}
List<ExtOperatorValue> parseTcpFlags(String string) {
List<ExtOperatorValue> operatorValue = new ArrayList<>();
Token token;
int index = 0;
string = string.replaceAll("FIN", Byte.valueOf(FIN).toString());
string = string.replaceAll("fin", Byte.valueOf(FIN).toString());
string = string.replaceAll("SYN", Byte.valueOf(SYN).toString());
string = string.replaceAll("syn", Byte.valueOf(SYN).toString());
string = string.replaceAll("RST", Byte.valueOf(RST).toString());
string = string.replaceAll("rst", Byte.valueOf(RST).toString());
string = string.replaceAll("PSH", Byte.valueOf(PSH).toString());
string = string.replaceAll("psh", Byte.valueOf(PSH).toString());
string = string.replaceAll("ACK", Byte.valueOf(ACK).toString());
string = string.replaceAll("ack", Byte.valueOf(ACK).toString());
string = string.replaceAll("URG", Byte.valueOf(URG).toString());
string = string.replaceAll("urg", Byte.valueOf(URG).toString());
do {
token = parseTcpTokenValue(string, index);
if (token.error) {
log.error("Error in parsing the TCP value list");
return null;
}
operatorValue.add(new ExtOperatorValue(token.operator, token.value));
index = token.index;
} while ((token.operator & endBit) != endBit);
return operatorValue;
}
List<ExtOperatorValue> parsePacketLength(String string) {
List<ExtOperatorValue> operatorValue = null;
operatorValue = createOperatorValue(string);
return operatorValue;
}
List<ExtOperatorValue> parseDscp(String string) {
List<ExtOperatorValue> operatorValue = null;
operatorValue = createOperatorValue(string);
return operatorValue;
}
List<ExtOperatorValue> parseFragment(String string) {
List<ExtOperatorValue> operatorValue = null;
string = string.replaceAll("DF", Byte.valueOf(DF).toString());
string = string.replaceAll("df", Byte.valueOf(DF).toString());
string = string.replaceAll("IF", Byte.valueOf(IF).toString());
string = string.replaceAll("if", Byte.valueOf(IF).toString());
string = string.replaceAll("FF", Byte.valueOf(FF).toString());
string = string.replaceAll("ff", Byte.valueOf(FF).toString());
string = string.replaceAll("LF", Byte.valueOf(LF).toString());
string = string.replaceAll("lf", Byte.valueOf(LF).toString());
operatorValue = createOperatorValue(string);
return operatorValue;
}
private class Token {
byte operator;
byte[] value;
int index;
boolean error;
}
List<ExtOperatorValue> createOperatorValue(String string) {
List<ExtOperatorValue> operatorValue = new ArrayList<>();
Token token;
int index = 0;
do {
token = parseMultiTokenValue(string, index);
if (token.error) {
log.error("Error in parsing the operator value list");
return null;
}
operatorValue.add(new ExtOperatorValue(token.operator, token.value));
index = token.index;
} while ((token.operator & endBit) != endBit);
return operatorValue;
}
Token parseMultiTokenValue(String str, int index) {
Token token = new Token();
token.error = true;
int number = 0;
int cur = 0;
byte operator = 0;
boolean prevNumber = false;
boolean bLess = false;
boolean bGreater = false;
boolean bAnd = false;
boolean bEqual = false;
while (str.length() > index) {
switch (str.charAt(index)) {
case '=':
if (bEqual) {
return token;
}
bEqual = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | equal);
break;
case '>':
if (bGreater) {
return token;
}
bGreater = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | greaterThan);
break;
case '<':
if (bLess) {
return token;
}
bLess = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | lessThan);
break;
case '&':
if (bAnd) {
return token;
}
bAnd = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | andBit);
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
prevNumber = true;
bLess = false;
bGreater = false;
bAnd = false;
bEqual = false;
cur = str.charAt(index);
number = (number * 10) + cur - '0';
break;
default:
log.error("Error in parsing the token character" + str.charAt(index));
return token;
}
index++;
}
if (prevNumber) {
return windUp(str, index, number, operator);
}
return token;
}
Token windUp(String str, int index, int number, byte operator) {
Token token = new Token();
byte[] array = new byte[1];
if (str.length() == index) {
operator = (byte) (operator | endBit);
}
if (number <= 255) {
array[0] = (byte) number;
} else if (number > 255 && number <= Short.MAX_VALUE) {
operator = (byte) (operator | twoByteLen);
array = shortToByteStream((short) number);
} else if (number > Short.MAX_VALUE) {
operator = (byte) (operator | fourByteLen);
array = intToByteStream(number);
}
token.value = array;
token.operator = operator;
token.index = index;
token.error = false;
return token;
}
byte[] intToByteStream(int val) {
return new byte[] {
(byte) (val >>> 24),
(byte) (val >>> 16),
(byte) (val >>> 8),
(byte) val};
}
byte[] shortToByteStream(short val) {
return new byte[] {
(byte) (val >>> 8),
(byte) val};
}
Token parseTcpTokenValue(String str, int index) {
Token token = new Token();
token.error = true;
int number = 0;
int cur = 0;
byte operator = 0;
boolean prevNumber = false;
boolean bNotBit = false;
boolean bAnd = false;
boolean bMatchBit = false;
while (str.length() > index) {
switch (str.charAt(index)) {
case '=':
if (bMatchBit) {
return token;
}
bMatchBit = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | matchBit);
break;
case '!':
if (bNotBit) {
return token;
}
bNotBit = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | notBit);
break;
case '&':
if (bAnd) {
return token;
}
bAnd = true;
if (prevNumber) {
return windUp(str, index, number, operator);
}
operator = (byte) (operator | andBit);
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
prevNumber = true;
bNotBit = false;
bAnd = false;
bMatchBit = false;
cur = str.charAt(index);
number = (number * 10) + cur - '0';
break;
default:
log.error("Error in parsing the TCP token character" + str.charAt(index));
return token;
}
index++;
}
if (prevNumber) {
return windUp(str, index, number, operator);
}
return token;
}
}
/*
* 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.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onosproject.flowapi.DefaultExtDscpValue;
import org.onosproject.flowapi.DefaultExtFragment;
import org.onosproject.flowapi.DefaultExtIcmpCode;
import org.onosproject.flowapi.DefaultExtIcmpType;
import org.onosproject.flowapi.DefaultExtIpProtocol;
import org.onosproject.flowapi.DefaultExtKeyName;
import org.onosproject.flowapi.DefaultExtPacketLength;
import org.onosproject.flowapi.DefaultExtPort;
import org.onosproject.flowapi.DefaultExtPrefix;
import org.onosproject.flowapi.DefaultExtTarget;
import org.onosproject.flowapi.DefaultExtTcpFlag;
import org.onosproject.flowapi.DefaultExtTrafficAction;
import org.onosproject.flowapi.DefaultExtTrafficMarking;
import org.onosproject.flowapi.DefaultExtTrafficRate;
import org.onosproject.flowapi.DefaultExtTrafficRedirect;
import org.onosproject.flowapi.DefaultExtWideCommunityInt;
import org.onosproject.flowapi.ExtDscpValue;
import org.onosproject.flowapi.ExtFlowTypes;
import org.onosproject.flowapi.ExtFragment;
import org.onosproject.flowapi.ExtIcmpCode;
import org.onosproject.flowapi.ExtIcmpType;
import org.onosproject.flowapi.ExtIpProtocol;
import org.onosproject.flowapi.ExtKeyName;
import org.onosproject.flowapi.ExtPacketLength;
import org.onosproject.flowapi.ExtPort;
import org.onosproject.flowapi.ExtPrefix;
import org.onosproject.flowapi.ExtTarget;
import org.onosproject.flowapi.ExtTcpFlag;
import org.onosproject.flowapi.ExtTrafficAction;
import org.onosproject.flowapi.ExtTrafficMarking;
import org.onosproject.flowapi.ExtTrafficRate;
import org.onosproject.flowapi.ExtTrafficRedirect;
import org.onosproject.flowapi.ExtWideCommunityInt;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import static org.onlab.util.Tools.nullIsIllegal;
/**
* Decode the Ext extension codec.
*/
public final class DecodeBgpFlowExtnCodecHelper {
private final ObjectNode json;
protected static final String MISSING_MEMBER_MESSAGE =
" member is required in ExtTypes";
protected static final String MALFORMED_MEMBER_MESSAGE =
" member is malformed";
private interface ExtensionDecoder {
ExtFlowTypes decodeExtension(ObjectNode json);
}
private final Map<String, ExtensionDecoder> decoderMap;
BgpParseAttributes parse = new BgpParseAttributes();
/**
* Creates a decode extension codec object.
* Initializes the lookup map for Bgp extension types.
*
* @param json JSON object to decode
*/
public DecodeBgpFlowExtnCodecHelper(ObjectNode json) {
this.json = json;
decoderMap = new HashMap<>();
decoderMap.put(ExtFlowTypes.ExtType.IPV4_SRC_PFX.name(), new BgpSourcePrefixDecode());
decoderMap.put(ExtFlowTypes.ExtType.IPV4_DST_PFX.name(), new BgpDestinationPrefixDecode());
decoderMap.put(ExtFlowTypes.ExtType.EXT_FLOW_RULE_KEY.name(), new BgpFlowRuleKeyDecode());
decoderMap.put(ExtFlowTypes.ExtType.IP_PROTO_LIST.name(), new BgpIpProtocolDecode());
decoderMap.put(ExtFlowTypes.ExtType.IN_PORT_LIST.name(), new BgpInPortDecode());
decoderMap.put(ExtFlowTypes.ExtType.DST_PORT_LIST.name(), new BgpDestinationPortDecode());
decoderMap.put(ExtFlowTypes.ExtType.SRC_PORT_LIST.name(), new BgpSourcePortDecode());
decoderMap.put(ExtFlowTypes.ExtType.ICMP_TYPE_LIST.name(), new BgpIcmpTypeDecode());
decoderMap.put(ExtFlowTypes.ExtType.ICMP_CODE_LIST.name(), new BgpIcmpCodeDecode());
decoderMap.put(ExtFlowTypes.ExtType.TCP_FLAG_LIST.name(), new BgpTcpFlagDecode());
decoderMap.put(ExtFlowTypes.ExtType.PACKET_LENGTH_LIST.name(), new BgpPacketLengthDecode());
decoderMap.put(ExtFlowTypes.ExtType.DSCP_VALUE_LIST.name(), new BgpDscpValueDecode());
decoderMap.put(ExtFlowTypes.ExtType.FRAGMENT_LIST.name(), new BgpFragmentDecode());
decoderMap.put(ExtFlowTypes.ExtType.TRAFFIC_RATE.name(), new BgpTrafficRateDecode());
decoderMap.put(ExtFlowTypes.ExtType.TRAFFIC_ACTION.name(), new BgpTrafficActionDecode());
decoderMap.put(ExtFlowTypes.ExtType.TRAFFIC_REDIRECT.name(), new BgpTrafficRedirectDecode());
decoderMap.put(ExtFlowTypes.ExtType.TRAFFIC_MARKING.name(), new BgpTrafficMarkingDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_FLAGS.name(), new BgpWcommFlagsDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_HOP_COUNT.name(), new BgpWcommHopCountDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_COMMUNITY.name(), new BgpWcommCommunityDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_CONTEXT_AS.name(), new BgpWcommContextAsDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_LOCAL_AS.name(), new BgpWcommLocalAsDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_TARGET.name(), new BgpWcommTargetDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_EXT_TARGET.name(), new BgpWcommExtTargetDecode());
decoderMap.put(ExtFlowTypes.ExtType.WIDE_COMM_PARAMETER.name(), new BgpWcommParameterDecode());
}
/** Source prefix decoder.*/
private class BgpSourcePrefixDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtPrefix.Builder resultBuilder = new DefaultExtPrefix.Builder();
String ip = nullIsIllegal(json.get(BgpFlowExtensionCodec.PREFIX),
BgpFlowExtensionCodec.PREFIX + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setPrefix(IpPrefix.valueOf(ip));
resultBuilder.setType(ExtFlowTypes.ExtType.IPV4_SRC_PFX);
return resultBuilder.build();
}
}
/** Destination prefix decoder.*/
private class BgpDestinationPrefixDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtPrefix.Builder resultBuilder = new DefaultExtPrefix.Builder();
String ip = nullIsIllegal(json.get(BgpFlowExtensionCodec.PREFIX),
BgpFlowExtensionCodec.PREFIX + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setPrefix(IpPrefix.valueOf(ip));
resultBuilder.setType(ExtFlowTypes.ExtType.IPV4_DST_PFX);
return resultBuilder.build();
}
}
/** Flow rule key decoder.*/
private class BgpFlowRuleKeyDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtKeyName.Builder resultBuilder = new DefaultExtKeyName.Builder();
String name = nullIsIllegal(json.get(BgpFlowExtensionCodec.NAME),
BgpFlowExtensionCodec.NAME + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setKeyName(name);
resultBuilder.setType(ExtFlowTypes.ExtType.EXT_FLOW_RULE_KEY);
return resultBuilder.build();
}
}
/** Ip protocol decoder.*/
private class BgpIpProtocolDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtIpProtocol.Builder resultBuilder = new DefaultExtIpProtocol.Builder();
String protocols = nullIsIllegal(json.get(BgpFlowExtensionCodec.PROTOCOLS),
BgpFlowExtensionCodec.PROTOCOLS + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setIpProtocol(parse.parseIpProtocol(protocols));
resultBuilder.setType(ExtFlowTypes.ExtType.IP_PROTO_LIST);
return resultBuilder.build();
}
}
/** In port decoder.*/
private class BgpInPortDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtPort.Builder resultBuilder = new DefaultExtPort.Builder();
String portList = nullIsIllegal(json.get(BgpFlowExtensionCodec.PORT),
BgpFlowExtensionCodec.PORT + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setPort(parse.parsePort(portList));
resultBuilder.setType(ExtFlowTypes.ExtType.IN_PORT_LIST);
return resultBuilder.build();
}
}
/** Destination decoder.*/
private class BgpDestinationPortDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtPort.Builder resultBuilder = new DefaultExtPort.Builder();
String portList = nullIsIllegal(json.get(BgpFlowExtensionCodec.DST_PORT),
BgpFlowExtensionCodec.DST_PORT + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setPort(parse.parsePort(portList));
resultBuilder.setType(ExtFlowTypes.ExtType.DST_PORT_LIST);
return resultBuilder.build();
}
}
/** Source decoder.*/
private class BgpSourcePortDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtPort.Builder resultBuilder = new DefaultExtPort.Builder();
String portList = nullIsIllegal(json.get(BgpFlowExtensionCodec.SRC_PORT),
BgpFlowExtensionCodec.SRC_PORT + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setPort(parse.parsePort(portList));
resultBuilder.setType(ExtFlowTypes.ExtType.SRC_PORT_LIST);
return resultBuilder.build();
}
}
/** Icmp type decoder.*/
private class BgpIcmpTypeDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtIcmpType.Builder resultBuilder = new DefaultExtIcmpType.Builder();
String icmpType = nullIsIllegal(json.get(BgpFlowExtensionCodec.ICMP_TYPE),
BgpFlowExtensionCodec.ICMP_TYPE + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setIcmpType(parse.parseIcmpType(icmpType));
resultBuilder.setType(ExtFlowTypes.ExtType.ICMP_TYPE_LIST);
return resultBuilder.build();
}
}
/** Icmp code decoder.*/
private class BgpIcmpCodeDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtIcmpCode.Builder resultBuilder = new DefaultExtIcmpCode.Builder();
String icmpCode = nullIsIllegal(json.get(BgpFlowExtensionCodec.ICMP_CODE),
BgpFlowExtensionCodec.ICMP_CODE + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setIcmpCode(parse.parseIcmpCode(icmpCode));
resultBuilder.setType(ExtFlowTypes.ExtType.ICMP_CODE_LIST);
return resultBuilder.build();
}
}
/** Tcp flag decoder.*/
private class BgpTcpFlagDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTcpFlag.Builder resultBuilder = new DefaultExtTcpFlag.Builder();
String tcpFlag = nullIsIllegal(json.get(BgpFlowExtensionCodec.TCP_FLAG),
BgpFlowExtensionCodec.TCP_FLAG + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setTcpFlag(parse.parseTcpFlags(tcpFlag));
resultBuilder.setType(ExtFlowTypes.ExtType.TCP_FLAG_LIST);
return resultBuilder.build();
}
}
/** Packet length decoder.*/
private class BgpPacketLengthDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtPacketLength.Builder resultBuilder = new DefaultExtPacketLength.Builder();
String packetLength = nullIsIllegal(json.get(BgpFlowExtensionCodec.PACKET_LENGTH),
BgpFlowExtensionCodec.PACKET_LENGTH + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setPacketLength(parse.parsePacketLength(packetLength));
resultBuilder.setType(ExtFlowTypes.ExtType.PACKET_LENGTH_LIST);
return resultBuilder.build();
}
}
/** Dscp value decoder.*/
private class BgpDscpValueDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtDscpValue.Builder resultBuilder = new DefaultExtDscpValue.Builder();
String dscpValue = nullIsIllegal(json.get(BgpFlowExtensionCodec.DSCP_VALUE),
BgpFlowExtensionCodec.DSCP_VALUE + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setDscpValue(parse.parseDscp(dscpValue));
resultBuilder.setType(ExtFlowTypes.ExtType.DSCP_VALUE_LIST);
return resultBuilder.build();
}
}
/** Fragment decoder.*/
private class BgpFragmentDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtFragment.Builder resultBuilder = new DefaultExtFragment.Builder();
String fragment = nullIsIllegal(json.get(BgpFlowExtensionCodec.FRAGMENT),
BgpFlowExtensionCodec.FRAGMENT + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setFragment(parse.parseFragment(fragment));
resultBuilder.setType(ExtFlowTypes.ExtType.FRAGMENT_LIST);
return resultBuilder.build();
}
}
/** Traffic rate decoder.*/
private class BgpTrafficRateDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTrafficRate.Builder resultBuilder = new DefaultExtTrafficRate.Builder();
String rate = nullIsIllegal(json.get(BgpFlowExtensionCodec.TRAFFIC_RATE),
BgpFlowExtensionCodec.TRAFFIC_RATE + MISSING_MEMBER_MESSAGE).asText();
String[] commaPart = rate.split(",");
String[] valuePart = commaPart[0].split("=");
if (valuePart[0].matches(BgpFlowExtensionCodec.TRAFFIC_RATE_ASN)) {
short s = Short.decode(valuePart[1].trim()).shortValue();
resultBuilder.setAsn(s);
} else {
nullIsIllegal(valuePart[0], BgpFlowExtensionCodec.TRAFFIC_RATE + MALFORMED_MEMBER_MESSAGE);
}
valuePart = commaPart[1].split("=");
if (valuePart[0].matches(BgpFlowExtensionCodec.TRAFFIC_RATE_RATE)) {
float f = Float.parseFloat(valuePart[1].trim());
resultBuilder.setRate(f);
} else {
nullIsIllegal(valuePart[0], BgpFlowExtensionCodec.TRAFFIC_RATE + MALFORMED_MEMBER_MESSAGE);
}
resultBuilder.setType(ExtFlowTypes.ExtType.TRAFFIC_RATE);
return resultBuilder.build();
}
}
/** Traffic action decoder.*/
private class BgpTrafficActionDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTrafficAction.Builder resultBuilder = new DefaultExtTrafficAction.Builder();
String rate = nullIsIllegal(json.get(BgpFlowExtensionCodec.TRAFFIC_ACTION),
BgpFlowExtensionCodec.TRAFFIC_ACTION + MISSING_MEMBER_MESSAGE).asText();
String[] commaPart = rate.split(",");
String[] valuePart = commaPart[0].split("=");
if (valuePart[0].matches(BgpFlowExtensionCodec.TRAFFIC_ACTION_TERMINAL)) {
boolean terminal = Boolean.parseBoolean(valuePart[1].trim());
resultBuilder.setTerminal(terminal);
} else {
nullIsIllegal(valuePart[0], BgpFlowExtensionCodec.TRAFFIC_ACTION_TERMINAL + MISSING_MEMBER_MESSAGE);
}
valuePart = commaPart[1].split("=");
if (valuePart[0].matches(BgpFlowExtensionCodec.TRAFFIC_ACTION_SAMPLE)) {
boolean sample = Boolean.parseBoolean(valuePart[1].trim());
resultBuilder.setSample(sample);
} else {
nullIsIllegal(valuePart[0], BgpFlowExtensionCodec.TRAFFIC_ACTION_SAMPLE + MISSING_MEMBER_MESSAGE);
}
valuePart = commaPart[2].split("=");
if (valuePart[0].matches(BgpFlowExtensionCodec.TRAFFIC_ACTION_RPD)) {
boolean rpd = Boolean.parseBoolean(valuePart[1].trim());
resultBuilder.setRpd(rpd);
} else {
nullIsIllegal(valuePart[0], BgpFlowExtensionCodec.TRAFFIC_ACTION_RPD + MISSING_MEMBER_MESSAGE);
}
resultBuilder.setType(ExtFlowTypes.ExtType.TRAFFIC_ACTION);
return resultBuilder.build();
}
}
/** Traffic redirect decoder.*/
private class BgpTrafficRedirectDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTrafficRedirect.Builder resultBuilder = new DefaultExtTrafficRedirect.Builder();
String action = nullIsIllegal(json.get(BgpFlowExtensionCodec.TRAFFIC_REDIRECTION),
BgpFlowExtensionCodec.TRAFFIC_REDIRECTION + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setRedirect(action);
resultBuilder.setType(ExtFlowTypes.ExtType.TRAFFIC_REDIRECT);
return resultBuilder.build();
}
}
/** Traffic marking decoder.*/
private class BgpTrafficMarkingDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTrafficMarking.Builder resultBuilder = new DefaultExtTrafficMarking.Builder();
String action = nullIsIllegal(json.get(BgpFlowExtensionCodec.TRAFFIC_MARKING),
BgpFlowExtensionCodec.TRAFFIC_MARKING + MISSING_MEMBER_MESSAGE).asText();
if ((action.length() != 1) || action.isEmpty()) {
nullIsIllegal(action, BgpFlowExtensionCodec.TRAFFIC_MARKING + MALFORMED_MEMBER_MESSAGE);
}
resultBuilder.setMarking((byte) action.charAt(0));
resultBuilder.setType(ExtFlowTypes.ExtType.TRAFFIC_MARKING);
return resultBuilder.build();
}
}
/** Wide community flag decoder.*/
private class BgpWcommFlagsDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
String wideComm = nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_FLAGS),
BgpFlowExtensionCodec.WIDE_COMM_FLAGS + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setwCommInt(Integer.valueOf(wideComm));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_FLAGS);
return resultBuilder.build();
}
}
/** Wide community hop count decoder.*/
private class BgpWcommHopCountDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
String wideComm = nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_HOP_COUNT),
BgpFlowExtensionCodec.WIDE_COMM_HOP_COUNT + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setwCommInt(Integer.valueOf(wideComm));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_HOP_COUNT);
return resultBuilder.build();
}
}
/** Wide community decoder.*/
private class BgpWcommCommunityDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
String wideComm = nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_COMMUNITY),
BgpFlowExtensionCodec.WIDE_COMM_COMMUNITY + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setwCommInt(Integer.valueOf(wideComm));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_COMMUNITY);
return resultBuilder.build();
}
}
/** Wide community context AS decoder.*/
private class BgpWcommContextAsDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
String wideComm = nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_CONTEXT_AS),
BgpFlowExtensionCodec.WIDE_COMM_CONTEXT_AS + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setwCommInt(Integer.valueOf(wideComm));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_CONTEXT_AS);
return resultBuilder.build();
}
}
/** Wide community local AS decoder.*/
private class BgpWcommLocalAsDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
String wideComm = nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_LOCAL_AS),
BgpFlowExtensionCodec.WIDE_COMM_LOCAL_AS + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setwCommInt(Integer.valueOf(wideComm));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_LOCAL_AS);
return resultBuilder.build();
}
}
/** Wide community parameter decoder.*/
private class BgpWcommParameterDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtWideCommunityInt.Builder resultBuilder = new DefaultExtWideCommunityInt.Builder();
String wideComm = nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_PARAMETER),
BgpFlowExtensionCodec.WIDE_COMM_PARAMETER + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setwCommInt(Integer.valueOf(wideComm));
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_PARAMETER);
return resultBuilder.build();
}
}
/** Wide community target decoder.*/
private class BgpWcommTargetDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTarget.Builder resultBuilder = new DefaultExtTarget.Builder();
JsonNode jsonNodes = json.get(BgpFlowExtensionCodec.WIDE_COMM_TARGET);
if (jsonNodes == null) {
nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_TARGET),
BgpFlowExtensionCodec.WIDE_COMM_TARGET + MISSING_MEMBER_MESSAGE).asText();
}
JsonNode array = jsonNodes.path(BgpFlowExtensionCodec.WIDE_COMM_TGT_LOCAL_SP);
if (array == null) {
nullIsIllegal(array, BgpFlowExtensionCodec.WIDE_COMM_TGT_LOCAL_SP + MISSING_MEMBER_MESSAGE).asText();
}
ExtPrefix.Builder resultBuilderPfx = parseIpArrayToPrefix(array);
resultBuilderPfx.setType(ExtFlowTypes.ExtType.IPV4_SRC_PFX);
resultBuilder.setLocalSpeaker(resultBuilderPfx.build());
array = jsonNodes.path(BgpFlowExtensionCodec.WIDE_COMM_TGT_REMOTE_SP);
if (array == null) {
nullIsIllegal(array, BgpFlowExtensionCodec.WIDE_COMM_TGT_REMOTE_SP + MISSING_MEMBER_MESSAGE).asText();
}
resultBuilderPfx = parseIpArrayToPrefix(array);
resultBuilderPfx.setType(ExtFlowTypes.ExtType.IPV4_DST_PFX);
resultBuilder.setRemoteSpeaker(resultBuilderPfx.build());
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_TARGET);
return resultBuilder.build();
}
}
/** Wide community extended target decoder.*/
private class BgpWcommExtTargetDecode implements ExtensionDecoder {
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
if (json == null || !json.isObject()) {
return null;
}
ExtTarget.Builder resultBuilder = new DefaultExtTarget.Builder();
JsonNode jsonNodes = json.get(BgpFlowExtensionCodec.WIDE_COMM_EXT_TARGET);
if (jsonNodes == null) {
nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_EXT_TARGET),
BgpFlowExtensionCodec.WIDE_COMM_EXT_TARGET + MISSING_MEMBER_MESSAGE).asText();
}
JsonNode array = jsonNodes.path(BgpFlowExtensionCodec.WIDE_COMM_TGT_LOCAL_SP);
if (array == null) {
nullIsIllegal(array, BgpFlowExtensionCodec.WIDE_COMM_TGT_LOCAL_SP + MISSING_MEMBER_MESSAGE).asText();
}
ExtPrefix.Builder resultBuilderPfx = parseIpArrayToPrefix(array);
resultBuilderPfx.setType(ExtFlowTypes.ExtType.IPV4_SRC_PFX);
resultBuilder.setLocalSpeaker(resultBuilderPfx.build());
array = jsonNodes.path(BgpFlowExtensionCodec.WIDE_COMM_TGT_REMOTE_SP);
if (array == null) {
nullIsIllegal(array, BgpFlowExtensionCodec.WIDE_COMM_TGT_REMOTE_SP + MISSING_MEMBER_MESSAGE).asText();
}
resultBuilderPfx = parseIpArrayToPrefix(array);
resultBuilderPfx.setType(ExtFlowTypes.ExtType.IPV4_DST_PFX);
resultBuilder.setRemoteSpeaker(resultBuilderPfx.build());
resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_EXT_TARGET);
return resultBuilder.build();
}
}
/** Ip address parser decoder.*/
public ExtPrefix.Builder parseIpArrayToPrefix(JsonNode array) {
ExtPrefix.Builder resultBuilder = new DefaultExtPrefix.Builder();
String ip;
IpPrefix prefix;
IpAddress ipAddr;
Iterator<JsonNode> itr = array.iterator();
while (itr.hasNext()) {
ip = itr.next().asText();
ipAddr = IpAddress.valueOf(ip);
prefix = IpPrefix.valueOf(ipAddr, 32);
resultBuilder.setPrefix(prefix);
}
return resultBuilder;
}
/**
* Decodes the JSON into a BgpFlowType extension object.
*
* @return ExtFlowTypes object
* @throws IllegalArgumentException if the JSON is invalid
*/
public ExtFlowTypes decode() {
String type = json.get(BgpFlowExtensionCodec.TYPE).asText();
ExtensionDecoder decoder = decoderMap.get(type);
if (decoder != null) {
return decoder.decodeExtension(json);
}
throw new IllegalArgumentException("Type " + type + " is unknown");
}
}
/*
* 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,
)
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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-flowmgr</artifactId>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-bgp-flowapi</artifactId>
<version>1.6.0-SNAPSHOT</version>
</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.flow.forwarder;
import org.onosproject.flowapi.ExtFlowContainer;
/**
* Abstraction of an entity which provides Bgp Flow Service.
*/
public interface BgpFlowForwarderService {
/**
* Install forwarding rule.
*
* @param container BgpFlow container
* @return a true if success else false
*/
boolean installForwardingRule(ExtFlowContainer container);
/**
* Uninstall forwarding rule.
*
* @param container BgpFlow container
* @return a true if success else false
*/
boolean unInstallForwardingRule(ExtFlowContainer container);
}
/*
* 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.flow.forwarder.impl;
import org.onosproject.core.ApplicationId;
import org.onosproject.flow.forwarder.BgpFlowForwarderService;
import org.onosproject.flowapi.ExtFlowContainer;
import org.onosproject.net.Annotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ExtensionSelectorResolver;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.driver.DriverHandler;
import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flowobjective.DefaultForwardingObjective;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
import org.onosproject.net.flowobjective.Objective;
import org.slf4j.Logger;
import java.util.Iterator;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.flow.criteria.ExtensionSelectorType.ExtensionSelectorTypes.EXT_MATCH_FLOW_TYPE;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides Bgp flow forwarder implementation.
*/
public class BgpFlowForwarderImpl implements BgpFlowForwarderService {
protected DriverService driverService;
protected DeviceService deviceService;
protected FlowObjectiveService flowObjectiveService;
private final Logger log = getLogger(getClass());
protected ApplicationId appId;
private static final String BGP_FLOW_CONTAINER_NOT_NULL = "Bgp flow container cannot be null";
private static final String APP_ID_NOT_NULL = "Application-Id cannot be null";
public static final String FLOW_PEER = "flowPeer";
/**
* Default constructor.
*/
public BgpFlowForwarderImpl() {
}
/**
* Explicit constructor.
*
* @param appId Application id
* @param flowObjectiveService flow service
* @param deviceService device service
* @param driverService driver service
*/
public BgpFlowForwarderImpl(ApplicationId appId, FlowObjectiveService flowObjectiveService,
DeviceService deviceService, DriverService driverService) {
this.appId = checkNotNull(appId, APP_ID_NOT_NULL);
this.flowObjectiveService = flowObjectiveService;
this.deviceService = deviceService;
this.driverService = driverService;
}
@Override
public boolean installForwardingRule(ExtFlowContainer container) {
checkNotNull(container, BGP_FLOW_CONTAINER_NOT_NULL);
return pushBgpFlowRuleForwarder(container, Objective.Operation.ADD);
}
@Override
public boolean unInstallForwardingRule(ExtFlowContainer container) {
checkNotNull(container, BGP_FLOW_CONTAINER_NOT_NULL);
return pushBgpFlowRuleForwarder(container, Objective.Operation.REMOVE);
}
/**
* Find the bgp device and push the rule.
*
* @param container is a flow rule container
* @param type either add or remove the service rule
* @return a true if success else false
*/
public boolean pushBgpFlowRuleForwarder(ExtFlowContainer container,
Objective.Operation type) {
DeviceId deviceId = null;
Iterable<Device> devices = deviceService.getAvailableDevices();
Iterator<Device> itr = devices.iterator();
while (itr.hasNext()) {
DeviceId tmp = itr.next().id();
if (tmp.toString().equals(container.deviceId())) {
if (validatePeer(tmp)) {
deviceId = tmp;
break;
}
}
}
if (deviceId != null) {
// pack traffic selector
TrafficSelector.Builder selector = packTrafficSelector(deviceId, container);
// pack traffic treatment
TrafficTreatment.Builder treatment = packTrafficTreatment(container);
sendBgpFlowRuleForwarder(selector, treatment, deviceId, type);
} else {
log.error("Bgp devices are not available..");
return false;
}
return true;
}
/**
* Validates the device id is a flow peer or not.
*
* @param deviceId device to which the flow needed to be pushed.
* @return true if success else false
*/
boolean validatePeer(DeviceId deviceId) {
boolean ret = false;
Device d = deviceService.getDevice(deviceId);
Annotations a = d != null ? d.annotations() : null;
String ipAddress = a.value(FLOW_PEER);
if (ipAddress != null) {
ret = true;
}
return ret;
}
/**
* Traffic selector builder function.
*
* @param deviceId device id.
* @param container container need to be pushed.
* @return the traffic selector builder
*/
public TrafficSelector.Builder packTrafficSelector(DeviceId deviceId, ExtFlowContainer container) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
DriverHandler handler = driverService.createHandler(deviceId);
ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
ExtensionSelector bgpExtSelector = resolver.getExtensionSelector(EXT_MATCH_FLOW_TYPE.type());
try {
bgpExtSelector.setPropertyValue("container", container);
} catch (Exception e) {
log.error("Failed to get extension instruction for bgp flow {}", deviceId);
}
selector.extension(bgpExtSelector, deviceId);
return selector;
}
/**
* Traffic treatment builder function.
*
* @param container container need to be pushed.
* @return the traffic treatment builder
*/
public TrafficTreatment.Builder packTrafficTreatment(ExtFlowContainer container) {
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
return treatment;
}
/**
* Send bgp flow forwarder to bgp provider.
*
* @param selector traffic selector
* @param treatment traffic treatment
* @param deviceId device id
* @param type operation type
*/
public void sendBgpFlowRuleForwarder(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment,
DeviceId deviceId, Objective.Operation type) {
ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build())
.withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE);
if (type.equals(Objective.Operation.ADD)) {
log.debug("ADD");
flowObjectiveService.forward(deviceId, objective.add());
} else {
log.debug("REMOVE");
flowObjectiveService.forward(deviceId, objective.remove());
}
}
}
/*
* 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 service manager for interacting with bgp provider.
*/
package org.onosproject.flow.forwarder.impl;
/*
* 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.
*/
/**
* Service forwarder for bgp flow.
*/
package org.onosproject.flow.forwarder;
/*
* 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.flow.manager;
import org.onosproject.flowapi.ExtFlowContainer;
/**
* Bgp flow service application.
*/
public interface BgpFlowService {
/**
* Bgp flow rule create interface.
*
* @param container flow container class
* @return true if success else false
*/
boolean onBgpFlowCreated(ExtFlowContainer container);
/**
* Bgp flow rule delete interface.
*
* @param container flow container class
* @return true if success else false
*/
boolean onBgpFlowDeleted(ExtFlowContainer container);
}
/*
* 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.flow.manager.impl;
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.apache.felix.scr.annotations.Service;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.flow.forwarder.BgpFlowForwarderService;
import org.onosproject.flow.forwarder.impl.BgpFlowForwarderImpl;
import org.onosproject.flow.manager.BgpFlowService;
import org.onosproject.flowapi.ExtFlowContainer;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides implementation of Bgp flow Service.
*/
@Component(immediate = true)
@Service
public class BgpFlowManager implements BgpFlowService {
private final Logger log = getLogger(getClass());
private static final String APP_ID = "org.onosproject.app.bgpflow";
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
protected ApplicationId appId;
private BgpFlowForwarderService bgpFlowForwarderService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DriverService driverService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected FlowObjectiveService flowObjectiveService;
@Activate
public void activate() {
appId = coreService.registerApplication(APP_ID);
bgpFlowForwarderService = new BgpFlowForwarderImpl(appId, flowObjectiveService, deviceService, driverService);
log.info("Started");
}
@Deactivate
public void deactivate() {
log.info("Stopped");
}
@Override
public boolean onBgpFlowCreated(ExtFlowContainer container) {
return bgpFlowForwarderService.installForwardingRule(container);
}
@Override
public boolean onBgpFlowDeleted(ExtFlowContainer container) {
return bgpFlowForwarderService.unInstallForwardingRule(container);
}
}
/*
* 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 service manager for interacting provider.
*/
package org.onosproject.flow.manager.impl;
/*
* 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 flow manager.
*/
package org.onosproject.flow.manager;
<?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-apps</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-bgpflow</artifactId>
<packaging>pom</packaging>
<description>ONOS bgp flow spec applications</description>
<modules>
<module>app</module>
<module>flowapi</module>
<module>flowmgr</module>
<module>bgpweb</module>
</modules>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -42,6 +42,7 @@
<module>reactive-routing</module>
<module>virtualbng</module>
<module>bgprouter</module>
<module>bgpflowspec</module>
<module>test</module>
<module>segmentrouting</module>
<module>xos-integration</module>
......
......@@ -40,6 +40,7 @@ public class ExtensionSelectorType {
NICIRA_MATCH_NSH_CH4(5),
NICIRA_MATCH_ENCAP_ETH_TYPE(6),
OFDPA_MATCH_VLAN_VID(16),
EXT_MATCH_FLOW_TYPE(20),
BMV2_MATCH_PARAMS(128);
private ExtensionSelectorType type;
......
......@@ -4,6 +4,7 @@ COMPILE_DEPS = [
'//drivers/utilities:onos-drivers-utilities',
'//protocols/openflow/api:onos-protocols-openflow-api',
'//core/store/serializers:onos-core-serializers',
'//apps/bgpflowspec/flowapi:onos-apps-bgpflowspec-flowapi',
]
TEST_DEPS = [
......@@ -28,5 +29,6 @@ onos_app (
':onos-drivers-default',
'//lib:openflowj',
'//protocols/openflow/api:onos-protocols-openflow-api',
'//apps/bgpflowspec/flowapi:onos-apps-bgpflowspec-flowapi',
]
)
......
......@@ -44,6 +44,11 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-bgp-flowapi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>openflowj</artifactId>
</dependency>
</dependencies>
......
/*
* 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.driver.extensions;
import org.onlab.util.KryoNamespace;
import org.onosproject.flowapi.ExtFlowContainer;
import org.onosproject.net.flow.AbstractExtension;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.ExtensionSelectorType;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Implementation of extension selector for multi value.
*/
public final class ExtMatchExtension extends AbstractExtension implements ExtensionSelector {
private ExtFlowContainer container;
private final KryoNamespace appKryo = new KryoNamespace.Builder().register(ExtMatchExtension.class).build();
/**
* Creates an object of ExtMatchExtension.
*/
public ExtMatchExtension() {
this.container = null;
}
/**
* Returns the container.
*
* @return the container to match
*/
public ExtFlowContainer container() {
return container;
}
@Override
public ExtensionSelectorType type() {
return ExtensionSelectorType.ExtensionSelectorTypes.EXT_MATCH_FLOW_TYPE.type();
}
@Override
public byte[] serialize() {
return appKryo.serialize(container);
}
@Override
public void deserialize(byte[] data) {
container = ExtFlowContainer.of(appKryo.deserialize(data));
}
@Override
public String toString() {
return toStringHelper(type().toString())
.add("container", container)
.toString();
}
@Override
public int hashCode() {
return Objects.hash(type(), container);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ExtMatchExtension) {
ExtMatchExtension that = (ExtMatchExtension) obj;
return Objects.equals(container, that.container) &&
Objects.equals(this.type(), that.type());
}
return false;
}
}
/*
* 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.driver.extensions;
import org.onosproject.net.behaviour.ExtensionSelectorResolver;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.ExtensionSelectorType;
/**
* Interpreter for bgp selector extensions.
*/
public class MultiExtensionSelectorInterpreter
extends AbstractHandlerBehaviour
implements ExtensionSelectorResolver {
@Override
public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) {
if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.EXT_MATCH_FLOW_TYPE.type())) {
return new ExtMatchExtension();
}
return null;
}
}
......@@ -141,6 +141,11 @@
<behaviour api="org.onosproject.net.behaviour.Pipeliner"
impl="org.onosproject.driver.pipeline.OpenVSwitchPipeline"/>
</driver>
<driver name="l3Device" extends="default"
manufacturer="" hwVersion="" swVersion="">
<behaviour api="org.onosproject.net.behaviour.ExtensionSelectorResolver"
impl="org.onosproject.driver.extensions.MultiExtensionSelectorInterpreter" />
</driver>
<driver name="aos" extends="ofdpa"
manufacturer="Accton" hwVersion=".*" swVersion="1.*">
</driver>
......
......@@ -231,6 +231,7 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi
DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
newBuilder.set(AnnotationKeys.DRIVER, "l3Device");
newBuilder.set(AnnotationKeys.TYPE, "L3");
newBuilder.set(ROUTING_UNIVERSE, Long.toString(nodeNlri.getIdentifier()));
......
......@@ -35,5 +35,15 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-bgp-flowapi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-ctl</artifactId>
<version>1.6.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
......
......@@ -18,8 +18,11 @@ package org.onosproject.provider.bgpcep.flow.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
......@@ -31,13 +34,63 @@ import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MplsLabel;
import org.onosproject.bgp.controller.BgpController;
import org.onosproject.bgp.controller.BgpId;
import org.onosproject.bgp.controller.BgpPeer;
import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri;
import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecRouteKey;
import org.onosproject.bgpio.types.BgpFsActionReDirect;
import org.onosproject.bgpio.types.BgpFsActionTrafficAction;
import org.onosproject.bgpio.types.BgpFsActionTrafficMarking;
import org.onosproject.bgpio.types.BgpFsActionTrafficRate;
import org.onosproject.bgpio.types.BgpFsDestinationPortNum;
import org.onosproject.bgpio.types.BgpFsDestinationPrefix;
import org.onosproject.bgpio.types.BgpFsDscpValue;
import org.onosproject.bgpio.types.BgpFsFragment;
import org.onosproject.bgpio.types.BgpFsIcmpCode;
import org.onosproject.bgpio.types.BgpFsIcmpType;
import org.onosproject.bgpio.types.BgpFsIpProtocol;
import org.onosproject.bgpio.types.BgpFsOperatorValue;
import org.onosproject.bgpio.types.BgpFsPacketLength;
import org.onosproject.bgpio.types.BgpFsPortNum;
import org.onosproject.bgpio.types.BgpFsSourcePortNum;
import org.onosproject.bgpio.types.BgpFsSourcePrefix;
import org.onosproject.bgpio.types.BgpFsTcpFlags;
import org.onosproject.bgpio.types.BgpValueType;
import org.onosproject.bgpio.types.WideCommunityAttrHeader;
import org.onosproject.bgpio.types.WideCommunityExcludeTarget;
import org.onosproject.bgpio.types.WideCommunityInteger;
import org.onosproject.bgpio.types.WideCommunityIpV4Neighbour;
import org.onosproject.bgpio.types.WideCommunityParameter;
import org.onosproject.bgpio.types.WideCommunityTarget;
import org.onosproject.bgpio.types.attr.WideCommunity;
import org.onosproject.core.ApplicationId;
import org.onosproject.flowapi.ExtDscpValue;
import org.onosproject.flowapi.ExtFlowContainer;
import org.onosproject.flowapi.ExtFlowTypes;
import org.onosproject.flowapi.ExtFragment;
import org.onosproject.flowapi.ExtIcmpCode;
import org.onosproject.flowapi.ExtIcmpType;
import org.onosproject.flowapi.ExtIpProtocol;
import org.onosproject.flowapi.ExtKeyName;
import org.onosproject.flowapi.ExtOperatorValue;
import org.onosproject.flowapi.ExtPacketLength;
import org.onosproject.flowapi.ExtPort;
import org.onosproject.flowapi.ExtPrefix;
import org.onosproject.flowapi.ExtTarget;
import org.onosproject.flowapi.ExtTcpFlag;
import org.onosproject.flowapi.ExtTrafficAction;
import org.onosproject.flowapi.ExtTrafficMarking;
import org.onosproject.flowapi.ExtTrafficRate;
import org.onosproject.flowapi.ExtTrafficRedirect;
import org.onosproject.flowapi.ExtWideCommunityInt;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Annotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
......@@ -56,12 +109,15 @@ import org.onosproject.net.flow.FlowRuleProviderService;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.FlowEntry.FlowEntryState;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.criteria.ExtensionCriterion;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.IPCriterion;
import org.onosproject.net.flow.criteria.MetadataCriterion;
import org.onosproject.net.flow.criteria.MplsBosCriterion;
import org.onosproject.net.flow.criteria.MplsCriterion;
import org.onosproject.net.flow.criteria.PortCriterion;
import org.onosproject.net.flow.criteria.TunnelIdCriterion;
import org.onosproject.net.flow.instructions.ExtensionPropertyException;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.ResourceService;
......@@ -125,6 +181,7 @@ public class BgpcepFlowRuleProvider extends AbstractProvider
protected DeviceService deviceService;
private FlowRuleProviderService providerService;
public static final String FLOW_PEER = "flowPeer";
private PcepLabelObject labelObj;
public static final int OUT_LABEL_TYPE = 0;
public static final int IN_LABEL_TYPE = 1;
......@@ -572,14 +629,19 @@ public class BgpcepFlowRuleProvider extends AbstractProvider
case ADD:
if (criteria == null) {
processRule(fbe.target(), PcepFlowType.ADD);
flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.ADDED, 0, 0, 0));
} else {
handleMessage(fbe, BgpPeer.FlowSpecOperation.ADD, batch.deviceId());
}
flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.ADDED, 0, 0, 0));
break;
case REMOVE:
if (criteria == null) {
processRule(fbe.target(), PcepFlowType.REMOVE);
flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.REMOVED, 0, 0, 0));
} else {
handleMessage(fbe, BgpPeer.FlowSpecOperation.DELETE, batch.deviceId());
}
flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.REMOVED, 0, 0, 0));
break;
default:
log.error("Unknown flow operation: {}", fbe);
......@@ -590,4 +652,330 @@ public class BgpcepFlowRuleProvider extends AbstractProvider
providerService.batchOperationCompleted(batch.id(), status);
providerService.pushFlowMetrics(batch.deviceId(), flowEntries);
}
public void handleMessage(FlowRuleBatchEntry fbe, BgpPeer.FlowSpecOperation operType, DeviceId deviceId) {
Set<Criterion> set = fbe.target().selector().criteria();
Iterator iterator = set.iterator();
Criterion cr;
while (iterator.hasNext()) {
cr = (Criterion) iterator.next();
switch (cr.type()) {
case EXTENSION:
ExtensionCriterion extensionCriterion = (ExtensionCriterion) cr;
ExtensionSelector extension = extensionCriterion.extensionSelector();
ExtFlowContainer container = null;
List<ExtFlowTypes> bgpFlows = null;
try {
container = extension.getPropertyValue("container");
} catch (ExtensionPropertyException e) {
e.printStackTrace();
}
bgpFlows = container.container();
iterateAndSend(bgpFlows, operType, deviceId);
break;
default:
log.error("This flow type is not supported: {}", cr.type());
}
}
}
void iterateAndSend(List<ExtFlowTypes> bgpFlows, BgpPeer.FlowSpecOperation operType, DeviceId deviceId) {
ListIterator<ExtFlowTypes> iterator = bgpFlows.listIterator();
ExtFlowTypes flow;
ExtKeyName name = null;
ExtPrefix ipcSource = null;
ExtPrefix ipcDestination = null;
IpPrefix prefix = null;
ListIterator<IpPrefix> pfxItr = null;
ExtTrafficRate flowRate = null;
ExtTrafficAction flowAction = null;
ExtTrafficMarking flowMarking = null;
List<BgpValueType> flowSpecComponents = new ArrayList<>();
List<BgpFsOperatorValue> operatorValue;
BgpFlowSpecNlri flowSpec = new BgpFlowSpecNlri(flowSpecComponents);
BgpFsActionTrafficRate rate = null;
BgpFsActionTrafficAction action = null;
BgpFsActionReDirect redirection = null;
BgpFsActionTrafficMarking marking = null;
List<BgpValueType> flowSpecAction = new LinkedList<>();
ExtWideCommunityInt wcIntList = null;
ListIterator<Integer> wcItr = null;
WideCommunity wideCommunity = null;
int flags = 0;
int hopCount = 0;
int community = 0;
int contextAs = 0;
int localAs = 0;
WideCommunityInteger wCommInt;
WideCommunityParameter wCommParam = null;
List<BgpValueType> wcParam = new ArrayList<>();
WideCommunityTarget wcTarget = null;
WideCommunityExcludeTarget wcExcludeTarget = null;
WideCommunityAttrHeader wideCommunityHeader = null;
while (iterator.hasNext()) {
flow = iterator.next();
switch (flow.type()) {
case EXT_FLOW_RULE_KEY:
name = (ExtKeyName) flow;
break;
case IPV4_DST_PFX:
ipcDestination = (ExtPrefix) flow;
pfxItr = ipcDestination.prefix().listIterator();
prefix = pfxItr.next();
flowSpecComponents.add(new BgpFsDestinationPrefix((byte) prefix.prefixLength(),
prefix));
break;
case IPV4_SRC_PFX:
ipcSource = (ExtPrefix) flow;
pfxItr = ipcSource.prefix().listIterator();
prefix = pfxItr.next();
flowSpecComponents.add(new BgpFsSourcePrefix((byte) prefix.prefixLength(),
prefix));
break;
case IP_PROTO_LIST:
operatorValue = convert(((ExtIpProtocol) flow).ipProtocol());
flowSpecComponents.add(new BgpFsIpProtocol(operatorValue));
break;
case IN_PORT_LIST:
operatorValue = convert(((ExtPort) flow).port());
flowSpecComponents.add(new BgpFsPortNum(operatorValue));
break;
case DST_PORT_LIST:
operatorValue = convert(((ExtPort) flow).port());
flowSpecComponents.add(new BgpFsDestinationPortNum(operatorValue));
break;
case SRC_PORT_LIST:
operatorValue = convert(((ExtPort) flow).port());
flowSpecComponents.add(new BgpFsSourcePortNum(operatorValue));
break;
case ICMP_TYPE_LIST:
operatorValue = convert(((ExtIcmpType) flow).icmpType());
flowSpecComponents.add(new BgpFsIcmpType(operatorValue));
break;
case ICMP_CODE_LIST:
operatorValue = convert(((ExtIcmpCode) flow).icmpCode());
flowSpecComponents.add(new BgpFsIcmpCode(operatorValue));
break;
case TCP_FLAG_LIST:
operatorValue = convert(((ExtTcpFlag) flow).tcpFlag());
flowSpecComponents.add(new BgpFsTcpFlags(operatorValue));
break;
case PACKET_LENGTH_LIST:
operatorValue = convert(((ExtPacketLength) flow).packetLength());
flowSpecComponents.add(new BgpFsPacketLength(operatorValue));
break;
case DSCP_VALUE_LIST:
operatorValue = convert(((ExtDscpValue) flow).dscpValue());
flowSpecComponents.add(new BgpFsDscpValue(operatorValue));
break;
case FRAGMENT_LIST:
operatorValue = convert(((ExtFragment) flow).fragment());
flowSpecComponents.add(new BgpFsFragment(operatorValue));
break;
case TRAFFIC_RATE:
flowRate = (ExtTrafficRate) flow;
rate = new BgpFsActionTrafficRate(flowRate.asn(), flowRate.rate().floatValue());
flowSpecAction.add(rate);
flowSpec.setFsActionTlv(flowSpecAction);
break;
case TRAFFIC_ACTION:
flowAction = (ExtTrafficAction) flow;
byte[] byteAction = processTrafficAction((ExtTrafficAction) flow);
action = new BgpFsActionTrafficAction(byteAction);
flowSpecAction.add(action);
flowSpec.setFsActionTlv(flowSpecAction);
break;
case TRAFFIC_REDIRECT:
byte[] byteRedirect = processTrafficRedirect((ExtTrafficRedirect) flow);
redirection = new BgpFsActionReDirect(byteRedirect);
flowSpecAction.add(redirection);
flowSpec.setFsActionTlv(flowSpecAction);
break;
case TRAFFIC_MARKING:
byte[] byteMarking = new byte[6];
flowMarking = (ExtTrafficMarking) flow;
byteMarking[5] = flowMarking.marking();
marking = new BgpFsActionTrafficMarking(byteMarking);
flowSpecAction.add(marking);
flowSpec.setFsActionTlv(flowSpecAction);
break;
case WIDE_COMM_FLAGS:
wcIntList = (ExtWideCommunityInt) flow;
wcItr = wcIntList.communityInt().listIterator();
flags = wcItr.next().intValue();
break;
case WIDE_COMM_HOP_COUNT:
wcIntList = (ExtWideCommunityInt) flow;
wcItr = wcIntList.communityInt().listIterator();
hopCount = wcItr.next().intValue();
break;
case WIDE_COMM_COMMUNITY:
wcIntList = (ExtWideCommunityInt) flow;
wcItr = wcIntList.communityInt().listIterator();
community = wcItr.next().intValue();
break;
case WIDE_COMM_CONTEXT_AS:
wcIntList = (ExtWideCommunityInt) flow;
wcItr = wcIntList.communityInt().listIterator();
contextAs = wcItr.next().intValue();
break;
case WIDE_COMM_LOCAL_AS:
wcIntList = (ExtWideCommunityInt) flow;
wcItr = wcIntList.communityInt().listIterator();
localAs = wcItr.next().intValue();
break;
case WIDE_COMM_TARGET:
wcTarget = processWideCommTarget((ExtTarget) flow);
break;
case WIDE_COMM_EXT_TARGET:
wcExcludeTarget = processWideCommExcTarget((ExtTarget) flow);
break;
case WIDE_COMM_PARAMETER:
wcIntList = (ExtWideCommunityInt) flow;
wCommInt = new WideCommunityInteger(wcIntList.communityInt());
wcParam.add(wCommInt);
wCommParam = new WideCommunityParameter(wcParam);
break;
default:
log.error("error: this type is not supported");
break;
}
}
if ((flowAction != null) && flowAction.rpd()) {
wideCommunityHeader = new WideCommunityAttrHeader((byte) flags, (byte) hopCount, (short) 0);
wideCommunity = new WideCommunity(wideCommunityHeader, community, localAs, contextAs,
wcTarget, wcExcludeTarget, wCommParam);
}
if (name == null) {
log.error("BGP Flow key is required");
return;
}
BgpPeer peer = getPeer(deviceId);
if (peer != null) {
peer.updateFlowSpec(operType, new BgpFlowSpecRouteKey(name.keyName()), flowSpec, wideCommunity);
}
}
byte[] processTrafficAction(ExtTrafficAction flow) {
ExtTrafficAction flowAction = null;
byte[] byteAction = new byte[6];
byte actionByte = 0;
flowAction = (ExtTrafficAction) flow;
if (flowAction.terminal()) {
actionByte = (byte) (actionByte | (byte) 0x01);
}
if (flowAction.sample()) {
actionByte = (byte) (actionByte | (byte) 0x02);
}
if (flowAction.rpd()) {
actionByte = (byte) (actionByte | (byte) 0x04);
}
byteAction[5] = actionByte;
return byteAction;
}
byte[] processTrafficRedirect(ExtTrafficRedirect flow) {
ExtTrafficRedirect flowRedirect = null;
byte[] byteRedirect = new byte[6];
byte[] tmp;
int val;
flowRedirect = (ExtTrafficRedirect) flow;
val = Integer.decode(flowRedirect.redirect()).intValue();
tmp = intToByteStream(val);
for (int i = 0; i < tmp.length; i++) {
byteRedirect[i] = tmp [i];
}
return byteRedirect;
}
WideCommunityTarget processWideCommTarget(ExtTarget flow) {
ExtPrefix localSpeaker;
ExtPrefix remoteSpeaker;
ListIterator<IpPrefix> pfxItr = null;
ListIterator<IpPrefix> pfxItr1 = null;
List<BgpValueType> wcIpv4 = null;
ExtTarget target = flow;
WideCommunityIpV4Neighbour wcIpV4Neighbour = null;
WideCommunityTarget wcTarget = null;
localSpeaker = target.localSpeaker();
remoteSpeaker = target.remoteSpeaker();
wcIpV4Neighbour = new WideCommunityIpV4Neighbour();
pfxItr = localSpeaker.prefix().listIterator();
pfxItr1 = remoteSpeaker.prefix().listIterator();
while (pfxItr.hasNext()) {
wcIpV4Neighbour.add(pfxItr.next().address(), pfxItr1.next().address());
}
wcIpv4 = new ArrayList<>();
wcIpv4.add(wcIpV4Neighbour);
wcTarget = new WideCommunityTarget(wcIpv4);
return wcTarget;
}
WideCommunityExcludeTarget processWideCommExcTarget(ExtTarget flow) {
ExtPrefix localSpeaker;
ExtPrefix remoteSpeaker;
ListIterator<IpPrefix> pfxItr = null;
ListIterator<IpPrefix> pfxItr1 = null;
List<BgpValueType> wcIpv4 = null;
ExtTarget target = flow;
localSpeaker = target.localSpeaker();
remoteSpeaker = target.remoteSpeaker();
WideCommunityIpV4Neighbour wcIpV4Neighbour = null;
wcIpV4Neighbour = new WideCommunityIpV4Neighbour();
WideCommunityExcludeTarget wcExcludeTarget = null;
pfxItr = localSpeaker.prefix().listIterator();
pfxItr1 = remoteSpeaker.prefix().listIterator();
while (pfxItr.hasNext()) {
wcIpV4Neighbour.add(pfxItr.next().address(), pfxItr1.next().address());
}
wcIpv4 = new ArrayList<>();
wcIpv4.add(wcIpV4Neighbour);
wcExcludeTarget = new WideCommunityExcludeTarget(wcIpv4);
return wcExcludeTarget;
}
BgpPeer getPeer(DeviceId deviceId) {
Device d = deviceService.getDevice(deviceId);
Annotations a = d != null ? d.annotations() : null;
String ipAddress = a.value(FLOW_PEER);
BgpId bgpId = BgpId.bgpId(IpAddress.valueOf(ipAddress));
BgpPeer peer = bgpController.getPeer(bgpId);
return peer;
}
byte[] intToByteStream(int val) {
return new byte[] {
(byte) (val >>> 24),
(byte) (val >>> 16),
(byte) (val >>> 8),
(byte) val};
}
List<BgpFsOperatorValue> convert(List<ExtOperatorValue> opVal) {
List<BgpFsOperatorValue> list = new ArrayList();
BgpFsOperatorValue operatorValue;
Iterator iterator = opVal.iterator();
while (iterator.hasNext()) {
ExtOperatorValue element = (ExtOperatorValue) iterator.next();
operatorValue = new BgpFsOperatorValue(element.option(), element.value());
list.add(operatorValue);
}
return list;
}
}
......
......@@ -32,14 +32,23 @@
</modules>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-bgp-flowapi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-pcep-controller-api</artifactId>
<artifactId>onos-bgp-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgpio</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-api</artifactId>
<artifactId>onos-pcep-controller-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......@@ -51,6 +60,22 @@
<groupId>org.onosproject</groupId>
<artifactId>onos-pcepio</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
</dependency>
</dependencies>
......
......@@ -70,6 +70,11 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-bgp-flowapi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
......