[Goldeneye] [ONOS-4161] BGP L3 Topology
Change-Id: I81ae4e88f6ab75202b98ed03cbe1597d0f6ddd1e
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
old mode 100755
new mode 100644
index 768e764..338c472
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
@@ -128,4 +128,25 @@
* @return node listener
*/
Set<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);
+
+ /**
+ * Return BGP link listener.
+ *
+ * @return link listener
+ */
+ Set<BgpLinkListener> linkListener();
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
old mode 100755
new mode 100644
index efa3b14..0acfb78
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
@@ -20,12 +20,9 @@
import java.util.List;
import java.util.ListIterator;
-import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-import org.onosproject.bgpio.types.AreaIDTlv;
import org.onosproject.bgpio.types.AutonomousSystemTlv;
import org.onosproject.bgpio.types.BgpLSIdentifierTlv;
import org.onosproject.bgpio.types.BgpValueType;
@@ -49,9 +46,9 @@
public static final int NODE_DESCRIPTOR_REMOTE = 2;
/**
- * Initialize bgp id to generate URI.
+ * Initialize BGP id to generate URI.
*
- * @param linkNlri node Nlri.
+ * @param linkNlri node NLRI.
* @param nodeDescriptorType node descriptor type, local/remote
*/
public BgpDpid(final BgpLinkLsNlriVer4 linkNlri, int nodeDescriptorType) {
@@ -61,26 +58,13 @@
this.stringBuilder.append("RD=").append(linkNlri.getRouteDistinguisher()
.getRouteDistinguisher()).append(":");
}
+ this.stringBuilder.append(":ROUTINGUNIVERSE=").append(((BgpLinkLsNlriVer4) linkNlri).getIdentifier());
- try {
- if ((linkNlri.getProtocolId() == BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_ONE)
- || (linkNlri.getProtocolId() == BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO)) {
- this.stringBuilder.append("PROTO=").append("ISIS").append(":ID=")
- .append(linkNlri.getIdentifier());
- } else {
- this.stringBuilder.append("PROTO=").append(linkNlri.getProtocolId()).append(":ID=")
- .append(linkNlri.getIdentifier());
- }
-
- 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());
+ if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) {
+ add(linkNlri.localNodeDescriptors());
+ } else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) {
+ add(linkNlri.remoteNodeDescriptors());
}
-
}
/*
@@ -96,72 +80,52 @@
}
/**
- * Initialize bgp id to generate URI.
+ * Initialize BGP id to generate URI.
*
- * @param nodeNlri node Nlri.
+ * @param nlri node NLRI.
*/
- public BgpDpid(final BgpNodeLSNlriVer4 nodeNlri) {
+ public BgpDpid(final BgpNodeLSNlriVer4 nlri) {
this.stringBuilder = new StringBuilder("");
-
- if (nodeNlri.getRouteDistinguisher() != null) {
- this.stringBuilder.append("RD=").append(nodeNlri.getRouteDistinguisher()
- .getRouteDistinguisher()).append(":");
+ if (((BgpNodeLSNlriVer4) nlri).getRouteDistinguisher() != null) {
+ this.stringBuilder.append("RD=")
+ .append(((BgpNodeLSNlriVer4) nlri).getRouteDistinguisher().getRouteDistinguisher()).append(":");
}
- try {
- if ((nodeNlri.getProtocolId() == BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_ONE)
- || (nodeNlri.getProtocolId() == BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO)) {
-
- this.stringBuilder.append("PROTO=").append("ISIS").append(":ID=")
- .append(nodeNlri.getIdentifier());
- } else {
- this.stringBuilder.append("PROTO=").append(nodeNlri.getProtocolId()).append(":ID=")
- .append(nodeNlri.getIdentifier());
- }
- add(nodeNlri.getLocalNodeDescriptors());
-
- } catch (BgpParseException e) {
- log.info("Exception node string: " + e.toString());
- }
+ this.stringBuilder.append(":ROUTINGUNIVERSE=").append(((BgpNodeLSNlriVer4) nlri).getIdentifier());
+ add(((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors().getNodedescriptors());
+ log.info("BgpDpid :: add");
}
- BgpDpid add(final Object value) {
- NodeDescriptors nodeDescriptors = null;
- if (value instanceof BgpNodeLSIdentifier) {
- BgpNodeLSIdentifier nodeLsIdentifier = (BgpNodeLSIdentifier) value;
- nodeDescriptors = nodeLsIdentifier.getNodedescriptors();
- } else if (value instanceof NodeDescriptors) {
- nodeDescriptors = (NodeDescriptors) value;
- }
-
- if (nodeDescriptors != null) {
- List<BgpValueType> subTlvs = nodeDescriptors.getSubTlvs();
+ /**
+ * Obtains instance of this class by appending stringBuilder with node descriptor value.
+ *
+ * @param value node descriptor
+ * @return instance of this class
+ */
+ public BgpDpid add(final NodeDescriptors value) {
+ log.info("BgpDpid :: add function");
+ if (value != null) {
+ List<BgpValueType> subTlvs = value.getSubTlvs();
ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
while (listIterator.hasNext()) {
BgpValueType tlv = listIterator.next();
if (tlv.getType() == AutonomousSystemTlv.TYPE) {
- AutonomousSystemTlv autonomousSystem = (AutonomousSystemTlv) tlv;
- this.stringBuilder.append(":AS=").append(autonomousSystem.getAsNum());
+ this.stringBuilder.append(":ASN=").append(((AutonomousSystemTlv) tlv).getAsNum());
} else if (tlv.getType() == BgpLSIdentifierTlv.TYPE) {
- BgpLSIdentifierTlv lsIdentifierTlv = (BgpLSIdentifierTlv) tlv;
- this.stringBuilder.append(":LSID=").append(lsIdentifierTlv.getBgpLsIdentifier());
- } else if (tlv.getType() == AreaIDTlv.TYPE) {
- AreaIDTlv areaIdTlv = (AreaIDTlv) tlv;
- this.stringBuilder.append(":AREA=").append(areaIdTlv.getAreaID());
+ this.stringBuilder.append(":DOMAINID=").append(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier());
} else if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
if (tlv instanceof IsIsNonPseudonode) {
- IsIsNonPseudonode isisNonPseudonode = (IsIsNonPseudonode) tlv;
- this.stringBuilder.append(":ISOID=").append(isoNodeIdString(isisNonPseudonode.getIsoNodeId()));
+ this.stringBuilder.append(":ISOID=").append(
+ isoNodeIdString(((IsIsNonPseudonode) tlv).getIsoNodeId()));
} else if (tlv instanceof IsIsPseudonode) {
- IsIsPseudonode isisPseudonode = (IsIsPseudonode) tlv;
- this.stringBuilder.append(":ISOID=").append(isoNodeIdString(isisPseudonode.getIsoNodeId()));
+ IsIsPseudonode isisPseudonode = ((IsIsPseudonode) tlv);
+ this.stringBuilder.append(":ISOID=").append(
+ isoNodeIdString(((IsIsPseudonode) tlv).getIsoNodeId()));
this.stringBuilder.append(":PSN=").append(isisPseudonode.getPsnIdentifier());
} else if (tlv instanceof OspfNonPseudonode) {
- OspfNonPseudonode ospfNonPseudonode = (OspfNonPseudonode) tlv;
- this.stringBuilder.append(":RID=").append(ospfNonPseudonode.getrouterID());
+ this.stringBuilder.append(":RID=").append(((OspfNonPseudonode) tlv).getrouterID());
} else if (tlv instanceof OspfPseudonode) {
- OspfPseudonode ospfPseudonode = (OspfPseudonode) tlv;
- this.stringBuilder.append(":RID=").append(ospfPseudonode.getrouterID());
+ this.stringBuilder.append(":RID=").append(((OspfPseudonode) tlv).getrouterID());
}
}
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java
index 8b34e31..9ecfb77 100755
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLinkListener.java
@@ -12,24 +12,29 @@
*/
package org.onosproject.bgp.controller;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
/**
- * Allows for providers interested in Link events to be notified.
+ * 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.
+ * Notify that got a packet of link from network and adds link.
*
- * @param linkNlri bgp link
+ * @param linkNlri BGP link NLRI
+ * @param details path attributes and NLRI information
+ * @throws BgpParseException BGP parse exception
*/
- void addLink(BgpLinkLsNlriVer4 linkNlri);
+ void addLink(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details) throws BgpParseException;
/**
- * Notify that got a packet of link from network and need do processing.
+ * Notify that got a packet of link from network and remove link.
*
- * @param linkNlri bgp link
+ * @param linkNlri BGP link NLRI
+ * @throws BgpParseException BGP parse exception
*/
- void deleteLink(BgpLinkLsNlriVer4 linkNlri);
+ void deleteLink(BgpLinkLsNlriVer4 linkNlri) throws BgpParseException;
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
index 636c1c8..d811b27 100755
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
@@ -13,6 +13,7 @@
package org.onosproject.bgp.controller;
+import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.protocol.BgpLSNlri;
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
import org.onosproject.bgpio.types.RouteDistinguisher;
@@ -27,16 +28,18 @@
*
* @param sessionInfo session info
* @param nlri network layer reach info
- * @param details nlri details
+ * @param details path attributes and NLRI information
+ * @throws BgpParseException while adding NLRI to local rib
*/
- void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details);
+ void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details) throws BgpParseException;
/**
* Removes NLRI identifier if it exists.
*
* @param nlri info
+ * @throws BgpParseException while deleting NLRI from local rib
*/
- void delete(BgpLSNlri nlri);
+ void delete(BgpLSNlri nlri) throws BgpParseException;
/**
* Update NLRI identifier mapped with route distinguisher if it exists in tree otherwise add NLRI infomation mapped
@@ -46,15 +49,17 @@
* @param nlri info
* @param details has pathattribute, protocol id and identifier
* @param routeDistinguisher unique for each VPN
+ * @throws BgpParseException while adding NLRI updation
*/
void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details,
- RouteDistinguisher routeDistinguisher);
+ RouteDistinguisher routeDistinguisher) throws BgpParseException;
/**
* Removes VPN NLRI identifier mapped to route distinguisher if it exists.
*
* @param nlri info
* @param routeDistinguisher unique for each VPN
+ * @throws BgpParseException while deleting NLRI from local rib
*/
- void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher);
+ void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) throws BgpParseException;
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java
index 726d931..121f339 100755
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpNodeListener.java
@@ -13,6 +13,7 @@
package org.onosproject.bgp.controller;
import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
/**
* Allows for providers interested in node events to be notified.
@@ -22,14 +23,15 @@
/**
* Notifies that the node was added.
*
- * @param nodeNlri node rechability info
+ * @param nodeNlri node reachability info
+ * @param details attributes and nlri details
*/
- void addNode(BgpNodeLSNlriVer4 nodeNlri);
+ void addNode(BgpNodeLSNlriVer4 nodeNlri, PathAttrNlriDetails details);
/**
* Notifies that the node was removed.
*
- * @param nodeNlri node rechability info
+ * @param nodeNlri node reachability info
*/
void deleteNode(BgpNodeLSNlriVer4 nodeNlri);
}