BUG-338 Allow incomming BGP connections.
[bgpcep.git] / bgp / rib-impl-config / src / main / yang / bgp-rib-impl.yang
index b0df01aae22db95c7a04fe25fceb6a32e3fd0ea9..05fea88a163fcb8677bf376ef51164484eb8eadd 100644 (file)
@@ -144,6 +144,30 @@ module bgp-rib-impl {
         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.RIB";
     }
 
+    identity bgp-peer-registry {
+        description
+            "Registry of BGP peers. Every new BGP in/out connection looks for peers to handle bgp messages in this registry";
+
+        base "config:service-type";
+        config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry";
+    }
+
+    identity strict-bgp-peer-registry {
+        description
+            "Registry of BGP peers that allows only one connection per 2 peers. Uses IP address for Peer identification and BGP Ids to resolve duplicate connections";
+
+        config:provided-service bgp-peer-registry;
+        base config:module-type;
+        config:java-name-prefix StrictBgpPeerRegistry;
+    }
+
+
+     augment "/config:modules/config:module/config:configuration" {
+        case strict-bgp-peer-registry {
+            when "/config:modules/config:module/config:type = 'strict-bgp-peer-registry'";
+        }
+    }
+
     identity bgp-peer {
         description
             "BGP peer instance.";
@@ -152,6 +176,50 @@ module bgp-rib-impl {
         config:java-name-prefix BGPPeer;
     }
 
+    identity bgp-peer-acceptor {
+        description
+            "BGP peer acceptor that handles incomming bgp connections. Uses BGP peer registry to accept or decline incomming connections";
+
+        base config:module-type;
+        config:java-name-prefix BGPPeerAcceptor;
+    }
+
+     augment "/config:modules/config:module/config:configuration" {
+        case bgp-peer-acceptor {
+            when "/config:modules/config:module/config:type = 'bgp-peer-acceptor'";
+
+            leaf binding-address {
+                description "IP address to bind to";
+                type inet:ip-address;
+                default "0.0.0.0";
+            }
+
+            leaf binding-port {
+                description "Port to bind to";
+                type inet:port-number;
+                default "179";
+            }
+
+            container bgp-dispatcher {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity bgp-dispatcher;
+                    }
+                }
+            }
+
+            container peer-registry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity bgp-peer-registry;
+                    }
+                }
+            }
+        }
+    }
+
     identity bgp-table-type {
         description
             "Service representing a AFI/SAFI pair";
@@ -209,6 +277,13 @@ module bgp-rib-impl {
                 default 180;
             }
 
+            leaf initiate-connection {
+                description "If true, connection will be initiated right away from current device.
+                    If not, the peer will only be registered to peer registry and available for incomming bgp connections.";
+                type boolean;
+                default true;
+            }
+
             list advertized-table {
                 uses config:service-ref {
                     refine type {
@@ -238,6 +313,17 @@ module bgp-rib-impl {
                     }
                 }
             }
+
+            container peer-registry {
+                description "BGP peer registry where current instance of BGP peer will be registered.";
+                uses config:service-ref {
+                    refine type {
+                        // FIXME backwards compatibility. If not configured, GLOBAL instance is used
+                        mandatory false;
+                        config:required-identity bgp-peer-registry;
+                    }
+                }
+            }
         }
     }