<?xml version="1.0" encoding="US-ASCII"?>

<!DOCTYPE rfc [
<!ENTITY I-D.ietf-netmod-rfc6991-bis PUBLIC "" "https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.draft-ietf-netmod-rfc6991-bis-17.xml">
<!ENTITY IEEE.1003-2.1992 PUBLIC "" "https://bib.ietf.org/public/rfc/bibxml6/reference.R.IEEE.1003-2.1992.xml">
<!ENTITY RFC1912 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1912.xml">
<!ENTITY RFC1930 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1930.xml">
<!ENTITY RFC1997 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1997.xml">
<!ENTITY RFC2119 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3688 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3688.xml">
<!ENTITY RFC4360 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4360.xml">
<!ENTITY RFC4384 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4384.xml">
<!ENTITY RFC6020 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6020.xml">
<!ENTITY RFC7942 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7942.xml">
<!ENTITY RFC7950 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7950.xml">
<!ENTITY RFC7951 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7951.xml">
<!ENTITY RFC8092 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8092.xml">
<!ENTITY RFC8174 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml">
<!ENTITY RFC8195 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8195.xml">
<!ENTITY RFC8340 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8340.xml">
<!ENTITY RFC8792 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8792.xml">
<!ENTITY RFC9595 PUBLIC "" "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9595.xml">
]>

<?rfc strict="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     category="std"
     docName="draft-ietf-grow-yang-bgp-communities-03"
     ipr="trust200902"
     xml:lang="en"
     submissionType="IETF"
     version="3">

  <front>

    <title abbrev="BGP Community YANG">A YANG Data Model for BGP Communities</title>

    <seriesInfo name="Internet-Draft" value="draft-ietf-grow-yang-bgp-communities-03"/>

    <author fullname="Martin Pels" initials="M" surname="Pels">
      <organization>RIPE NCC</organization>
      <address>
        <postal>
          <country>Netherlands</country>
        </postal>
        <email>mpels@ripe.net</email>
      </address>
    </author>

    <date />

    <abstract>
      <t>
        This document defines a YANG data model for the structured specification of BGP communities.
        The model provides operators with a way to publish their locally defined BGP communities in a standardized format.
      </t>
    </abstract>
  </front>

  <middle>

    <section title="Introduction" anchor="intro">

      <t>
        ISPs use BGP communities to add information to their prefix announcements or to let customers influence routing behaviour inside the network of the ISP.
        Each ISP defines for itself which BGP communities to support and how the structure of these communities should be interpreted.
        This document provides a YANG<xref target="RFC7950"/> module for describing the structure and meaning of BGP communities<xref target="RFC1997"/>, Extended BGP communities<xref target="RFC4360"/> and Large BGP communities<xref target="RFC8092"/>.
        ISPs can use this standardized format to publish their community definitions.
        <xref target="rationale"/> elaborates on further advantages of using such a standardized format.
      </t>

    </section>

    <section title="Terminology" anchor="terminology">
       <t>
         The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
         NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
         "MAY", and "OPTIONAL" in this document are to be interpreted as
         described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/>
         when, and only when, they appear in all capitals, as shown here.
      </t>
      <t>
        The meaning of the symbols in tree diagrams are defined in <xref target="RFC8340"/>.
      </t>
    </section>

    <section title="Rationale" anchor="rationale">

      <t>
        ISPs may define various BGP communities that have local significance within their network.
        These communities could be used to add miscellaneous information to a prefix announcement.
        For example, a community "64501:1:528" may signify that the AS with ASN 64501 is originating a prefix from a point of presence in The Netherlands (ISO 3166-1 code 528).
        Communities could be used to allow customers of an ISP to control the routing behavior of their prefixes inside the ISP.
        For example, a community "64501:4:64498" attached to a prefix advertised to AS64501 by a customer may be interpreted by AS64501 to mean that this prefix must not be propagated to AS64498.
      </t>
      <t>
        For both use cases it is necessary for the ISP to communicate the meaning of their locally defined communities to others.
        Currently this is typically done by publishing a list of communities on a web page, or as a remark inside an "autnum" object in the Internet Routing Registry.
        This makes it cumbersome to determine whether and where an ISP publishes community information.
        The lack of a well-defined structure makes it hard to create a standardized publishing mechanism, and to develop tools for automatically parsing community information and eventually triggering configuration actions.
      </t>
      <t>
        The purpose of the YANG model defined in this document is to provide a standardized format for publishing community definitions.
        These definitions help applications to interpret the structure and purpose of BGP communities.
        For example, looking glasses may use the published definitions to parse communities seen in BGP announcements and display their meaning.
        Another potential use case is in generating routing policy configurations based on community definitions published by an upstream ASN.
        This could be achieved automatically using external tooling to generate router configurations, or inside a router's command-line interface by importing the definitions and providing the CLI-user with available choices for manual configuration.
      </t>
      <t>
        This document only describes a data model for the publishing format of community definitions.
        The publishing location and publishing mechanism used are outside the scope of this specification.
        The data model does not make any assumption about the protocol used to publish/retrieve formatted data following the model.
      </t>

    </section>

    <section title="Tree view" anchor="tree">

      <t>
        The following tree diagram provides an overview of the "ietf-grow-yang-bgp-communities" data model.
      </t>
      <sourcecode>
module: ietf-grow-yang-bgp-communities
  +--rw bgp-communities
     +--rw serial?        uint32
     +--rw uri?           inet:uri
     +--rw description?   string
     +--rw contact-url?   inet:uri
     +--rw contact* [email-address]
     |  +--rw email-address          inet:email-address
     |  +--rw name?                  string
     |  +--rw role?                  string
     |  +--rw organization?          string
     |  +--rw organizational-unit?   string
     +--rw regular* [name]
     |  +--rw name            community-name
     |  +--rw category?       community-category
     |  +--rw description?    community-description
     |  +--rw global-admin    two-octet-as-number
     |  +--rw local-admin
     |     +--rw format?   local-admin-format
     |     +--rw field* [name]
     |        +--rw name           field-name
     |        +--rw length?        uint8
     |        +--rw pattern        field-pattern
     |        +--rw description?   field-description
     +--rw extended* [name]
     |  +--rw name              community-name
     |  +--rw category?         community-category
     |  +--rw description?      community-description
     |  +--rw type              uint8
     |  +--rw subtype           uint8
     |  +--rw (global-admin)
     |  |  +--:(asn)
     |  |  |  +--rw asn?   two-octet-as-number
     |  |  +--:(asn4)
     |  |     +--rw asn4?   inet:as-number
     |  +--rw local-admin
     |     +--rw format?   local-admin-format
     |     +--rw field* [name]
     |        +--rw name           field-name
     |        +--rw length?        uint8
     |        +--rw pattern        field-pattern
     |        +--rw description?   field-description
     +--rw large* [name]
        +--rw name                 community-name
        +--rw category?            community-category
        +--rw description?         community-description
        +--rw global-admin         inet:as-number
        +--rw local-data-part-1
        |  +--rw format?   local-admin-format
        |  +--rw field* [name]
        |     +--rw name           field-name
        |     +--rw length?        uint8
        |     +--rw pattern        field-pattern
        |     +--rw description?   field-description
        +--rw local-data-part-2
           +--rw format?   local-admin-format
           +--rw field* [name]
              +--rw name           field-name
              +--rw length?        uint8
              +--rw pattern        field-pattern
              +--rw description?   field-description
      </sourcecode>
    </section>

    <section title="YANG Module" anchor="module">
      <t>
        This section contains the complete YANG module defined in this document.
        A break-down of the individual elements in this module can be found in <xref target="elements"/>.
      </t>
      <sourcecode>
<![CDATA[
<CODE BEGINS> file "ietf-grow-yang-bgp-communities@2025-02-13.yang"

module ietf-grow-yang-bgp-communities {
  yang-version 1.1;
  namespace
    "urn:ietf:params:xml:ns:yang:ietf-grow-yang-bgp-communities";
  prefix bgp-comm;

  import ietf-inet-types {
    prefix inet;
    reference
      "draft-ietf-netmod-rfc6991-bis-17: Common YANG Data Types";
  }

  organization
    "IETF GROW Working Group";
  contact
    "WG Web:   <https://datatracker.ietf.org/wg/grow/>
     WG List:  <mailto:grow@ietf.org>

     Author:   Martin Pels
       <mailto:mpels@ripe.net>";
  description
    "This module describes a structure for BGP Communities

     Copyright (c) 2025 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject to
     the license terms contained in, the Revised BSD License set
     forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (https://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC YYYY; see
     the RFC itself for full legal notices.

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
     NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
     'MAY', and 'OPTIONAL' in this document are to be interpreted as
     described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
     they appear in all capitals, as shown here.";

  // RFC-EDITOR: please update YYYY with this RFC ID

  revision 2025-02-13 {
    description
      "Initial revision.";
    reference
      "RFC YYYY: YANG Module for BGP Communities
       RFC-EDITOR: please update YYYY with this RFC ID";
  }

  typedef two-octet-as-number {
    type uint16;
    description
      "This type represents autonomous system numbers, which
       identify an Autonomous System (AS).

       Autonomous system numbers were originally limited to 16
       bits.  BGP extensions have enlarged the autonomous system
       number space to 32 bits.  The two-octet-as-number type uses
       an uint16 base type for use cases where the enlarged number
       space is not supported.";
    reference
      "RFC 1930: Guidelines for creation, selection, and
       registration of an Autonomous System (AS)";
  }

  typedef community-name {
    type string {
      length "1..255";
      pattern '[^ \t\r\n\p{C}]+';
    }
    description
      "This type restricts values for the name of a BGP community.";
  }

  typedef community-category {
    type enumeration {
      enum informational {
        value 0;
        description
          "Informational community";
      }
      enum action {
        value 1;
        description
          "Action community";
      }
    }
    description
      "This type restricts values for the category of a BGP
       community.";
  }

  typedef community-description {
    type string {
      length "1..65535";
      pattern '[^\p{C}]+';
    }
    description
      "This type restricts values for the description of a BGP
       community.";
  }

  typedef local-admin-format {
    type enumeration {
      enum decimal {
        value 0;
        description
          "Decimal number string";
      }
      enum binary {
        value 1;
        description
          "Bit string";
      }
    }
    description
      "This type defines the format options for a BGP community
       Local Administrator/Local Data field encoding";
  }

  typedef field-name {
    type string {
      length "1..255";
      pattern '[^ \t\r\n\p{C}]+';
    }
    description
      "This type restricts values for the name leaf of a BGP
       community Local Administrator/Local Data field.";
  }

  typedef field-pattern {
    type string {
      length "1..4095";
      pattern '[-0-9.,*?^$+|(){}\[\]]+';
    }
    description
      "This type restricts values for the pattern leaf of a BGP
       community Local Administrator/Local Data field.  Patterns
       are described as POSIX Extended Regular Expressions";
    reference
      "IEEE 1003.2-1992: Information Technology - Portable
       Operating System Interface (POSIX) - Part 2: Shell and
       Utilities (Vol. 1)";
  }

  typedef field-description {
    type string {
      length "1..65535";
      pattern '[^\p{C}]+';
    }
    description
      "This type restricts values for the description leaf of a BGP
       community Local Administrator/Local Data field.";
  }

  grouping local-admin-fields {
    description
      "A group of subfields inside the Local Administrator/Local
       Data section of a BGP Community";
    list field {
      key "name";
      ordered-by user;
      description
        "Ordered list of fields with their meanings";
      leaf name {
        type field-name;
        description
          "The name of the field";
      }
      leaf length {
        type uint8;
        description
          "Length of the field";
      }
      leaf pattern {
        type field-pattern;
        mandatory true;
        description
          "Regular Expression describing the expected contents of
           the field";
      }
      leaf description {
        type field-description;
        description
          "A text description of the field contents";
      }
    }
  }

  container bgp-communities {
    description
      "A community set";
    leaf serial {
      type uint32;
      must "boolean(.)";
      description
        "Version number of the community set";
    }
    leaf uri {
      type inet:uri;
      description
        "Publication point for the community set";
    }
    leaf description {
      type string {
        length "1..65535";
        pattern '[^\p{C}]+';
      }
      description
        "A description for the community set";
    }
    leaf contact-url {
      type inet:uri;
      description
        "A reference to a webpage with maintainer contact
         information";
    }
    list contact {
      key "email-address";
      description
        "A list of contacts for the community set maintainer(s)";
      leaf email-address {
        type inet:email-address;
        description
          "Maintainer contact e-mail address";
      }
      leaf name {
        type string {
          length "1..255";
          pattern '[^\p{C}]+';
        }
        description
          "Maintainer contact name";
      }
      leaf role {
        type string {
          length "1..255";
          pattern '[^\p{C}]+';
        }
        description
          "Maintainer contact role";
      }
      leaf organization {
        type string {
          length "1..255";
          pattern '[^\p{C}]+';
        }
        description
          "Maintainer contact organization";
      }
      leaf organizational-unit {
        type string {
          length "1..255";
          pattern '[^\p{C}]+';
        }
        description
          "Maintainer contact organizational unit";
      }
    }
    list regular {
      key "name";
      description
        "A list of objects describing RFC 1997 BGP Communities";
      leaf name {
        type community-name;
        description
          "Community name";
      }
      leaf category {
        type community-category;
        description
          "Category of the community";
      }
      leaf description {
        type community-description;
        description
          "Description for the community";
      }
      leaf global-admin {
        type two-octet-as-number;
        mandatory true;
        description
          "Global Administrator field";
      }
      container local-admin {
        description
          "Local Administrator Field";
        leaf format {
          type local-admin-format;
          default "decimal";
          description
            "Format used for parsing Local Administrator subfields";
        }
        uses local-admin-fields;
      }
      reference
        "RFC 1997: BGP Communities Attribute";
    }
    list extended {
      key "name";
      description
        "A list of objects describing RFC 4360 Extended BGP
         Communities";
      leaf name {
        type community-name;
        description
          "Community name";
      }
      leaf category {
        type community-category;
        description
          "Category of the community";
      }
      leaf description {
        type community-description;
        description
          "Description for the community";
      }
      leaf type {
        type uint8;
        mandatory true;
        description
          "Type Field";
      }
      leaf subtype {
        type uint8;
        mandatory true;
        description
          "Sub-Type Field";
      }
      choice global-admin {
        mandatory true;
        description
          "Global Administrator Field";
        case asn {
          leaf asn {
            type two-octet-as-number;
            must "../type = 0 or ../type = 64";
            description
              "Two-Octet AS";
          }
        }
        case asn4 {
          leaf asn4 {
            type inet:as-number;
            must "../type = 2 or ../type = 66";
            description
              "Four-Octet AS";
          }
        }
      }
      container local-admin {
        description
          "Local Administrator Field";
        leaf format {
          type local-admin-format;
          default "decimal";
          description
            "Format used for parsing Local Administrator subfields";
        }
        uses local-admin-fields;
      }
      reference
        "RFC 4360: BGP Extended Communities Attribute";
    }
    list large {
      key "name";
      description
        "A list of objects describing RFC 8092 Large BGP
         Communities";
      leaf name {
        type community-name;
        description
          "Community name";
      }
      leaf category {
        type community-category;
        description
          "Category of the community";
      }
      leaf description {
        type community-description;
        description
          "Description for the community";
      }
      leaf global-admin {
        type inet:as-number;
        mandatory true;
        description
          "Global Administrator field";
      }
      container local-data-part-1 {
        description
          "Local Data Part 1 Field";
        leaf format {
          type local-admin-format;
          default "decimal";
          description
            "Format used for parsing Local Data Part 1 subfields";
        }
        uses local-admin-fields;
      }
      container local-data-part-2 {
        description
          "Local Data Part 2 Field";
        leaf format {
          type local-admin-format;
          default "decimal";
          description
            "Format used for parsing Local Data Part 2 subfields";
        }
        uses local-admin-fields;
      }
      reference
        "RFC 8092: BGP Large Communities Attribute";
    }
  }
}
<CODE ENDS>
]]>
      </sourcecode>

    </section>

    <section title="Data Elements" anchor="elements">
      <t>
        The BGP Communities YANG module contains the elements described in this section.
        The full contents of the module can be found in <xref target="module"/>.

        Several elements in this module use data types from <xref target="I-D.ietf-netmod-rfc6991-bis"/>.
        These data types are represented with the prefix "inet".
      </t>

      <section title="The &quot;serial&quot; leaf" anchor="elements.serial">
        <t>
          A required value of type "uint32", containing the version number for the community set.
          This value wraps and should be compared using sequence space arithmetic.
          Publishing Implementations are free to decide how to generate this value.
          One example method is to use the YYYYMMDDnn syntax as commonly used inside the DNS<xref target="RFC1912"/>.
        </t>
      </section>

      <section title="The &quot;uri&quot; leaf" anchor="elements.uri">
        <t>
          An optional value of type "inet:uri", describing the publication point for the community set.
        </t>
      </section>

      <section title="The &quot;description&quot; leaf" anchor="elements.description">
        <t>
          An optional value of type "string" with a maximum length of 65535, providing information about the specified set of communities.
        </t>
      </section>

      <section title="The &quot;contact-url&quot; leaf" anchor="elements.contact-url">
        <t>
          An optional value of type "inet:uri", describing a webpage where maintainer contact information may be found.
        </t>
      </section>

      <section title="The &quot;contact&quot; list" anchor="elements.contact">
        <t>
          A list of objects defining contact information for the maintainer(s) of the community set.
          Each object contains the following elements.
        </t>

        <section title="The &quot;email-address&quot; leaf" anchor="elements.contact.email-address">
          <t>
            A required value of type "inet:email-address", containing the e-mail address of the contact.
          </t>
        </section>

        <section title="The &quot;name&quot; leaf" anchor="elements.contact.name">
          <t>
            An optional value of type "string" with a maximum length of 255, containing the name of the contact.
          </t>
        </section>

        <section title="The &quot;role&quot; leaf" anchor="elements.contact.role">
          <t>
            An optional value of type "string" with a maximum length of 255, describing the role of the contact.
          </t>
        </section>

        <section title="The &quot;organization&quot; leaf" anchor="elements.contact.organization">
          <t>
            An optional value of type "string" with a maximum length of 255, containing the organization of the contact.
          </t>
        </section>

        <section title="The &quot;organizational-unit&quot; leaf" anchor="elements.contact.organizational-unit">
          <t>
            An optional value of type "string" with a maximum length of 255, containing the organizational unit of the contact.
          </t>
        </section>

      </section>

      <section title="The &quot;regular&quot; list" anchor="elements.regular">
        <t>
          A list of objects defining Regular (<xref target="RFC1997"/>) BGP communities.
          Each object contains the following elements.
        </t>

        <section title="The &quot;name&quot; leaf" anchor="elements.regular.name">
          <t>
            A required value of type "community-name", containing the name of this community.
          </t>
          <t>
            The structure of the "community-name" type is defined in <xref target="types.community-name"/>.
          </t>
        </section>

        <section title="The &quot;category&quot; leaf" anchor="elements.regular.category">
          <t>
            An optional value of type "community-category", containing the category of this community.
          </t>
          <t>
            The structure of the "community-category" type is defined in <xref target="types.community-category"/>.
          </t>
        </section>

        <section title="The &quot;description&quot; leaf" anchor="elements.regular.description">
          <t>
            An optional value of type "community-description", containing a description of this community.
          </t>
          <t>
            The structure of the "community-description" type is defined in <xref target="types.community-description"/>.
          </t>
        </section>

        <section title="The &quot;global-admin&quot; leaf" anchor="elements.regular.global-admin">
          <t>
            A required value of type "two-octet-as-number", containing the Autonomous System Number (ASN) set in the Global Administrator part of this community.
          </t>
          <t>
           The structure of the "two-octet-as-number" type is defined in <xref target="types.two-octet-as-number"/>.
          </t>
        </section>

        <section title="The &quot;local-admin&quot; container" anchor="elements.regular.local-admin">
          <t>
            A group of elements that describe the Local Administrator part of the community.
            This object contains the following elements.
          </t>

          <section title="The &quot;format&quot; leaf" anchor="elements.regular.local-admin.format">
            <t>
              An optional value of type "local-admin-format", describing the encoding format in which fields are to be parsed (see <xref target="recommendations.parsing"/>).
            </t>
            <t>
              The structure of the "local-admin-format" type is defined in <xref target="types.local-admin-format"/>.
              If this leaf is not defined, the default "decimal" encoding is assumed.
            </t>
          </section>

          <section title="The &quot;field&quot; list" anchor="elements.regular.local-admin.field">
            <t>
              A list of objects that together form the Local Administrator part of the community.
              The combined length values of all fields MUST NOT exceed the maximum length of the Local Administrator part of the community.
            </t>

            <section title="The &quot;name&quot; leaf" anchor="elements.regular.local-admin.field.name">
              <t>
                A required value of type "field-name", containing the name of the field.
              </t>
              <t>
                The structure of the "field-name" type is defined in <xref target="types.field-name"/>.
              </t>
            </section>

            <section title="The &quot;length&quot; leaf" anchor="elements.regular.local-admin.field.length">
              <t>
                An optional value of type "uint8", containing the length of the field.
                If the expected field format (<xref target="elements.regular.local-admin.format"/>) is "decimal", this is a number of digits.
                In case the expected field format is "binary", this is a number of bits.
             </t>
             <t>
                Parsers use the field length to determine how many decimals or bits from the Local Administrator part of the community are used by this field.
                If this leaf is not defined, the length is assumed to be the maximum allowed length of the entire field list.
                In this case the field list MUST NOT contain more than one element.
              </t>
            </section>

            <section title="The &quot;pattern&quot; leaf" anchor="elements.regular.local-admin.field.pattern">
              <t>
                A required value of type "field-pattern", used by parsers to match the content of the corresponding field in the Local Administrator part of a community.
                This could be a single value or a regular expression pattern matching multiple values.
              </t>
              <t>
                The structure of the "field-pattern" type is defined in <xref target="types.field-pattern"/>.
              </t>
            </section>

            <section title="The &quot;description&quot; leaf" anchor="elements.regular.local-admin.field.description">
              <t>
                An optional value of type "field-description", containing a description of the pattern.
                This description can be used to provide meaning to specific values for a field.
              </t>
              <t>
                The structure of the "field-description" type is defined in <xref target="types.field-description"/>.
              </t>
            </section>

          </section>

        </section>

      </section>

      <section title="The &quot;extended&quot; list" anchor="elements.extended">
        <t>
          A list of objects defining Extended (<xref target="RFC4360"/>) BGP communities.
          Two-Octet and Four-Octet AS Specific communities are supported by this specification.
          Each object contains the following elements.
        </t>

        <section title="The &quot;name&quot; leaf" anchor="elements.extended.name">
          <t>
            A required value of type "community-name", containing the name of this community.
          </t>
          <t>
            The structure of the "community-name" type is defined in <xref target="types.community-name"/>.
          </t>
        </section>

        <section title="The &quot;category&quot; leaf" anchor="elements.extended.category">
          <t>
            An optional value of type "community-category", containing the category of this community.
          </t>
          <t>
            The structure of the "community-category" type is defined in <xref target="types.community-category"/>.
          </t>
        </section>

        <section title="The &quot;description&quot; leaf" anchor="elements.extended.description">
          <t>
            An optional value of type "community-description", containing a description of this community.
          </t>
          <t>
            The structure of the "community-description" type is defined in <xref target="types.community-description"/>.
          </t>
        </section>

        <section title="The &quot;type&quot; leaf" anchor="elements.extended.type">
          <t>
            A required value of type "uint8", containing the high-order Type of the community.
            Supported values are 0 (0x00) for Transitive Two-Octet AS-Specific Extended Communities, 2 (0x02) for Transitive Four-Octet AS-Specific Extended Communities, 64 (0x40) for Non-Transitive Two-Octet AS-Specific Extended Communities and 66 (0x42) for Non-Transitive Four-Octet AS-Specific Extended Communities.
          </t>
        </section>

        <section title="The &quot;subtype&quot; leaf" anchor="elements.extended.subtype">
          <t>
            A required value of type "uint8", containing the low-order Sub-Type of the community.
          </t>
        </section>

        <section title="The &quot;asn&quot; leaf" anchor="elements.extended.asn">
          <t>
            For Two-Octet AS Specific communities: A required value of type "two-octet-as-number", containing the Autonomous Sytem Number set in the Global Administrator part of this community.
          </t>
          <t>
            The structure of the "two-octet-as-number" type is defined in <xref target="types.two-octet-as-number"/>.
          </t>
        </section>

        <section title="The &quot;asn4&quot; leaf" anchor="elements.extended.asn4">
          <t>
            For Four-Octet AS Specific communities: A required value of type "inet:as-number", containing the ASN set in the Global Administrator part of this community.
          </t>
        </section>

        <section title="The &quot;local-admin&quot; container" anchor="elements.extended.local-admin">
          <t>
            A group of elements that describe the Local Administrator part of the community.
            This object contains the following elements.
          </t>

          <section title="The &quot;format&quot; leaf" anchor="elements.extended.local-admin.format">
            <t>
              An optional value of type "local-admin-format", describing the encoding format in which fields are to be parsed (see <xref target="recommendations.parsing"/>).
            </t>
            <t>
              The structure of the "local-admin-format" type is defined in <xref target="types.local-admin-format"/>.
              If this leaf is not defined, the default "decimal" encoding is assumed.
            </t>
          </section>

          <section title="The &quot;field&quot; list" anchor="elements.extended.local-admin.field">
            <t>
              A list of objects that together form the Local Administrator part of the community.
              The combined length values of all fields MUST NOT exceed the maximum length of the Local Administrator part of the community.
            </t>
            <t>
              The supported leafs in this list are identical to those described in <xref target="elements.regular.local-admin.field"/>.
            </t>
          </section>

        </section>

      </section>

      <section title="The &quot;large&quot; list" anchor="elements.large">
        <t>
          A list of objects defining Large (<xref target="RFC8092"/>) BGP communities.
          Each object contains the following elements.
        </t>
      
        <section title="The &quot;name&quot; leaf" anchor="elements.large.name">
          <t>
            A required value of type "community-name", containing the name of this community.
          </t>
          <t>
            The structure of the "community-name" type is defined in <xref target="types.community-name"/>.
          </t>
        </section>

        <section title="The &quot;category&quot; leaf" anchor="elements.large.category">
          <t>
            An optional value of type "community-category", containing the category of this community.
          </t>
          <t>
            The structure of the "community-category" type is defined in <xref target="types.community-category"/>.
          </t>
        </section>

        <section title="The &quot;description&quot; leaf" anchor="elements.large.description">
          <t>
            An optional value of type "community-description", containing a description of this community.
          </t>
          <t>
            The structure of the "community-description" type is defined in <xref target="types.community-description"/>.
          </t>
        </section>

        <section title="The &quot;global-admin&quot; leaf" anchor="elements.large.global-admin">
          <t>
            A required value of type "inet:as-number", containing the ASN set in the Global Administrator part of this community.
          </t>
        </section>

        <section title="The &quot;local-datapart-1&quot; container" anchor="elements.large.local-data-part-1">
          <t>
            A group of elements that describe the Local Data Part 1 section of the community.
            This object contains the following elements.
          </t>

          <section title="The &quot;format&quot; leaf" anchor="elements.large.local-data-part-1.format">
            <t>
              An optional value of type "local-admin-format", describing the encoding format in which fields are to be parsed (see <xref target="recommendations.parsing"/>).
            </t>
            <t>
              The structure of the "local-admin-format" type is defined in <xref target="types.local-admin-format"/>.
              If this leaf is not defined, the default "decimal" encoding is assumed.
            </t>
          </section>

          <section title="The &quot;field&quot; list" anchor="elements.large.local-data-part-1.field">
            <t>
              A list of objects that together form the Local Data Part 1 section of the community.
              The combined length values of all fields MUST NOT exceed the maximum length of the "Local Data Part 1" section of the community.
            </t>
            <t>
              The supported leafs in this list are identical to those described in <xref target="elements.regular.local-admin.field"/>.
            </t>
          </section>

        </section>

        <section title="The &quot;local-data-part-2&quot; container" anchor="elements.large.local-data-part-2">
          <t>
            A group of elements that describe the Local Data Part 2 section of the community.
            This object contains the following elements.
          </t>

          <section title="The &quot;format&quot; leaf" anchor="elements.large.local-data-part-2.format">
            <t>
              An optional value of type "local-admin-format", describing the encoding format in which fields are to be parsed (see <xref target="recommendations.parsing"/>).
            </t>
            <t>
              The structure of the "local-admin-format" type is defined in <xref target="types.local-admin-format"/>.
              If this leaf is not defined, the default "decimal" encoding is assumed.
            </t>
          </section>

          <section title="The &quot;field&quot; list" anchor="elements.large.local-data-part-2.field">
            <t>
              A list of objects that together form the Local Data Part 2 section of the community.
              The combined length values of all fields MUST NOT exceed the maximum length of the "Local Data Part 2" section of the community.
            </t>
            <t>
              The supported leafs in this list are identical to those described in <xref target="elements.regular.local-admin.field"/>.
            </t>
          </section>

        </section>

      </section>

    </section>

    <section title="Type definitions" anchor="types">

      <t>
        Several of the elements defined in <xref target="elements"/> use custom data types. These data types are defined here.
      </t>

      <section title="The &quot;two-octet-as-number&quot; data type" anchor="types.two-octet-as-number">
        <t>
          A Two-Octet Autonomous System Number, as defined in <xref target="RFC1930"/>.
        </t>
      </section>

      <section title="The &quot;community-name&quot; data type" anchor="types.community-name">
        <t>
          A string specifying the name of a BGP community.
          Names may be up to 255 characters long and MUST NOT contain spaces or tabs.
        </t>
      </section>

      <section title="The &quot;community-category&quot; data type" anchor="types.community-category">
        <t>
          An enum specifying the category of a BGP community.
          Possible categories are "informational" and "action", as described in <xref target="RFC8195"/>.
        </t>
      </section>

      <section title="The &quot;community-description&quot; data type" anchor="types.community-description">
        <t>
          A string specifying the description of a BGP community.
          Descriptions may be up to 65535 characters long.
        </t>
      </section>

      <section title="The &quot;local-admin-format&quot; data type" anchor="types.local-admin-format">
        <t>
          An enum specifying the encoding for a Local Administrator/Local Data field.
          Possible encodings are "decimal" for decimal numbers and "binary" for bit strings.
        </t>
      </section>

      <section title="The &quot;field-name&quot; data type" anchor="types.field-name">
        <t>
          A string specifying the name of a BGP community Local Administrator/Local Data field.
          Names may be up to 255 characters long and MUST NOT contain spaces or tabs.
        </t>
      </section>

      <section title="The &quot;field-pattern&quot; data type" anchor="types.field-pattern">
        <t>
          A string specifying the pattern of a BGP community Local Administrator/Local Data field.
          Patterns may be up to 4095 characters long and are described as POSIX Extended Regular Expressions (see <xref target="IEEE.1003-2.1992"/>, Section 2.8.4).
        </t>
      </section>

      <section title="The &quot;field-description&quot; data type" anchor="types.field-description">
        <t>
          A string specifying the description of a BGP community Local Administrator/Local Data field.
          Descriptions may be up to 65535 characters long.
        </t>
      </section>

    </section>

    <section title="Operational guidelines" anchor="recommendations">

      <section title="Publishing guidelines" anchor="recommendations.publishing">
        <t>
          Operators SHOULD only publish BGP community definitions for networks they control.
          This may include communities where the Global Administrator field contains a private ASN, if this community has a local meaning inside the network of the publisher.
        </t>
        <t>
          When publishing community definitions with overlapping field patterns, these definitions MUST be ordered from most to least preferred.
          This ensures parsers can perform deterministic matching (see <xref target="recommendations.parsing"/>).
          For example, a definition for a single community "64500:123" needs to be specified before a definition that matches a covering range of communities "64500:*".
        </t>
      </section>

      <section title="Parsing guidelines" anchor="recommendations.parsing">
        <t>
          A published BGP community definition can be used by parsers to display information about a received community.
          If a received community matches multiple published community definitions, the first matching definition in the published order takes precedence.
        </t>
        <t>
          Parsers that use published community definitions from multiple operators SHOULD NOT attempt to match received communities where the Global Administrator field contains a private ASN, unless they have some method to determine which published definition is the authoritative one.
        </t>
        <t>
          By default, communities are compared using the decimal representation of the fields. If "format" for a Local Administrator or Local Data Part is set to "binary", the fields in the received community are converted to strings of zeros and ones before comparison.
        </t>
        <t>
          Applications that parse these community definitions SHOULD reject objects that do not comply with the rules described in this document.
          Furthermore, parsers SHOULD check that the sum of the specified Local Administrator or Local Data Part field lengths in each community definition does not exceed the local part size of the specified community type.
          For example, a Regular BGP community definition with format "decimal" containing a field of length 4 and a field of length 2 would be illegal, as the Local Administrator field has a maximum length of 65535 (5 digits).
        </t>
      </section>

    </section>

    <section title="IANA considerations" anchor="iana">

      <section title="YANG Namespace Registration" anchor="iana.xml">
        <t>
          This document registers the following XML namespace URN in the "IETF
          XML Registry", following the format defined in <xref target="RFC3688"/>:
        </t>
        <sourcecode>
URI: urn:ietf:params:xml:ns:yang:ietf-grow-yang-bgp-communities
Registrant Contact: The IESG.
XML: N/A, the requested URI is an XML namespace.
        </sourcecode>
      </section>

      <section title="YANG Module Registration" anchor="iana.yang">
        <t>
          This document registers the following YANG module in the "YANG Module Names" registry <xref target="RFC6020"/>:
        </t>
        <sourcecode>
Name: ietf-grow-yang-bgp-communities
Maintained by IANA? N
Namespace: urn:ietf:params:xml:ns:yang:ietf-grow-yang-bgpcommunities
Prefix: bgp-comm
Reference: RFC YYYY
RFC-EDITOR: please update YYYY with this RFC ID
        </sourcecode>
      </section>

      <section title="YANG SID Allocation" anchor="iana.sid">
        <t>
          This document registers the following entry in the "IETF YANG SID" registry <xref target="RFC9595"/>:
        </t>
        <sourcecode>
SID range entry point: TBD
SID range size: 100
YANG module name: ietf-grow-yang-bgp-communities
Reference: RFC YYYY
RFC-EDITOR: please update YYYY with this RFC ID
        </sourcecode>
      </section>

    </section>

    <section title="Implementation status" anchor="implementation">

      <t>
        RFC-EDITOR: Please remove this section and the accompanying reference(s) before publication.
      </t>

     <t>
       This section records the status of known implementations of the protocol defined by this specification at the time of posting of this Internet-Draft, and is based on a proposal described in <xref target="RFC7942"/>.
       The description of implementations in this section is intended to assist the IETF in its decision processes in progressing drafts to RFCs.
       Please note that the listing of any individual implementation here does not imply endorsement by the IETF.
       Furthermore, no effort has been spent to verify the information presented here that was supplied by IETF contributors.
       This is not intended as, and must not be construed to be, a catalog of available implementations or their features.
       Readers are advised to note that other implementations may exist.
     </t>

     <t>
       According to <xref target="RFC7942"/>, "this will allow reviewers and working groups to assign due consideration to documents that have the benefit of running code, which may serve as evidence of valuable experimentation and feedback that have made the implemented protocols more mature.
       It is up to the individual working groups to use this information as they see fit".
     </t>

      <section title="Publishing implementations" anchor="implementation.publishing">

        <t>
          The following networks are known to publish BGP community definitions according to this specification.
        </t>

        <table anchor="table.publishing">
          <name>Publishing implementations</name>
          <thead>
            <tr>
              <th>ASN</th>
              <th>Publication URI</th>
              <th>YANG model revision</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>197000</td>
              <td><eref target="https://www-static.ripe.net/dynamic/draft-ietf-grow-yang-bgp-communities/as197000.json">as197000.json</eref></td>
              <td>2024-06-15</td>
            </tr>
            <tr>
              <td>25152</td>
              <td><eref target="https://www-static.ripe.net/dynamic/draft-ietf-grow-yang-bgp-communities/as25152.json">as25152.json</eref></td>
              <td>2024-06-15</td>
            </tr>
          </tbody>
        </table>

      </section>

      <section title="Parser implementations" anchor="implementation.parsing">

        <t>
          The following known parser implementations exist.
        </t>

        <table anchor="table.parsing">
          <name>Parser implementations</name>
          <thead>
            <tr>
              <th>Name</th>
              <th>YANG model revision</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td><eref target="https://github.com/NLNOG/lg.ring.nlnog.net/">NLNOG Looking Glass</eref></td>
              <td>2024-06-15</td>
            </tr>
          </tbody>
        </table>

      </section>

    </section>
    
    <section title="Security considerations" anchor="security">

      <t>
        The YANG module described in this document may be used to specify BGP community definitions in different encoding formats, such as XML, JSON or CBOR.
        Applications that parse these community definitions SHOULD reject objects that do not comply with the rules described in this document.
        Furthermore, parsers SHOULD check that the sum of the specified Local Administrator or Local Data Part field lengths in each community definition does not exceed the local part size of the specified community type.
      </t>
      <t>
        The "contact-url" element defined in <xref target="elements.contact-url"/> may contain a link to an untrusted webpage.
        Parsers MAY opt to render the URL as plain text rather than a clickable link, to prevent inadvertent exposure of information by users of the rendered output.
      </t>
      <t>
        Several elements of the "contact" list defined in <xref target="elements.contact"/> may contain personal data covered by privacy-laws.
        Publishers MUST ensure that the elements defined in <xref target="elements.contact.email-address"/> and <xref target="elements.contact.name"/> do not contain any privacy-sensitive information.
      </t>

    </section>

  </middle>

  <back>

    <references title="Normative References" anchor="normative">

      &I-D.ietf-netmod-rfc6991-bis;
      &RFC1930;
      &RFC1997;
      &RFC4360;
      &RFC7950;
      &RFC8092;
      &RFC9595;

    </references>

    <references title="Informative References" anchor="informative">

      &IEEE.1003-2.1992;
      &RFC1912;
      &RFC2119;
      &RFC3688;
      &RFC4384;
      &RFC6020;
      &RFC7942;
      &RFC7951;
      &RFC8174;
      &RFC8195;
      &RFC8340;
      &RFC8792;

    </references>

    <section title="JSON Examples" anchor="examples">

      <t>
        This section shows example use cases for the YANG module defined in this document, using JSON<xref target="RFC7951"/> encoding.
      </t>

      <section title="RFC8195 Selective NO_EXPORT definition" anchor="examples.rfc8195">
        <t>
          A JSON definition for the example Large BGP community described in <xref target="RFC8195"/>, section 4.1.1 looks as follows.
        </t>
        <t>
          NOTE: '\' line wrapping per <xref target="RFC8792"/>
        </t>
        <sourcecode>
{
  "ietf-grow-yang-bgp-communities:bgp-communities": {
    "serial": 2023080101,
    "uri": "http://example.net/peering/communities",
    "description": "BGP Community example for ASN-Based Selective \
NO_EXPORT",
    "contact": [
      {
        "email-address": "noc@example.net",
        "name": "Example.net contact",
        "role": "Administrative contact",
        "organization": "Example.net",
        "organizational-unit": "NOC"
      }
    ],
    "large": [
      {
        "name": "RFC8195-NOEXPORT-ASN",
        "category": "action",
        "description": "Do not export route to ASN",
        "global-admin": 65539,
        "local-data-part-1": {
          "field": [
            {
              "name": "Function",
              "pattern": "4",
              "description": "ASN-No-Export"
            }
          ]
        },
        "local-data-part-2": {
          "field": [
            {
              "name": "ASN",
              "pattern": ".*"
            }
          ]
        }
      }
    ]
  }
}
        </sourcecode>
      </section>

      <section title="RFC4384 Data Collection definition" anchor="examples.rfc4384">
        <t>
          A JSON definition for the example Regular BGP community described in <xref target="RFC4384"/>, section 4 looks as follows.
        </t>
        <t>
          NOTE: '\' line wrapping per <xref target="RFC8792"/>
        </t>
        <sourcecode>
{
  "ietf-grow-yang-bgp-communities:bgp-communities": {
    "serial": 2023080101,
    "uri": "http://example.net/peering/communities",
    "description": "BGP Community example for Data Collection",
    "contact-url": "https://example.net/contact",
    "regular": [
      {
        "name": "RFC4384-ORIGIN-OC/FJ",
        "description": "A national route over a terrestrial link \
from the Fiji Islands",
        "global-admin": 64497,
        "local-admin": {
          "format": "binary",
          "field": [
            {
              "name": "Region",
              "length": 5,
              "pattern": "00010",
              "description": "OC"
            },
            {
              "name": "Satellite",
              "length": 1,
              "pattern": "0"
            },
            {
              "name": "Country",
              "length": 10,
              "pattern": "0011110010",
              "description": "FJ"
            }
          ]
        }
      }
    ]
  }
}
        </sourcecode>
      </section>

    </section>

    <section title="Acknowledgements" anchor="acknowledgements">

      <t>
        The author would like to thank Jeffrey Haas, Luuk Hendriks, Jasper den Hertog, Teun Vink, Tom Petch, Dale Carder and Mohamed Boucadair for contributing ideas and feedback to this document.
      </t>

    </section>

  </back>

</rfc>
