BUG-338 Allow incomming BGP connections.
[bgpcep.git] / bgp / rib-impl-config / src / main / yang / bgp-rib-impl.yang
index 328572bb83595401926a2ebdac4854587a8c36b4..05fea88a163fcb8677bf376ef51164484eb8eadd 100644 (file)
@@ -4,14 +4,19 @@ module bgp-rib-impl {
     namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl";
     prefix "bgprib-impl";
 
-    import bgp-listener { prefix bgpl; revision-date 2013-04-09; }
+    import bgp-multiprotocol { prefix bgp-mp; revision-date 2013-09-19; }
+    import bgp-rib { prefix rib; revision-date 2013-09-25; }
+    import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
     import config-bgp-rib { prefix bgprib; revision-date 2013-07-01; }
     import config-bgp-parser-spi { prefix bgpspi; revision-date 2013-11-15; }
     import config-bgp-rib-spi { prefix ribspi; revision-date 2013-11-15; }
+    import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
     import opendaylight-md-sal-binding {prefix mdsb; revision-date 2013-10-28; }
     import netty { prefix netty; revision-date 2013-11-19; }
-    import reconnect-strategy { prefix rs; revision-date 2013-11-09; }
     import config { prefix config; revision-date 2013-04-05; }
+    import protocol-framework { prefix pf; revision-date 2014-03-13; }
+    import odl-tcpmd5-cfg { prefix tcpmd5; revision-date 2014-04-27; }
+    import odl-tcpmd5-netty-cfg { prefix tcpmd5n; revision-date 2014-04-27; }
 
     organization "Cisco Systems, Inc.";
 
@@ -22,11 +27,11 @@ module bgp-rib-impl {
          BGP listener implementation.
 
         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.;
-        
+
         This program and the accompanying materials are made available
-               under the terms of the Eclipse Public License v1.0 which
-               accompanies this distribution, and is available at
-               http://www.eclipse.org/legal/epl-v10.html";
+        under the terms of the Eclipse Public License v1.0 which
+        accompanies this distribution, and is available at
+        http://www.eclipse.org/legal/epl-v10.html";
 
     revision "2013-04-09" {
         description
@@ -36,55 +41,12 @@ module bgp-rib-impl {
     identity base-bgp-parser {
         base config:module-type;
         config:java-name-prefix BaseBGPParser;
+        config:provided-service bgpspi:extension;
     }
 
     augment "/config:modules/config:module/config:configuration" {
         case base-bgp-parser {
             when "/config:modules/config:module/config:type = 'base-bgp-parser'";
-
-            container bgp-extensions {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity bgpspi:extensions;
-                    }
-                }
-            }
-        }
-    }
-
-    identity bgp-proposal {
-        description
-            "Service representing a BGP proposal.";
-
-        base "config:service-type";
-        config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal";
-    }
-
-    identity bgp-proposal-impl {
-        base config:module-type;
-        config:provided-service bgp-proposal;
-        config:java-name-prefix BGPSessionProposalImpl;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case bgp-proposal-impl {
-            when "/config:modules/config:module/config:type = 'bgp-proposal-impl'";
-
-            leaf holdtimer {
-                type int16;
-                default 180;
-            }
-
-            leaf bgp-id {
-                mandatory true;
-                type string;
-            }
-
-            leaf as-number {
-                mandatory true;
-                type int32;
-            }
         }
     }
 
@@ -114,7 +76,16 @@ module bgp-rib-impl {
                     }
                 }
             }
-            
+
+            container timer {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity netty:netty-timer;
+                    }
+                }
+            }
+
             container boss-group {
                 uses config:service-ref {
                     refine type {
@@ -123,7 +94,7 @@ module bgp-rib-impl {
                     }
                 }
             }
-            
+
             container worker-group {
                 uses config:service-ref {
                     refine type {
@@ -132,19 +103,102 @@ module bgp-rib-impl {
                     }
                 }
             }
+
+            container md5-channel-factory {
+                uses config:service-ref {
+                    refine type {
+                        mandatory false;
+                        config:required-identity tcpmd5n:md5-channel-factory;
+                    }
+                }
+            }
+
+            container md5-server-channel-factory {
+                uses config:service-ref {
+                    refine type {
+                        mandatory false;
+                        config:required-identity tcpmd5n:md5-server-channel-factory;
+                    }
+                }
+            }
         }
     }
 
-    identity bgp-impl {
+    identity base-bgp-rib {
         base config:module-type;
-            config:provided-service bgpl:listener;
-        config:java-name-prefix BGPImpl;
-
+        config:provided-service ribspi:extension;
+        config:java-name-prefix BaseBGPRIB;
     }
 
     augment "/config:modules/config:module/config:configuration" {
-        case bgp-impl {
-            when "/config:modules/config:module/config:type = 'bgp-impl'";
+        case base-bgp-rib {
+            when "/config:modules/config:module/config:type = 'base-bgp-rib'";
+        }
+    }
+
+    identity rib-instance {
+        description
+            "Service representing a RIB instance";
+
+        base "config:service-type";
+        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.";
+
+        base config:module-type;
+        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 {
@@ -155,23 +209,120 @@ module bgp-rib-impl {
                 }
             }
 
-            container bgp-proposal {
+            container peer-registry {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
-                        config:required-identity bgp-proposal;
+                        config:required-identity bgp-peer-registry;
                     }
                 }
             }
+        }
+    }
+
+    identity bgp-table-type {
+        description
+            "Service representing a AFI/SAFI pair";
+
+        base "config:service-type";
+        config:java-class "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType";
+    }
+
+    identity bgp-table-type-impl {
+        description
+            "Simple provider for bgp-table-type.";
+
+        config:provided-service bgp-table-type;
+        base config:module-type;
+        config:java-name-prefix BGPTableTypeImpl;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case bgp-table-type-impl {
+            when "/config:modules/config:module/config:type = 'bgp-table-type-impl'";
+
+            leaf afi {
+                type identityref {
+                    base bgp-t:address-family;
+                }
+                mandatory true;
+            }
+            leaf safi {
+                type identityref {
+                    base bgp-t:subsequent-address-family;
+                }
+                mandatory true;
+            }
+        }
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case bgp-peer {
+            when "/config:modules/config:module/config:type = 'bgp-peer'";
 
             leaf host {
-                 mandatory true;
-                 type string;
+                description "Remote host IP address";
+                type inet:ip-address;
+                mandatory true;
             }
 
             leaf port {
-                 mandatory true;
-                 type uint16;
+                description "Remote host port";
+                type inet:port-number;
+                default 179;
+            }
+
+            leaf holdtimer {
+                type int16;
+                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 {
+                        mandatory true;
+                        config:required-identity bgp-table-type;
+                    }
+                }
+            }
+
+            leaf remote-as {
+                description
+                    "Expected remote AS number. If not present, it is assumed
+                    to be the same as our local AS number.";
+                type uint32;
+            }
+
+            leaf password {
+                type tcpmd5:rfc2385-key;
+                description "RFC2385 shared secret";
+            }
+
+            container rib {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity rib-instance;
+                    }
+                }
+            }
+
+            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;
+                    }
+                }
             }
         }
     }
@@ -179,50 +330,50 @@ module bgp-rib-impl {
     identity rib-impl {
         base config:module-type;
         config:provided-service bgprib:rib;
+        config:provided-service rib-instance;
         config:java-name-prefix RIBImpl;
     }
 
-
     augment "/config:modules/config:module/config:configuration" {
         case rib-impl {
             when "/config:modules/config:module/config:type = 'rib-impl'";
 
-            container bgp {
+            container extensions {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
-                        config:required-identity bgpl:listener;
+                        config:required-identity ribspi:consumer-extensions;
                     }
                 }
             }
 
-            container extensions {
+            container bgp-dispatcher {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
-                        config:required-identity ribspi:consumer-extensions;
+                        config:required-identity bgp-dispatcher;
                     }
                 }
             }
-                       
+
             container session-reconnect-strategy {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
-                        config:required-identity rs:reconnect-strategy;
+                        config:required-identity pf:reconnect-strategy-factory;
                     }
                 }
-            }                  
-            
+            }
+
             container tcp-reconnect-strategy {
                 uses config:service-ref {
                     refine type {
                         mandatory true;
-                        config:required-identity rs:reconnect-strategy;
+                        config:required-identity pf:reconnect-strategy-factory;
                     }
                 }
             }
-                       
+
             container data-provider {
                 uses config:service-ref {
                     refine type {
@@ -231,6 +382,33 @@ module bgp-rib-impl {
                     }
                 }
             }
+
+            leaf local-as {
+                description "Our local AS number. Needed by best selection path attribute.";
+                type uint32;
+                mandatory true;
+            }
+
+            leaf bgp-id {
+                description "Our local BGP identifier. Needed by best selection path attribute.";
+                mandatory true;
+                type inet:ipv4-address;
+            }
+
+            list local-table {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity bgp-table-type;
+                    }
+                }
+            }
+
+            leaf rib-id {
+                description "Identifier of this RIB in local data store.";
+                type rib:rib-id;
+                mandatory true;
+            }
         }
     }
 }