<commit_before>module snabb-softwire-v1 {
  namespace snabb:lwaftr;
  prefix softwire;

  import ietf-inet-types { prefix inet; }
  import ietf-yang-types { prefix yang; }

  organization "Igalia, S.L.";
  contact "<NAME> <<EMAIL>>";
  description
   "Configuration for the Snabb Switch lwAFTR.";

  revision 2016-11-04 {
    description
     "Initial revision.";
  }

  container softwire-config {
    description
     "Configuration for Snabb lwaftr.";

    grouping traffic-filters {
      type string;
      description
       "Ingress and egress filters describing the set of packets
        that should be allowed to pass, as pflang filters.  pflang
        is the language of tcpdump, libpcap and other tools.  Note
        that if VLAN tagging is enabled, the filters run on packets
        after VLAN tags have been stripped off.";
      leaf ingress-filter {
        type string;
        description
         "Filter for incoming traffic.  Packets that do not match
          the filter will be silently dropped.";
      }
      leaf egress-filter {
        type string;
        description
         "Filter for outgoing traffic.  Packets that do not match
          the filter will be silently dropped.";
      }
    }

    grouping icmp-policy {
      description
       "The lwAFTR can be configured to allow or drop incoming ICMP
        messages, and to generate outgoing ICMP error messages or
        not.";

      leaf allow-incoming-icmp {
        type boolean;
        default true;
        description
         "Whether to allow incoming ICMP packets.";
      }

      leaf generate-icmp-errors {
        type boolean;
        default true;
        description
         "Whether to generate outgoing ICMP error messages.";
      }
    }

    grouping vlan-tagging {
      description
       "802.1Q Ethernet tagging.";

      leaf vlan-tag {
        type uint16 {
          range 0..4095;
        }
        description
         "802.1Q Ethernet VLAN tag for this interface.";
      }
    }

    grouping error-rate-limiting {
      description
       "These settings limit the rate of ICMP error message
        transmission.";

      container error-rate-limiting {
        presence true;

        leaf packets {
          type uint32;
          description
           "The number of ICMP error messages which can be sent within
            the specified time period.";
        }

        leaf period {
          type uint32 { range 1..max; }
          default 2;
          description
           "The time period given in seconds.";
        }
      }
    }

    grouping reassembly {
      description
       "These settings limit the resources devoted to reassembling
        fragmented packets.";

      container reassembly {
        presence true;

        leaf max-fragments-per-packet {
          type uint32 { range 1..max; }
          default 20;
          description
           "The maximum number of fragments per reassembled packet.
            Attempts to reassemble a packet using more fragments than
            this threshold will fail and the reassembly data will be
            discarded.";
        }

        leaf max-packets {
          type uint32;
          default 20000;
          description
           "The maximum number of concurrent reassembly attempts.  If
            this limit is reached, an additional reassembly will cause
            random eviction of an ongoing reassembly. Note that this
            setting directly affects memory usage; the memory buffer
            allocated to reassembly is this maximum number of
            reassemblies times 25 kilobytes each.";
        }
      }
    }

    container external-interface {
      description
       "Configuration for the external, internet-facing IPv4
        interface.";

      presence true;

      leaf ip {
        type inet:ipv4-address;
        mandatory true;
        description
         "L3 Address of the internet-facing network interface.  Used
          when generating error messages and responding to ICMP echo
          requests.";
      }
      leaf mac {
        type yang:mac-address;
        mandatory true;
        description
         "MAC address of the internet-facing NIC.";
      }
      leaf mtu {
        type uint16;
        default 1460;
        description
         "Maximum packet size to send on the IPv4 interface.";
      }

      uses traffic-filters;
      uses icmp-policy;
      uses vlan-tagging;
      uses error-rate-limiting;
      uses reassembly;

      container next-hop {
        presence true;
        leaf ip {
          type inet:ipv4-address;
          description
           "IPv4 address of the next hop for the internet-facing NIC.
            The lwAFTR will resolve this to a MAC address using ARP.";
        }
        leaf mac {
          type yang:mac-address;
          description
           "Statically configured MAC address of the next hop for the
            internet-facing NIC.";
        }
      }
    }

    container internal-interface {
      description
       "Configuration for the internal IPv6 interface.";

      presence true;

      leaf ip {
        type inet:ipv6-address;
        mandatory true;
        description
         "L3 Address of the internal-facing network interface.  Used
          when generating error messages and responding to ICMP echo
          requests.";
      }
      leaf mac {
        type yang:mac-address;
        mandatory true;
        description
         "MAC address of the internal-facing NIC.";
      }
      leaf mtu {
        type uint16;
        default 1500;
        description
         "Maximum packet size to sent on the IPv6 interface.";
      }

      uses traffic-filters;
      uses icmp-policy;
      uses vlan-tagging;
      uses error-rate-limiting;
      uses reassembly;

      container next-hop {
        presence true;
        leaf ip {
          type inet:ipv6-address;
          description
           "IPv6 address of the next hop for the internal-facing NIC.
            The lwAFTR will resolve this to a MAC address using NDP.";
        }
        leaf mac {
          type yang:mac-address;
          description
           "Statically configured MAC address of the next hop for the
            internal-facing NIC.";
        }
      }

      leaf hairpinning {
        type boolean;
        default true;
        description
         "Indicates whether to support hairpinning of traffic between
          two B4s.";
      }
    }
  }

  container binding-table {
    description
     "A collection of softwires (tunnels), along with a description
      of the IPv4 and IPv6 addresses handled by the lwAFTR.";

    presence true;

    list psid-map {
      description
       "The set of IPv4 addresses managed by the lwAFTR, along with
        the way in which those IPv4 addresses share ports.  A PSID map
        entry associates a PSID length, shift, and
        reserved-ports-bit-count with each IPv4 address served by
        the lwAFTR.

        The lightweight 4-over-6 architecture supports sharing of
        IPv4 addresses by partitioning the space of TCP/UDP/ICMP
        ports into disjoint \"port sets\".  Each softwire associated
        with an IPv4 address corresponds to a different set of ports
        on that address.  The way that the ports are partitioned is
        specified in RFC 7597:  each address has an associated set
        of parameters that specifies how to compute a \"port set
        identifier\" (PSID) from a given port.

                             0                   1
                             0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
                            +-----------+-----------+-------+
              Ports in      |     A     |    PSID   |   j   |
           the CE port set  |    > 0    |           |       |
                            +-----------+-----------+-------+
                            |  a bits   |  k bits   |m bits |

             Figure 2: Structure of a Port-Restricted Port Field

          Source: http://tools.ietf.org/html/rfc7597#section-5.1

        We find the specification's names to be a bit obtuse, so we
        refer to them using the following names:

          a bits = reserved-ports-bit-count.
          k bits = psid-length.
          m bits = shift.";

      key addr;

      leaf addr {
        type inet:ipv4-address;
        mandatory true;
        description
         "Public IPv4 address managed by the lwAFTR.";
      }

      leaf end-addr {
        type inet:ipv4-address;
        description
         "If present, this PSID map entry applies to all addresses
          between 'addr' and this address, inclusive.";
      }

      leaf psid-length {
        type uint8 { range 0..16; }
        mandatory true;
        description
         "The number of bits devoted to the PSID in the port map.
          If the psid-length is N, then the IPv4 address will be
          shared 2^N ways.  Note that psid-length, shift, and
          reserved-ports-bit-count must add up to 16.";
      }

      leaf shift {
        type uint8 { range 0..16; }
        description
         "Given an incoming port, one can obtain the PSID by
          shifting the port right by 'shift' bits and then masking
          off the lowest 'psid-length' bits.  Defaults to 16 -
          psid-length.  Note that psid-length, shift, and
          reserved-ports-bit-count must add up to 16.";
      }

      leaf reserved-ports-bit-count {
        type uint8 { range 0..16; }
        default 0;
        description
         "Reserve the lowest 2^N ports so that they map to no
          softwire.  This can be useful to prevent the low 1024
          ports (for example) from being mapped to customers.  Note
          that psid-length and shift must add up to less than or
          equal to 16.";
      }
    }

    leaf-list br-address {
      type inet:ipv6-address;
      description
       "B4-facing address of an lwAFTR.";
    }

    list softwire {
      key "ipv4 psid padding";

      leaf ipv4 {
        type inet:ipv4-address;
        mandatory true;
        description
         "Public IPv4 address of the softwire.";
      }

      leaf psid {
        type uint16;
        mandatory true;
        description
         "Port set ID.";
      }

      leaf padding {
        type uint16 { range 0..0; }
        default 0;
        description
         "Reserved bytes.";
      }

      leaf br {
        type uint32;
        mandatory true;
        description
         "The B4-facing address of the lwAFTR for this softwire, as
          a zero-based index into br-addresses.";
      }

      leaf b4-ipv6 {
        type inet:ipv6-address;
        mandatory true;
        description
         "B4 address.";
      }
    }
  }
}
<commit_msg>Grouping has no type.<commit_after>module snabb-softwire-v1 {
  namespace snabb:lwaftr;
  prefix softwire;

  import ietf-inet-types { prefix inet; }
  import ietf-yang-types { prefix yang; }

  organization "Igalia, S.L.";
  contact "<NAME> <<EMAIL>>";
  description
   "Configuration for the Snabb Switch lwAFTR.";

  revision 2016-11-04 {
    description
     "Initial revision.";
  }

  container softwire-config {
    description
     "Configuration for Snabb lwaftr.";

    grouping traffic-filters {
      description
       "Ingress and egress filters describing the set of packets
        that should be allowed to pass, as pflang filters.  pflang
        is the language of tcpdump, libpcap and other tools.  Note
        that if VLAN tagging is enabled, the filters run on packets
        after VLAN tags have been stripped off.";
      leaf ingress-filter {
        type string;
        description
         "Filter for incoming traffic.  Packets that do not match
          the filter will be silently dropped.";
      }
      leaf egress-filter {
        type string;
        description
         "Filter for outgoing traffic.  Packets that do not match
          the filter will be silently dropped.";
      }
    }

    grouping icmp-policy {
      description
       "The lwAFTR can be configured to allow or drop incoming ICMP
        messages, and to generate outgoing ICMP error messages or
        not.";

      leaf allow-incoming-icmp {
        type boolean;
        default true;
        description
         "Whether to allow incoming ICMP packets.";
      }

      leaf generate-icmp-errors {
        type boolean;
        default true;
        description
         "Whether to generate outgoing ICMP error messages.";
      }
    }

    grouping vlan-tagging {
      description
       "802.1Q Ethernet tagging.";

      leaf vlan-tag {
        type uint16 {
          range 0..4095;
        }
        description
         "802.1Q Ethernet VLAN tag for this interface.";
      }
    }

    grouping error-rate-limiting {
      description
       "These settings limit the rate of ICMP error message
        transmission.";

      container error-rate-limiting {
        presence true;

        leaf packets {
          type uint32;
          description
           "The number of ICMP error messages which can be sent within
            the specified time period.";
        }

        leaf period {
          type uint32 { range 1..max; }
          default 2;
          description
           "The time period given in seconds.";
        }
      }
    }

    grouping reassembly {
      description
       "These settings limit the resources devoted to reassembling
        fragmented packets.";

      container reassembly {
        presence true;

        leaf max-fragments-per-packet {
          type uint32 { range 1..max; }
          default 20;
          description
           "The maximum number of fragments per reassembled packet.
            Attempts to reassemble a packet using more fragments than
            this threshold will fail and the reassembly data will be
            discarded.";
        }

        leaf max-packets {
          type uint32;
          default 20000;
          description
           "The maximum number of concurrent reassembly attempts.  If
            this limit is reached, an additional reassembly will cause
            random eviction of an ongoing reassembly. Note that this
            setting directly affects memory usage; the memory buffer
            allocated to reassembly is this maximum number of
            reassemblies times 25 kilobytes each.";
        }
      }
    }

    container external-interface {
      description
       "Configuration for the external, internet-facing IPv4
        interface.";

      presence true;

      leaf ip {
        type inet:ipv4-address;
        mandatory true;
        description
         "L3 Address of the internet-facing network interface.  Used
          when generating error messages and responding to ICMP echo
          requests.";
      }
      leaf mac {
        type yang:mac-address;
        mandatory true;
        description
         "MAC address of the internet-facing NIC.";
      }
      leaf mtu {
        type uint16;
        default 1460;
        description
         "Maximum packet size to send on the IPv4 interface.";
      }

      uses traffic-filters;
      uses icmp-policy;
      uses vlan-tagging;
      uses error-rate-limiting;
      uses reassembly;

      container next-hop {
        presence true;
        leaf ip {
          type inet:ipv4-address;
          description
           "IPv4 address of the next hop for the internet-facing NIC.
            The lwAFTR will resolve this to a MAC address using ARP.";
        }
        leaf mac {
          type yang:mac-address;
          description
           "Statically configured MAC address of the next hop for the
            internet-facing NIC.";
        }
      }
    }

    container internal-interface {
      description
       "Configuration for the internal IPv6 interface.";

      presence true;

      leaf ip {
        type inet:ipv6-address;
        mandatory true;
        description
         "L3 Address of the internal-facing network interface.  Used
          when generating error messages and responding to ICMP echo
          requests.";
      }
      leaf mac {
        type yang:mac-address;
        mandatory true;
        description
         "MAC address of the internal-facing NIC.";
      }
      leaf mtu {
        type uint16;
        default 1500;
        description
         "Maximum packet size to sent on the IPv6 interface.";
      }

      uses traffic-filters;
      uses icmp-policy;
      uses vlan-tagging;
      uses error-rate-limiting;
      uses reassembly;

      container next-hop {
        presence true;
        leaf ip {
          type inet:ipv6-address;
          description
           "IPv6 address of the next hop for the internal-facing NIC.
            The lwAFTR will resolve this to a MAC address using NDP.";
        }
        leaf mac {
          type yang:mac-address;
          description
           "Statically configured MAC address of the next hop for the
            internal-facing NIC.";
        }
      }

      leaf hairpinning {
        type boolean;
        default true;
        description
         "Indicates whether to support hairpinning of traffic between
          two B4s.";
      }
    }
  }

  container binding-table {
    description
     "A collection of softwires (tunnels), along with a description
      of the IPv4 and IPv6 addresses handled by the lwAFTR.";

    presence true;

    list psid-map {
      description
       "The set of IPv4 addresses managed by the lwAFTR, along with
        the way in which those IPv4 addresses share ports.  A PSID map
        entry associates a PSID length, shift, and
        reserved-ports-bit-count with each IPv4 address served by
        the lwAFTR.

        The lightweight 4-over-6 architecture supports sharing of
        IPv4 addresses by partitioning the space of TCP/UDP/ICMP
        ports into disjoint \"port sets\".  Each softwire associated
        with an IPv4 address corresponds to a different set of ports
        on that address.  The way that the ports are partitioned is
        specified in RFC 7597:  each address has an associated set
        of parameters that specifies how to compute a \"port set
        identifier\" (PSID) from a given port.

                             0                   1
                             0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
                            +-----------+-----------+-------+
              Ports in      |     A     |    PSID   |   j   |
           the CE port set  |    > 0    |           |       |
                            +-----------+-----------+-------+
                            |  a bits   |  k bits   |m bits |

             Figure 2: Structure of a Port-Restricted Port Field

          Source: http://tools.ietf.org/html/rfc7597#section-5.1

        We find the specification's names to be a bit obtuse, so we
        refer to them using the following names:

          a bits = reserved-ports-bit-count.
          k bits = psid-length.
          m bits = shift.";

      key addr;

      leaf addr {
        type inet:ipv4-address;
        mandatory true;
        description
         "Public IPv4 address managed by the lwAFTR.";
      }

      leaf end-addr {
        type inet:ipv4-address;
        description
         "If present, this PSID map entry applies to all addresses
          between 'addr' and this address, inclusive.";
      }

      leaf psid-length {
        type uint8 { range 0..16; }
        mandatory true;
        description
         "The number of bits devoted to the PSID in the port map.
          If the psid-length is N, then the IPv4 address will be
          shared 2^N ways.  Note that psid-length, shift, and
          reserved-ports-bit-count must add up to 16.";
      }

      leaf shift {
        type uint8 { range 0..16; }
        description
         "Given an incoming port, one can obtain the PSID by
          shifting the port right by 'shift' bits and then masking
          off the lowest 'psid-length' bits.  Defaults to 16 -
          psid-length.  Note that psid-length, shift, and
          reserved-ports-bit-count must add up to 16.";
      }

      leaf reserved-ports-bit-count {
        type uint8 { range 0..16; }
        default 0;
        description
         "Reserve the lowest 2^N ports so that they map to no
          softwire.  This can be useful to prevent the low 1024
          ports (for example) from being mapped to customers.  Note
          that psid-length and shift must add up to less than or
          equal to 16.";
      }
    }

    leaf-list br-address {
      type inet:ipv6-address;
      description
       "B4-facing address of an lwAFTR.";
    }

    list softwire {
      key "ipv4 psid padding";

      leaf ipv4 {
        type inet:ipv4-address;
        mandatory true;
        description
         "Public IPv4 address of the softwire.";
      }

      leaf psid {
        type uint16;
        mandatory true;
        description
         "Port set ID.";
      }

      leaf padding {
        type uint16 { range 0..0; }
        default 0;
        description
         "Reserved bytes.";
      }

      leaf br {
        type uint32;
        mandatory true;
        description
         "The B4-facing address of the lwAFTR for this softwire, as
          a zero-based index into br-addresses.";
      }

      leaf b4-ipv6 {
        type inet:ipv6-address;
        mandatory true;
        description
         "B4 address.";
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.06281022405715081, 'fraction_numerical': 0.014751588811059053, 'mean_word_length': 1.5704065816144033, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5983494', 'n_tokens_mistral': 5794, 'n_tokens_neox': 5445, 'n_words': 2195}