From e63291850fd0795c5700e25e67e5dee89ba54c5f Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Tue, 1 Dec 2015 05:49:27 -0800 Subject: onos commit hash c2999f30c69e50df905a9d175ef80b3f23a98514 Change-Id: I2bb8562c4942b6d6a6d60b663db2e17540477b81 Signed-off-by: Ashlee Young --- .../org/onosproject/bgp/controller/BGPCfg.java | 297 --------------------- .../onosproject/bgp/controller/BGPController.java | 138 ---------- .../java/org/onosproject/bgp/controller/BGPId.java | 121 --------- .../onosproject/bgp/controller/BGPPacketStats.java | 52 ---- .../org/onosproject/bgp/controller/BGPPeer.java | 103 ------- .../org/onosproject/bgp/controller/BGPPeerCfg.java | 180 ------------- .../org/onosproject/bgp/controller/BgpCfg.java | 297 +++++++++++++++++++++ .../onosproject/bgp/controller/BgpConnectPeer.java | 28 ++ .../onosproject/bgp/controller/BgpController.java | 117 ++++++++ .../org/onosproject/bgp/controller/BgpDpid.java | 130 +++++++++ .../java/org/onosproject/bgp/controller/BgpId.java | 121 +++++++++ .../bgp/controller/BgpLinkListener.java | 35 +++ .../onosproject/bgp/controller/BgpLocalRib.java | 60 +++++ .../bgp/controller/BgpNodeListener.java | 35 +++ .../onosproject/bgp/controller/BgpPacketStats.java | 52 ++++ .../org/onosproject/bgp/controller/BgpPeer.java | 113 ++++++++ .../org/onosproject/bgp/controller/BgpPeerCfg.java | 180 +++++++++++++ .../onosproject/bgp/controller/BgpPeerManager.java | 8 +- .../onosproject/bgp/controller/BgpSessionInfo.java | 70 +++++ 19 files changed, 1242 insertions(+), 895 deletions(-) delete mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java delete mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java delete mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPId.java delete mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPacketStats.java delete mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java delete mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java create mode 100644 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java (limited to 'framework/src/onos/bgp/api/src') diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java deleted file mode 100755 index 46165d87..00000000 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * 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 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 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/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java deleted file mode 100755 index 9d44041e..00000000 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPController.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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 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); - - /** - * Register a listener for BGP message events. - * - * @param listener the listener to notify - */ - void addLinkListener(BgpLinkListener listener); - - /** - * Unregister a listener. - * - * @param listener the listener to unregister - */ - void removeLinkListener(BgpLinkListener 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 peer manager. - * - * @return BGPPeerManager peer manager instance - */ - BgpPeerManager peerManager(); - - /** - * Return BGP connected peers. - * - * @return connectedPeers connected peers - */ - Map connectedPeers(); - - /** - * Return BGP node listener. - * - * @return node listener - */ - Set listener(); - - /** - * Return BGP link listener. - * - * @return link listener - */ - Set linkListener(); -} diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPId.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPId.java deleted file mode 100755 index 636e72f3..00000000 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPId.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPacketStats.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPacketStats.java deleted file mode 100755 index 95f83a2d..00000000 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPacketStats.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java deleted file mode 100755 index aafaf06e..00000000 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeer.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.protocol.BGPFactory; -import org.onosproject.bgpio.protocol.BGPMessage; - -/** - * 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 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(); - - /** - * Return the BGP session info. - * - * @return sessionInfo bgp session info - */ - BgpSessionInfo sessionInfo(); -} diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java deleted file mode 100755 index e7c5d9b4..00000000 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpCfg.java new file mode 100755 index 00000000..6f64d2bb --- /dev/null +++ b/framework/src/onos/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 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 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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java new file mode 100755 index 00000000..8f33ee87 --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java new file mode 100755 index 00000000..cc87eb32 --- /dev/null +++ b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java @@ -0,0 +1,117 @@ +/* + * 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 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 peer manager. + * + * @return BGPPeerManager peer manager instance + */ + BgpPeerManager peerManager(); + + /** + * Return BGP connected peers. + * + * @return connectedPeers connected peers + */ + Map connectedPeers(); + + /** + * Return BGP node listener. + * + * @return node listener + */ + Set listener(); +} diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java new file mode 100755 index 00000000..ed04dc94 --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpId.java new file mode 100755 index 00000000..7a6c625d --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java new file mode 100755 index 00000000..8b34e314 --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java new file mode 100755 index 00000000..636c1c85 --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java new file mode 100755 index 00000000..726d931b --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPacketStats.java new file mode 100755 index 00000000..8fd3c688 --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeer.java new file mode 100644 index 00000000..9f4d47da --- /dev/null +++ b/framework/src/onos/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 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 pathAttr) throws BgpParseException; + + /** + * Return the BGP session info. + * + * @return sessionInfo bgp session info + */ + BgpSessionInfo sessionInfo(); +} diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerCfg.java new file mode 100755 index 00000000..2fb970fc --- /dev/null +++ b/framework/src/onos/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/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java index d2230967..895cc145 100755 --- a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java +++ b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpPeerManager.java @@ -26,7 +26,7 @@ public interface BgpPeerManager { * * @return false if peer already exist, otherwise true */ - public boolean addConnectedPeer(BGPId bgpId, BGPPeer bgpPeer); + public boolean addConnectedPeer(BgpId bgpId, BgpPeer bgpPeer); /** * Validate wheather peer is connected. @@ -35,14 +35,14 @@ public interface BgpPeerManager { * * @return true if peer exist, otherwise false */ - public boolean isPeerConnected(BGPId bgpId); + public boolean isPeerConnected(BgpId bgpId); /** * Remove connected peer. * * @param bgpId BGP ID */ - public void removeConnectedPeer(BGPId bgpId); + public void removeConnectedPeer(BgpId bgpId); /** * Gets connected peer. @@ -50,5 +50,5 @@ public interface BgpPeerManager { * @param bgpId BGP ID * @return BGPPeer the connected peer, otherwise null */ - public BGPPeer getPeer(BGPId bgpId); + public BgpPeer getPeer(BgpId bgpId); } diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpSessionInfo.java new file mode 100755 index 00000000..a21a23d2 --- /dev/null +++ b/framework/src/onos/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(); +} -- cgit 1.2.3-korg