Mass-convert all compontents to use -no-zone addresses
[bgpcep.git] / bgp / concepts / src / main / yang / bgp-types.yang
index f860d9feb03b3f1af2b41f6ac96e9fea5a1a30ce..f3204dfeb4d160c4b651ef3ae824daeb6cea6efb 100644 (file)
@@ -3,7 +3,8 @@ module bgp-types {
     namespace "urn:opendaylight:params:xml:ns:yang:bgp-types";
     prefix "bgp-t";
 
-    import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
+    import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
+    import network-concepts { prefix netc; revision-date 2013-11-25; }
 
     organization "Cisco Systems, Inc.";
     contact "Dana Kutenicsova <dkutenic@cisco.com>";
@@ -18,6 +19,11 @@ module bgp-types {
         accompanies this distribution, and is available at
         http://www.eclipse.org/legal/epl-v10.html";
 
+    revision "2018-03-29" {
+        description "RFC6514 Extended communities";
+        reference "https://tools.ietf.org/html/rfc6514";
+    }
+
     revision "2013-09-19" {
         description
             "Initial revision.";
@@ -40,6 +46,11 @@ module bgp-types {
         }
     }
 
+    typedef bgp-id {
+        description "BGP identifier";
+        type inet:ipv4-address-no-zone;
+    }
+
     identity address-family {
         reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
     }
@@ -70,7 +81,7 @@ module bgp-types {
 
     typedef cluster-identifier {
         reference "http://tools.ietf.org/html/rfc4456#section-8";
-        type inet:ipv4-address;
+        type inet:ipv4-address-no-zone;
     }
 
     typedef short-as-number {
@@ -79,6 +90,112 @@ module bgp-types {
         }
     }
 
+    typedef route-distinguisher {
+        reference "https://tools.ietf.org/html/rfc4364#section-4.2";
+        type union {
+            type rd-two-octet-as;
+            type rd-ipv4;
+            type rd-as;
+        }
+    }
+
+    typedef rd-two-octet-as {
+        type string {
+            /* 2B AS : 4B number */
+            pattern '0:'
+                + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
+                + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
+                + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])'
+                + ':'
+                + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
+                + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
+                + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
+                + '42949672[0-8][0-9]|429496729[0-5])';
+        }
+    }
+
+    typedef rd-ipv4 {
+        type string {
+            /* IPv4 : 2B number */
+            pattern '((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
+                + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))'
+                + ':'
+                + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
+                + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
+                + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
+        }
+    }
+
+    typedef rd-as {
+        type string {
+            /* 4B AS : 2B number */
+            pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
+                + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
+                + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
+                + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
+                + '42949672[0-8][0-9]|429496729[0-5])'
+                + ':'
+                + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
+                + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
+                + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
+        }
+    }
+
+    typedef encapsulation-tunnel-type {
+        reference "http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types";
+        type enumeration {
+            enum l2tpv3-over-ip {
+                value 1;
+            }
+            enum gre {
+                value 2;
+            }
+            enum transmit-tunnel-endpoint {
+                value 3;
+            }
+            enum ipsec-tunnel-mode {
+                value 4;
+            }
+            enum ip-in-ip-ipsec-transport-mode {
+                value 5;
+            }
+            enum mpls-in-ip-tunnel-ipsec-transport-mode {
+                value 6;
+            }
+            enum ip-in-ip {
+                value 7;
+            }
+            enum vxlan {
+                value 8;
+            }
+            enum nvgre {
+                value 9;
+            }
+            enum mpls {
+                value 10;
+            }
+            enum mpls-in-gre {
+                value 11;
+            }
+            enum vxlan-gpe {
+                value 12;
+            }
+            enum mpls-in-udp {
+                value 13;
+            }
+            enum ipv6-tunnel {
+                value 14;
+            }
+        }
+    }
+
     grouping bgp-aggregator {
         reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
         description "BGP Path Attribute AGGREGATOR.";
@@ -87,7 +204,7 @@ module bgp-types {
             type inet:as-number;
         }
         leaf network-address {
-            type inet:ipv4-address;
+            type inet:ipv4-address-no-zone;
         }
     }
 
@@ -102,20 +219,143 @@ module bgp-types {
         }
     }
 
-    grouping extended-community {
-        leaf comm-type {
-            type uint8;
+    grouping route-ipv4-extended-community {
+        reference "http://tools.ietf.org/html/rfc4360";
+        leaf global-administrator {
+            type inet:ipv4-address-no-zone;
+        }
+        leaf local-administrator {
+            type uint16;
+        }
+    }
+
+    grouping link-bandwidth-extended-community {
+        reference "https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth-06#section-2";
+        description
+            "The Link Bandwidth extended community is optional non-transitive";
+
+        leaf bandwidth {
+            description "Bandwidth of the link";
+            mandatory true;
+            type netc:bandwidth;
+            units "bytes per second";
+        }
+    }
+
+    grouping as-4-spec-common {
+        container as-4-specific-common {
+            leaf as-number {
+                description "Carries a 4-octet Autonomous System (AS) number";
+                reference "https://tools.ietf.org/html/rfc5668#section-2";
+
+                mandatory true;
+                type inet:as-number;
+            }
+
+            leaf local-administrator {
+                type uint16;
+                mandatory true;
+            }
+        }
+    }
+
+    grouping encapsulation-extended-community {
+        reference "https://tools.ietf.org/html/rfc5512#section-4.5";
+        description "BGP Encapsulation extended community";
+
+        leaf tunnel-type {
+            description "Tunnel type specifying the encapsulation protocol";
+            mandatory true;
+            type encapsulation-tunnel-type;
+        }
+    }
+
+    grouping inet4-specific-extended-community-common {
+        container inet4-specific-extended-community-common {
+            leaf global-administrator {
+                type inet:ipv4-address-no-zone;
+            }
+            leaf local-administrator {
+                type binary {
+                    length "2";
+                }
+            }
+        }
+    }
+
+    grouping source-as-4-extended-community-grouping {
+        reference "https://tools.ietf.org/html/rfc6514#section-6";
+        leaf global-administrator {
+            description "Carries a 4-octet Autonomous System (AS) number";
+            reference "https://tools.ietf.org/html/rfc5668#section-2";
+
+            mandatory true;
+            type inet:as-number;
+        }
+    }
+
+    grouping source-as-extended-community-grouping {
+        reference "https://tools.ietf.org/html/rfc6514#section-6";
+        leaf global-administrator {
+            type bgp-t:short-as-number;
         }
-        leaf comm-sub-type {
-            type uint8;
+    }
+
+    grouping route-target {
+        description "Marker grouping for Route Target extended communities.";
+    }
+
+    grouping route-target-constrain-default-route-grouping {
+        container route-target-constrain-default-route {
+            uses route-target;
+            presence
+                "The presence of this container indicates that the routes
+                is a default route target";
+        }
+    }
+
+    grouping route-target-extended-community-grouping {
+        container route-target-extended-community {
+            description "Type 0x00 / Subtype 0x02";
+            reference "http://tools.ietf.org/html/rfc4360#section-4";
+            uses route-target;
+
+            leaf global-administrator {
+                type short-as-number;
+            }
+            leaf local-administrator {
+                type binary {
+                    length "4";
+                }
+            }
+        }
+    }
+
+    grouping route-target-ipv4-grouping {
+        container route-target-ipv4 {
+            description "Type 0x01 / Subtype 0x02";
+            reference "http://tools.ietf.org/html/rfc4360#section-4";
+            uses route-target;
+            uses route-ipv4-extended-community;
+        }
+    }
+
+    grouping as-4-route-target-extended-community-grouping {
+        container as-4-route-target-extended-community {
+            description "Type 0x02 / Subtype 0x02";
+            reference "https://tools.ietf.org/html/rfc5668";
+            uses route-target;
+            uses as-4-spec-common;
+        }
+    }
+
+    grouping extended-community {
+        leaf transitive {
+            type boolean;
         }
         choice extended-community {
             case as-specific-extended-community-case {
                 container as-specific-extended-community {
-                    when "../comm-type = 0 and ../comm-sub-type = 0 or ../comm-type = 40 and ../comm-sub-type = 0";
-                    leaf transitive {
-                        type boolean;
-                    }
                     leaf global-administrator {
                         type short-as-number;
                     }
@@ -128,14 +368,13 @@ module bgp-types {
             }
             case inet4-specific-extended-community-case {
                 container inet4-specific-extended-community {
-                    when "../comm-type = 1 and ../comm-sub-type = 0 or ../comm-type = 41 and ../comm-sub-type = 0";
-                    leaf transitive {
-                        type boolean;
-                    }
+                    uses inet4-specific-extended-community-common;
                     leaf global-administrator {
-                        type inet:ipv4-address;
+                        status deprecated;
+                        type inet:ipv4-address-no-zone;
                     }
                     leaf local-administrator {
+                        status deprecated;
                         type binary {
                             length "2";
                         }
@@ -144,10 +383,6 @@ module bgp-types {
             }
             case opaque-extended-community-case {
                 container opaque-extended-community {
-                    when "../comm-type = 3 and ../comm-sub-type = 0 or ../comm-type = 43 and ../comm-sub-type = 0";
-                    leaf transitive {
-                        type boolean;
-                    }
                     leaf value {
                         type binary {
                             length "6";
@@ -156,21 +391,16 @@ module bgp-types {
                 }
             }
             case route-target-extended-community-case {
-                container route-target-extended-community {
-                    when "../comm-type = 1 and ../comm-sub-type = 2 or ../comm-type = 2 and ../comm-sub-type = 2 or ../comm-type = 3 and ../comm-sub-type = 2";
-                    leaf global-administrator {
-                        type short-as-number;
-                    }
-                    leaf local-administrator {
-                        type binary {
-                            length "4";
-                        }
-                    }
-                }
+                uses route-target-extended-community-grouping;
+            }
+            case route-target-ipv4-case {
+                uses route-target-ipv4-grouping;
+            }
+            case as-4-route-target-extended-community-case {
+                uses as-4-route-target-extended-community-grouping;
             }
             case route-origin-extended-community-case {
                 container route-origin-extended-community {
-                    when "../comm-type = 1 and ../comm-sub-type = 3 or ../comm-type = 2 and ../comm-sub-type = 3 or ../comm-type = 3 and ../comm-sub-type = 3";
                     leaf global-administrator {
                         type short-as-number;
                     }
@@ -181,16 +411,62 @@ module bgp-types {
                     }
                 }
             }
+            case route-origin-ipv4-case {
+                container route-origin-ipv4 {
+                    reference "http://tools.ietf.org/html/rfc4360#section-5";
+                    uses route-ipv4-extended-community;
+                }
+            }
+            case link-bandwidth-case {
+                container link-bandwidth-extended-community {
+                    uses link-bandwidth-extended-community;
+                }
+            }
+            case as-4-generic-spec-extended-community-case {
+                container as-4-generic-spec-extended-community {
+                    reference "https://www.ietf.org/archive/id/draft-ietf-idr-as4octet-extcomm-generic-subtype-08.txt";
+                    uses as-4-spec-common;
+                }
+            }
+            case as-4-route-origin-extended-community-case {
+                container as-4-route-origin-extended-community {
+                    reference "https://tools.ietf.org/html/rfc5668";
+                    uses as-4-spec-common;
+                }
+            }
+            case encapsulation-case {
+                container encapsulation-extended-community {
+                    uses encapsulation-extended-community;
+                }
+            }
+            case vrf-route-import-extended-community-case {
+                reference "https://tools.ietf.org/html/rfc6514#section-7";
+                container vrf-route-import-extended-community {
+                    uses inet4-specific-extended-community-common;
+                }
+            }
+            case source-as-4-extended-community-case {
+                container source-as-4-extended-community {
+                    uses source-as-4-extended-community-grouping;
+                }
+            }
+            case source-as-extended-community-case {
+                container source-as-extended-community {
+                    uses source-as-extended-community-grouping;
+                }
+            }
         }
     }
 
     grouping next-hop {
         choice c-next-hop {
+            default empty-next-hop-case;
             case ipv4-next-hop-case {
                 container ipv4-next-hop {
                     reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
                     leaf global {
-                        type inet:ipv4-address;
+                        type inet:ipv4-address-no-zone;
+                        mandatory true;
                     }
                 }
             }
@@ -198,35 +474,45 @@ module bgp-types {
                 container ipv6-next-hop {
                     reference "http://tools.ietf.org/html/rfc4760#section-3";
                     leaf global {
-                        type inet:ipv6-address;
+                        type inet:ipv6-address-no-zone;
+                        mandatory true;
                     }
                     leaf link-local {
-                        type inet:ipv6-address;
+                        type inet:ipv6-address-no-zone;
                     }
                 }
             }
+            case empty-next-hop-case {
+                leaf empty-next-hop {
+                    type empty;
+                }
+            }
         }
     }
 
     grouping as-path-segment {
         reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
-        choice c-segment {
-            case a-set-case {
-                container a-set {
-                    leaf-list as-set {
-                        type inet:as-number;
-                    }
-                }
-            }
-            case a-list-case {
-                container a-list {
-                    list as-sequence {
-                        leaf as {
-                            type inet:as-number;
-                        }
-                    }
-                }
-            }
+        leaf-list as-sequence {
+            type inet:as-number;
+            ordered-by user;
+            max-elements "255";
+        }
+        leaf-list as-set {
+            type inet:as-number;
+        }
+    }
+
+    grouping route-distinguisher-grouping {
+        leaf route-distinguisher {
+            type route-distinguisher;
+            mandatory true;
+        }
+    }
+
+    grouping orig-route-ip-grouping {
+        leaf orig-route-ip {
+            type inet:ip-address-no-zone;
+            mandatory true;
         }
     }
 }