diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-06 07:15:03 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-08 10:55:21 -0800 |
commit | 76dc892491948adae5e5e62cf94448967e8d865b (patch) | |
tree | 7a33ef05cc583946db21edad627060f280a53549 /framework/src/onos/protocols/bgp/api | |
parent | d333c63fdec8b064184b0a26f8d777f267577fde (diff) |
Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2
Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/protocols/bgp/api')
15 files changed, 1416 insertions, 0 deletions
diff --git a/framework/src/onos/protocols/bgp/api/pom.xml b/framework/src/onos/protocols/bgp/api/pom.xml new file mode 100755 index 00000000..2390e5f6 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/pom.xml @@ -0,0 +1,90 @@ +<?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 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-bgp</artifactId> + <version>1.4.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>onos-bgp-api</artifactId> + <packaging>bundle</packaging> + + <description>ONOS BGP controller subsystem API</description> + + <dependencies> + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onos-bgpio</artifactId> + </dependency> + <dependency> + <groupId>io.netty</groupId> + <artifactId>netty</artifactId> + </dependency> + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onos-api</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + <configuration> + <artifactSet> + <excludes> + <exclude>io.netty:netty</exclude> + <exclude>com.google.guava:guava</exclude> + <exclude>org.slf4j:slfj-api</exclude> + <exclude>ch.qos.logback:logback-core</exclude> + <exclude>ch.qos.logback:logback-classic</exclude> + <exclude>com.google.code.findbugs:annotations</exclude> + </excludes> + </artifactSet> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Export-Package> + org.onosproject.bgp.*,org.onosproject.bgpio.*,org.onosproject.bgp.controller + </Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java new file mode 100755 index 00000000..6f64d2bb --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java @@ -0,0 +1,297 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; + +import java.util.TreeMap; + +/** + * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller. + */ +public interface BgpCfg { + + enum State { + /** + * Signifies that its just created. + */ + INIT, + + /** + * Signifies that only IP Address is configured. + */ + IP_CONFIGURED, + + /** + * Signifies that only Autonomous System is configured. + */ + AS_CONFIGURED, + + /** + * Signifies that both IP and Autonomous System is configured. + */ + IP_AS_CONFIGURED + } + + /** + * Returns the status of the configuration based on this state certain operations like connection is handled. + * + * @return State of the configuration + */ + State getState(); + + /** + * To set the current state of the configuration. + * + * @param state Configuration State enum + */ + void setState(State state); + + /** + * Get the status of the link state support for this BGP speaker. + * + * @return true if the link state is supported else false + */ + boolean getLsCapability(); + + /** + * Set the link state support to this BGP speaker. + * + * @param lscapability true value if link state is supported else false + */ + void setLsCapability(boolean lscapability); + + /** + * Get the status of the 32 bit AS support for this BGP speaker. + * + * @return true if the 32 bit AS number is supported else false + */ + boolean getLargeASCapability(); + + /** + * Set the 32 bit AS support capability to this BGP speaker. + * + * @param largeAs true value if the 32 bit AS is supported else false + */ + void setLargeASCapability(boolean largeAs); + + /** + * Set the AS number to which this BGP speaker belongs. + * + * @param localAs 16 or 32 bit AS number, length is dependent on the capability + */ + void setAsNumber(int localAs); + + /** + * Get the AS number to which this BGP speaker belongs. + * + * @return 16 or 32 bit AS number, length is dependent on the capability + */ + int getAsNumber(); + + /** + * Get the connection retry count number. + * + * @return connection retry count if there is a connection error + */ + int getMaxConnRetryCount(); + + /** + * Set the connection retry count. + * + * @param retryCount number of times to try to connect if there is any error + */ + void setMaxConnRetryCout(int retryCount); + + /** + * Get the connection retry time in seconds. + * + * @return connection retry time in seconds + */ + int getMaxConnRetryTime(); + + /** + * Set the connection retry time in seconds. + * + * @param retryTime connection retry times in seconds + */ + void setMaxConnRetryTime(int retryTime); + + /** + * Set the keep alive timer for the connection. + * + * @param holdTime connection hold timer in seconds + */ + void setHoldTime(short holdTime); + + /** + * Returns the connection hold timer in seconds. + * + * @return connection hold timer in seconds + */ + short getHoldTime(); + + /** + * Returns the maximum number of session supported. + * + * @return maximum number of session supported + */ + int getMaxSession(); + + /** + * Set the maximum number of sessions to support. + * + * @param maxsession maximum number of session + */ + void setMaxSession(int maxsession); + + /** + * Returns the Router ID of this BGP speaker. + * + * @return IP address in string format + */ + String getRouterId(); + + /** + * Set the Router ID of this BGP speaker. + * + * @param routerid IP address in string format + */ + void setRouterId(String routerid); + + /** + * Add the BGP peer IP address and the AS number to which it belongs. + * + * @param routerid IP address in string format + * @param remoteAs AS number to which it belongs + * + * @return true if added successfully else false + */ + boolean addPeer(String routerid, int remoteAs); + + /** + * Add the BGP peer IP address and the keep alive time. + * + * @param routerid IP address in string format + * @param holdTime keep alive time for the connection + * + * @return true if added successfully else false + */ + boolean addPeer(String routerid, short holdTime); + + /** + * Add the BGP peer IP address, the AS number to which it belongs and keep alive time. + * + * @param routerid IP address in string format + * @param remoteAs AS number to which it belongs + * @param holdTime keep alive time for the connection + * + * @return true if added successfully else false + */ + boolean addPeer(String routerid, int remoteAs, short holdTime); + + /** + * Remove the BGP peer with this IP address. + * + * @param routerid router IP address + * + * @return true if removed successfully else false + */ + boolean removePeer(String routerid); + + /** + * Connect to BGP peer with this IP address. + * + * @param routerid router IP address + * + * @return true of the configuration is found and able to connect else false + */ + boolean connectPeer(String routerid); + + /** + * Disconnect this BGP peer with this IP address. + * + * @param routerid router IP address in string format + * + * @return true if the configuration is found and able to disconnect else false + */ + boolean disconnectPeer(String routerid); + + /** + * Returns the peer tree information. + * + * @return return the tree map with IP as key and BGPPeerCfg as object + */ + TreeMap<String, BgpPeerCfg> displayPeers(); + + /** + * Return the BGP Peer information with this matching IP. + * + * @param routerid router IP address in string format + * + * @return BGPPeerCfg object + */ + BgpPeerCfg displayPeers(String routerid); + + /** + * Check if this BGP peer is configured. + * + * @param routerid router IP address in string format + * + * @return true if configured exists else false + */ + boolean isPeerConfigured(String routerid); + + /** + * Check if this BGP speaker is having connection with the peer. + * + * @param routerid router IP address in string format + * + * @return true if the connection exists else false + */ + boolean isPeerConnected(String routerid); + + /** + * Return the peer tree map. + * + * @return return the tree map with IP as key and BGPPeerCfg as object + */ + TreeMap<String, BgpPeerCfg> getPeerTree(); + + /** + * Set the current connection state information. + * + * @param routerid router IP address in string format + * @param state state information + */ + void setPeerConnState(String routerid, BgpPeerCfg.State state); + + /** + * Check if the peer can be connected or not. + * + * @param routerid router IP address in string format + * + * @return true if the peer can be connected else false + */ + boolean isPeerConnectable(String routerid); + + /** + * Get the current peer connection state information. + * + * @param routerid router IP address in string format + * + * @return state information + */ + BgpPeerCfg.State getPeerConnState(String routerid); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java new file mode 100755 index 00000000..8f33ee87 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java @@ -0,0 +1,28 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; + +/** + * Abstraction of an BGP connect peer, initiate remote connection to BGP peer on configuration. + */ +public interface BgpConnectPeer { + /** + * Initiate bgp peer connection. + */ + void connectPeer(); + + /** + * End bgp peer connection. + */ + void disconnectPeer(); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java new file mode 100755 index 00000000..0930e8e8 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java @@ -0,0 +1,131 @@ +/* + * 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. + */ + +package org.onosproject.bgp.controller; + +import java.util.Map; +import java.util.Set; + +import org.onosproject.bgpio.exceptions.BgpParseException; +import org.onosproject.bgpio.protocol.BgpMessage; + +/** + * Abstraction of an BGP controller. Serves as a one stop shop for obtaining BGP devices and (un)register listeners on + * bgp events + */ +public interface BgpController { + + /** + * Returns list of bgp peers connected to this BGP controller. + * + * @return Iterable of BGPPeer elements + */ + Iterable<BgpPeer> getPeers(); + + /** + * Returns the actual bgp peer for the given ip address. + * + * @param bgpId the id of the bgp peer to fetch + * @return the interface to this bgp peer + */ + BgpPeer getPeer(BgpId bgpId); + + /** + * Register a listener for BGP message events. + * + * @param listener the listener to notify + */ + void addListener(BgpNodeListener listener); + + /** + * Unregister a listener. + * + * @param listener the listener to unregister + */ + void removeListener(BgpNodeListener listener); + + /** + * Send a message to a particular bgp peer. + * + * @param bgpId the id of the peer to send message. + * @param msg the message to send + */ + void writeMsg(BgpId bgpId, BgpMessage msg); + + /** + * Process a message and notify the appropriate listeners. + * + * @param bgpId id of the peer the message arrived on + * @param msg the message to process. + * @throws BgpParseException on data processing error + */ + void processBGPPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException; + + /** + * Close all connected BGP peers. + * + */ + void closeConnectedPeers(); + + /** + * Get the BGPConfig class to the caller. + * + * @return configuration object + */ + BgpCfg getConfig(); + + /** + * Get the BGP connected peers to this controller. + * + * @return the integer number + */ + int connectedPeerCount(); + + /** + * Return BGP local RIB instance with VPN. + * + * @return BGPLocalRibImpl local RIB with VPN + */ + BgpLocalRib bgpLocalRibVpn(); + + /** + * Return BGP local RIB instance. + * + * @return BGPLocalRibImpl local RIB + */ + BgpLocalRib bgpLocalRib(); + + /** + * Return BGP peer manager. + * + * @return BGPPeerManager peer manager instance + */ + BgpPeerManager peerManager(); + + /** + * Return BGP connected peers. + * + * @return connectedPeers connected peers + */ + Map<BgpId, BgpPeer> connectedPeers(); + + /** + * Return BGP node listener. + * + * @return node listener + */ + Set<BgpNodeListener> listener(); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java new file mode 100755 index 00000000..ed04dc94 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java @@ -0,0 +1,130 @@ +/* + * 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. + */ + +package org.onosproject.bgp.controller; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.onosproject.bgpio.exceptions.BgpParseException; +import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4; +import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The class representing a network bgp device id. This class is immutable. + */ +public final class BgpDpid { + private static final Logger log = LoggerFactory.getLogger(BgpDpid.class); + + private static final String SCHEME = "bgp"; + private static final long UNKNOWN = 0; + private StringBuilder stringBuilder; + public static final int NODE_DESCRIPTOR_LOCAL = 1; + public static final int NODE_DESCRIPTOR_REMOTE = 2; + + /** + * Initialize bgp id to generate URI. + * + * @param linkNlri node Nlri. + * @param nodeDescriptorType node descriptor type, local/remote + */ + public BgpDpid(final BgpLinkLsNlriVer4 linkNlri, int nodeDescriptorType) { + this.stringBuilder = new StringBuilder("bgpls://"); + + if (linkNlri.getRouteDistinguisher() != null) { + this.stringBuilder.append(linkNlri.getRouteDistinguisher().getRouteDistinguisher()).append(':'); + } + + try { + this.stringBuilder.append(linkNlri.getProtocolId()).append(':').append(linkNlri.getIdentifier()) + .append('/'); + + if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) { + add(linkNlri.localNodeDescriptors()); + } else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) { + add(linkNlri.remoteNodeDescriptors()); + } + } catch (BgpParseException e) { + log.info("Exception BgpId string: " + e.toString()); + } + + } + + /** + * Initialize bgp id to generate URI. + * + * @param nodeNlri node Nlri. + */ + public BgpDpid(final BgpNodeLSNlriVer4 nodeNlri) { + this.stringBuilder = new StringBuilder("bgpls://"); + + if (nodeNlri.getRouteDistinguisher() != null) { + this.stringBuilder.append(nodeNlri.getRouteDistinguisher().getRouteDistinguisher()).append(':'); + } + + try { + + this.stringBuilder.append(nodeNlri.getProtocolId()).append(':').append(nodeNlri.getIdentifier()) + .append('/'); + + add(nodeNlri.getLocalNodeDescriptors()); + + } catch (BgpParseException e) { + log.info("Exception node string: " + e.toString()); + } + } + + BgpDpid add(final Object value) { + if (value != null) { + this.stringBuilder.append('&').append('=').append(value.toString()); + } + return this; + } + + @Override + public String toString() { + return this.stringBuilder.toString(); + } + + /** + * Produces bgp URI. + * + * @param value string to get URI + * @return bgp URI, otherwise null + */ + public static URI uri(String value) { + try { + return new URI(SCHEME, value, null); + } catch (URISyntaxException e) { + log.info("Exception BgpId URI: " + e.toString()); + } + return null; + } + + /** + * Returns bgpDpid created from the given device URI. + * + * @param uri device URI + * @return object of BgpDpid + */ + public static BgpDpid bgpDpid(URI uri) { + checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme"); + + // TODO: return BgpDpid generated from uri + return null; + } +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java new file mode 100755 index 00000000..7a6c625d --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java @@ -0,0 +1,121 @@ +/* + * 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. + */ + +package org.onosproject.bgp.controller; + +import org.onlab.packet.IpAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Objects; + +import static com.google.common.base.Preconditions.checkArgument; + +/** + * The class representing a network peer bgp ip. + * This class is immutable. + */ +public final class BgpId { + + private static final String SCHEME = "bgp"; + private static final long UNKNOWN = 0; + private final IpAddress ipAddress; + + /** + * Private constructor. + */ + private BgpId(IpAddress ipAddress) { + this.ipAddress = ipAddress; + } + + /** + * Create a BGPId from ip address. + * + * @param ipAddress IP address + * @return object of BGPId + */ + public static BgpId bgpId(IpAddress ipAddress) { + return new BgpId(ipAddress); + } + + /** + * Returns the ip address. + * + * @return ipAddress + */ + public IpAddress ipAddress() { + return ipAddress; + } + + /** + * Convert the BGPId value to a ':' separated hexadecimal string. + * + * @return the BGPId value as a ':' separated hexadecimal string. + */ + @Override + public String toString() { + return ipAddress.toString(); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof BgpId)) { + return false; + } + + BgpId otherBGPid = (BgpId) other; + return Objects.equals(ipAddress, otherBGPid.ipAddress); + } + + @Override + public int hashCode() { + return Objects.hash(ipAddress); + } + + /** + * Returns BGPId created from the given device URI. + * + * @param uri device URI + * @return object of BGPId + */ + public static BgpId bgpId(URI uri) { + checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme"); + return new BgpId(IpAddress.valueOf(uri.getSchemeSpecificPart())); + } + + /** + * Produces device URI from the given DPID. + * + * @param bgpId device bgpId + * @return device URI + */ + public static URI uri(BgpId bgpId) { + return uri(bgpId.ipAddress()); + } + + /** + * Produces device URI from the given DPID long. + * + * @param ipAddress device ip address + * @return device URI + */ + public static URI uri(IpAddress ipAddress) { + try { + return new URI(SCHEME, ipAddress.toString(), null); + } catch (URISyntaxException e) { + return null; + } + } +}
\ No newline at end of file diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java new file mode 100755 index 00000000..8b34e314 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java @@ -0,0 +1,35 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; + +import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4; + +/** + * Allows for providers interested in Link events to be notified. + */ +public interface BgpLinkListener { + + /** + * Notify that got a packet of link from network and need do processing. + * + * @param linkNlri bgp link + */ + void addLink(BgpLinkLsNlriVer4 linkNlri); + + /** + * Notify that got a packet of link from network and need do processing. + * + * @param linkNlri bgp link + */ + void deleteLink(BgpLinkLsNlriVer4 linkNlri); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java new file mode 100755 index 00000000..636c1c85 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + +package org.onosproject.bgp.controller; + +import org.onosproject.bgpio.protocol.BgpLSNlri; +import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails; +import org.onosproject.bgpio.types.RouteDistinguisher; + +/** + * Abstraction of BGP local RIB. + */ +public interface BgpLocalRib { + + /** + * Add NLRI to local RIB. + * + * @param sessionInfo session info + * @param nlri network layer reach info + * @param details nlri details + */ + void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details); + + /** + * Removes NLRI identifier if it exists. + * + * @param nlri info + */ + void delete(BgpLSNlri nlri); + + /** + * Update NLRI identifier mapped with route distinguisher if it exists in tree otherwise add NLRI infomation mapped + * to respective route distinguisher. + * + * @param sessionInfo BGP session info + * @param nlri info + * @param details has pathattribute, protocol id and identifier + * @param routeDistinguisher unique for each VPN + */ + void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details, + RouteDistinguisher routeDistinguisher); + + /** + * Removes VPN NLRI identifier mapped to route distinguisher if it exists. + * + * @param nlri info + * @param routeDistinguisher unique for each VPN + */ + void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java new file mode 100755 index 00000000..726d931b --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java @@ -0,0 +1,35 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; + +import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; + +/** + * Allows for providers interested in node events to be notified. + */ +public interface BgpNodeListener { + + /** + * Notifies that the node was added. + * + * @param nodeNlri node rechability info + */ + void addNode(BgpNodeLSNlriVer4 nodeNlri); + + /** + * Notifies that the node was removed. + * + * @param nodeNlri node rechability info + */ + void deleteNode(BgpNodeLSNlriVer4 nodeNlri); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java new file mode 100755 index 00000000..8fd3c688 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java @@ -0,0 +1,52 @@ +/* + * 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. + */ + +package org.onosproject.bgp.controller; + +/** + * A representation of a packet context which allows any provider to view a packet in event, but may block the response + * to the event if blocked has been called. This packet context can be used to react to the packet in event with a + * packet out. + */ +public interface BgpPacketStats { + /** + * Returns the count for no of packets sent out. + * + * @return int value of no of packets sent + */ + int outPacketCount(); + + /** + * Returns the count for no of packets received. + * + * @return int value of no of packets sent + */ + int inPacketCount(); + + /** + * Returns the count for no of wrong packets received. + * + * @return int value of no of wrong packets received + */ + int wrongPacketCount(); + + /** + * Returns the time. + * + * @return the time + */ + long getTime(); +}
\ No newline at end of file diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java new file mode 100644 index 00000000..9f4d47da --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java @@ -0,0 +1,113 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; +import java.util.List; +import org.jboss.netty.channel.Channel; +import org.onosproject.bgpio.exceptions.BgpParseException; +import org.onosproject.bgpio.protocol.BgpFactory; +import org.onosproject.bgpio.protocol.BgpMessage; +import org.onosproject.bgpio.types.BgpValueType; + +/** + * Represents the peer side of an BGP peer. + * + */ +public interface BgpPeer { + + /** + * Sets the associated Netty channel for this bgp peer. + * + * @param channel the Netty channel + */ + void setChannel(Channel channel); + + /** + * Gets the associated Netty channel handler for this bgp peer. + * + * @return Channel channel connected. + */ + Channel getChannel(); + + /** + * Sets whether the bgp peer is connected. + * + * @param connected whether the bgp peer is connected + */ + void setConnected(boolean connected); + + /** + * Checks whether the handshake is complete. + * + * @return true is finished, false if not. + */ + boolean isHandshakeComplete(); + + /** + * Writes the message to the peer. + * + * @param msg the message to write + */ + void sendMessage(BgpMessage msg); + + /** + * Writes the BGPMessage list to the peer. + * + * @param msgs the messages to be written + */ + void sendMessage(List<BgpMessage> msgs); + + /** + * Provides the factory for BGP version. + * + * @return BGP version specific factory. + */ + BgpFactory factory(); + + /** + * Checks if the bgp peer is still connected. + * + * @return whether the bgp peer is still connected + */ + boolean isConnected(); + + /** + * Disconnects the bgp peer by closing the TCP connection. Results in a call to the channel handler's + * channelDisconnected method for cleanup + */ + void disconnectPeer(); + + /** + * Identifies the channel used to communicate with the bgp peer. + * + * @return string representation of the connection to the peer + */ + String channelId(); + + /** + * Maintaining Adj-RIB-In separately for each peer. + * + * @param pathAttr list of Bgp path attributes + * @throws BgpParseException while building Adj-Rib-In + */ + void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException; + + /** + * Return the BGP session info. + * + * @return sessionInfo bgp session info + */ + BgpSessionInfo sessionInfo(); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java new file mode 100755 index 00000000..2fb970fc --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java @@ -0,0 +1,180 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; + +/** + * BGP Peer configuration information. + */ +public interface BgpPeerCfg { + + enum State { + + /** + * Signifies that peer connection is idle. + */ + IDLE, + + /** + * Signifies that connection is initiated. + */ + CONNECT, + + /** + * Signifies that state is active and connection can be established. + */ + ACTIVE, + + /** + * Signifies that open is sent and anticipating reply. + */ + OPENSENT, + + /** + * Signifies that peer sent the open message as reply. + */ + OPENCONFIRM, + + /** + * Signifies that all the negotiation is successful and ready to exchange other messages. + */ + ESTABLISHED, + + /** + * Signifies that invalid state. + */ + INVALID + } + + /** + * Returns the connection State information of the peer. + * + * @return + * enum state is returned + */ + State getState(); + + /** + * Set the connection state information of the peer. + * + * @param state + * enum state + */ + void setState(State state); + + /** + * Returns the connection is initiated from us or not. + * + * @return + * true if the connection is initiated by this peer, false if it has been received. + */ + boolean getSelfInnitConnection(); + + /** + * Set the connection is initiated from us or not. + * + * @param selfInit + * true if the connection is initiated by this peer, false if it has been received. + */ + void setSelfInnitConnection(boolean selfInit); + + /** + * Returns the AS number to which this peer belongs. + * + * @return + * AS number + */ + int getAsNumber(); + + /** + * Set the AS number to which this peer belongs. + * + * @param asNumber + * AS number + */ + void setAsNumber(int asNumber); + + /** + * Get the keep alive timer value configured. + * + * @return + * keep alive timer value in seconds + */ + short getHoldtime(); + + /** + * Set the keep alive timer value. + * + * @param holdTime + * keep alive timer value in seconds + */ + void setHoldtime(short holdTime); + + /** + * Return the connection type eBGP or iBGP. + * + * @return + * true if iBGP, false if it is eBGP + */ + boolean getIsIBgp(); + + /** + * Set the connection type eBGP or iBGP. + * + * @param isIBgp + * true if iBGP, false if it is eBGP + */ + void setIsIBgp(boolean isIBgp); + + /** + * Return the peer router IP address. + * + * @return + * IP address in string format + */ + String getPeerRouterId(); + + /** + * Set the peer router IP address. + * + * @param peerId + * IP address in string format + */ + void setPeerRouterId(String peerId); + + /** + * Set the peer router IP address and AS number. + * + * @param peerId + * IP address in string format + * @param asNumber + * AS number + */ + void setPeerRouterId(String peerId, int asNumber); + + /** + * Set the peer connect instance. + * + * @param connectpeer connect peer instance + */ + void setConnectPeer(BgpConnectPeer connectpeer); + + /** + * Get the peer connect instance. + * + * @return peer connect instance + */ + BgpConnectPeer connectPeer(); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java new file mode 100755 index 00000000..895cc145 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java @@ -0,0 +1,54 @@ +/* + * 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. + */ +package org.onosproject.bgp.controller; + +/** + * Responsible for keeping track of the current set BGPLS peers connected to the system. + * + */ +public interface BgpPeerManager { + + /** + * Add connected peer. + * + * @param bgpId BGP ID to add + * @param bgpPeer BGp peer instance + * + * @return false if peer already exist, otherwise true + */ + public boolean addConnectedPeer(BgpId bgpId, BgpPeer bgpPeer); + + /** + * Validate wheather peer is connected. + * + * @param bgpId BGP ID to validate + * + * @return true if peer exist, otherwise false + */ + public boolean isPeerConnected(BgpId bgpId); + + /** + * Remove connected peer. + * + * @param bgpId BGP ID + */ + public void removeConnectedPeer(BgpId bgpId); + + /** + * Gets connected peer. + * + * @param bgpId BGP ID + * @return BGPPeer the connected peer, otherwise null + */ + public BgpPeer getPeer(BgpId bgpId); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java new file mode 100755 index 00000000..a21a23d2 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java @@ -0,0 +1,70 @@ +/* + * 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. + */ + +package org.onosproject.bgp.controller; + +import org.onosproject.bgpio.protocol.BgpVersion; + +/** + * Abstraction of an BGP session info. Maintian session parameters obtained during session creation. + */ +public interface BgpSessionInfo { + /** + * Gets the bgp session type iBGP/eBGP. + * + * @return isiBGPSession, true if session is of type internal, otherwise false. + */ + boolean isIbgpSession(); + + /** + * Gets the negotiated hold time for the session. + * + * @return negotiated hold time. + */ + short negotiatedholdTime(); + + /** + * Gets the BGP ID of BGP peer. + * + * @return bgp ID. + */ + BgpId remoteBgpId(); + + /** + * Gets the BGP version of peer. + * + * @return bgp version. + */ + BgpVersion remoteBgpVersion(); + + /** + * Gets the BGP remote bgp AS number. + * + * @return remoteBgpASNum peer AS number. + */ + long remoteBgpASNum(); + + /** + * Gets the BGP peer hold time. + * + * @return bgp hold time. + */ + short remoteBgpHoldTime(); + + /** + * Gets the BGP version for this bgp peer. + * + * @return bgp identifier. + */ + int remoteBgpIdentifier(); +} diff --git a/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java new file mode 100755 index 00000000..4dd775b8 --- /dev/null +++ b/framework/src/onos/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * BGP controller API. + */ +package org.onosproject.bgp.controller; |