<?xml version="1.0"?>
<!-- SNMP forwarder configuration -->
<interfaceDefinition>
  <node name="service">
    <children>
      <node name="snmp" owner="${vyos_conf_scripts_dir}/snmp.py">
        <properties>
          <help>Simple Network Management Protocol (SNMP)</help>
          <priority>900</priority>
        </properties>
        <children>
          <tagNode name="community">
            <properties>
              <help>Community name</help>
              <constraint>
                <regex>[[:alnum:]-_!@*#]{1,100}</regex>
              </constraint>
              <constraintErrorMessage>Community string is limited to alphanumerical characters, -, _, !, @, *, and # with a total lenght of 100</constraintErrorMessage>
            </properties>
            <children>
              <leafNode name="authorization">
                <properties>
                  <help>Authorization type</help>
                  <completionHelp>
                    <list>ro rw</list>
                  </completionHelp>
                  <valueHelp>
                    <format>ro</format>
                    <description>Read-Only</description>
                  </valueHelp>
                  <valueHelp>
                    <format>rw</format>
                    <description>Read-Write</description>
                  </valueHelp>
                  <constraint>
                    <regex>(ro|rw)</regex>
                  </constraint>
                  <constraintErrorMessage>Authorization type must be either 'rw' or 'ro'</constraintErrorMessage>
                </properties>
                <defaultValue>ro</defaultValue>
              </leafNode>
              <leafNode name="client">
                <properties>
                  <help>IP address of SNMP client allowed to contact system</help>
                  <constraint>
                    <validator name="ipv4-address"/>
                    <validator name="ipv6-address"/>
                  </constraint>
                  <multi/>
                </properties>
              </leafNode>
              <leafNode name="network">
                <properties>
                  <help>Subnet of SNMP client(s) allowed to contact system</help>
                  <valueHelp>
                    <format>ipv4net</format>
                    <description>IP address and prefix length</description>
                  </valueHelp>
                  <valueHelp>
                    <format>ipv6net</format>
                    <description>IPv6 address and prefix length</description>
                  </valueHelp>
                  <constraint>
                    <validator name="ip-prefix"/>
                  </constraint>
                  <multi/>
                </properties>
                <defaultValue>0.0.0.0/0 ::/0</defaultValue>
              </leafNode>
            </children>
          </tagNode>
          <leafNode name="contact">
            <properties>
              <help>Contact information</help>
              <constraint>
                <regex>.{1,255}</regex>
              </constraint>
              <constraintErrorMessage>Contact information is limited to 255 characters or less</constraintErrorMessage>
            </properties>
          </leafNode>
          <leafNode name="description">
            <properties>
              <help>Description information</help>
              <constraint>
                <regex>.{1,255}</regex>
              </constraint>
              <constraintErrorMessage>Description is limited to 255 characters or less</constraintErrorMessage>
            </properties>
          </leafNode>
          <tagNode name="listen-address">
            <properties>
              <help>IP address to listen for incoming SNMP requests</help>
              <completionHelp>
                <script>${vyos_completion_dir}/list_local_ips.sh --both</script>
              </completionHelp>
              <valueHelp>
                <format>ipv4</format>
                <description>IPv4 address to listen for incoming SNMP requests</description>
              </valueHelp>
              <valueHelp>
                <format>ipv6</format>
                <description>IPv6 address to listen for incoming SNMP requests</description>
              </valueHelp>
              <constraint>
                <validator name="ipv4-address"/>
                <validator name="ipv6-address"/>
              </constraint>
            </properties>
            <children>
              #include <include/port-number.xml.i>
              <leafNode name="port">
                <defaultValue>161</defaultValue>
              </leafNode>
            </children>
          </tagNode>
          <leafNode name="location">
            <properties>
              <help>Location information</help>
              <constraint>
                <regex>.{1,255}</regex>
              </constraint>
              <constraintErrorMessage>Location is limited to 255 characters or less</constraintErrorMessage>
            </properties>
          </leafNode>
          <leafNode name="oid-enable">
            <properties>
              <help>Enable specific OIDs that by default are disable</help>
              <completionHelp>
                <list>ip-forward ip-route-table ip-net-to-media-table ip-net-to-physical-phys-address</list>
              </completionHelp>
              <valueHelp>
                <format>ip-forward</format>
                <description>Enable ipForward: .1.3.6.1.2.1.4.24</description>
              </valueHelp>
              <valueHelp>
                <format>ip-route-table</format>
                <description>Enable ipRouteTable: .1.3.6.1.2.1.4.21</description>
              </valueHelp>
              <valueHelp>
                <format>ip-net-to-media-table</format>
                <description>Enable ipNetToMediaTable: .1.3.6.1.2.1.4.22</description>
              </valueHelp>
              <valueHelp>
                <format>ip-net-to-physical-phys-address</format>
                <description>Enable ipNetToPhysicalPhysAddress: .1.3.6.1.2.1.4.35</description>
              </valueHelp>
              <constraint>
                <regex>(ip-forward|ip-route-table|ip-net-to-media-table|ip-net-to-physical-phys-address)</regex>
              </constraint>
              <constraintErrorMessage>OID must be one of the liste options</constraintErrorMessage>
              <multi/>
            </properties>
          </leafNode>
          #include <include/snmp/protocol.xml.i>
          <leafNode name="smux-peer">
            <properties>
              <help>Register a subtree for SMUX-based processing</help>
              <valueHelp>
                <format>txt</format>
                <description>SNMP Object Identifier</description>
              </valueHelp>
              <multi/>
            </properties>
          </leafNode>
          <leafNode name="trap-source">
            <properties>
              <help>SNMP trap source address</help>
              <valueHelp>
                <format>ipv4</format>
                <description>IPv4 address</description>
              </valueHelp>
              <valueHelp>
                <format>ipv6</format>
                <description>IPv6 address</description>
              </valueHelp>
              <constraint>
                <validator name="ipv4-address"/>
                <validator name="ipv6-address"/>
              </constraint>
            </properties>
          </leafNode>
          <tagNode name="trap-target">
            <properties>
              <help>Address of trap target</help>
              <valueHelp>
                <format>ipv4</format>
                <description>IPv4 address</description>
              </valueHelp>
              <valueHelp>
                <format>ipv6</format>
                <description>IPv6 address</description>
              </valueHelp>
              <constraint>
                <validator name="ipv4-address"/>
                <validator name="ipv6-address"/>
              </constraint>
            </properties>
            <children>
              <leafNode name="community">
                <properties>
                  <help>Community used when sending trap information</help>
                </properties>
              </leafNode>
              #include <include/port-number.xml.i>
              <leafNode name="port">
                <defaultValue>162</defaultValue>
              </leafNode>
            </children>
          </tagNode>
          <node name="v3">
            <properties>
              <help>Simple Network Management Protocol (SNMP) v3</help>
            </properties>
            <children>
              <leafNode name="engineid">
                <properties>
                  <help>Specifies the EngineID that uniquely identify an agent (e.g. 000000000000000000000002)</help>
                  <constraint>
                    <regex>([0-9a-f][0-9a-f]){1,18}</regex>
                  </constraint>
                  <constraintErrorMessage>ID must contain an even number (from 2 to 36) of hex digits</constraintErrorMessage>
                </properties>
                <defaultValue></defaultValue>
              </leafNode>
              <tagNode name="group">
                <properties>
                  <help>Specifies the group with name groupname</help>
                </properties>
                <children>
                  #include <include/snmp/access-mode.xml.i>
                  <leafNode name="seclevel">
                    <properties>
                      <help>Security levels</help>
                      <completionHelp>
                        <list>noauth auth priv</list>
                      </completionHelp>
                      <valueHelp>
                        <format>noauth</format>
                        <description>Messages not authenticated and not encrypted (noAuthNoPriv)</description>
                      </valueHelp>
                      <valueHelp>
                        <format>auth</format>
                        <description>Messages are authenticated but not encrypted (authNoPriv)</description>
                      </valueHelp>
                      <valueHelp>
                        <format>priv</format>
                        <description>Messages are authenticated and encrypted (authPriv)</description>
                      </valueHelp>
                      <constraint>
                        <regex>(noauth|auth|priv)</regex>
                      </constraint>
                    </properties>
                    <defaultValue>auth</defaultValue>
                  </leafNode>
                  <leafNode name="view">
                    <properties>
                      <help>Defines the name of view</help>
                      <completionHelp>
                        <path>service snmp v3 view</path>
                      </completionHelp>
                    </properties>
                  </leafNode>
                </children>
              </tagNode>
              <tagNode name="trap-target">
                <properties>
                  <help>Defines SNMP target for inform or traps for IP</help>
                  <valueHelp>
                    <format>ipv4</format>
                    <description>IP address of trap target</description>
                  </valueHelp>
                  <valueHelp>
                    <format>ipv6</format>
                    <description>IPv6 address of trap target</description>
                  </valueHelp>
                  <constraint>
                    <validator name="ipv4-address"/>
                    <validator name="ipv6-address"/>
                  </constraint>
                </properties>
                <children>
                  <node name="auth">
                    <properties>
                      <help>Defines the privacy</help>
                    </properties>
                    <children>
                      <leafNode name="encrypted-password">
                        <properties>
                          <help>Defines the encrypted key for authentication</help>
                          <constraint>
                            <regex>[0-9a-f]*</regex>
                          </constraint>
                          <constraintErrorMessage>Encrypted key must only contain hex digits</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      <leafNode name="plaintext-password">
                        <properties>
                          <help>Defines the clear text key for authentication</help>
                          <constraint>
                            <regex>.{8,}</regex>
                          </constraint>
                          <constraintErrorMessage>Key must contain 8 or more characters</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      #include <include/snmp/authentication-type.xml.i>
                    </children>
                  </node>
                  #include <include/port-number.xml.i>
                  <leafNode name="port">
                    <defaultValue>162</defaultValue>
                  </leafNode>
                  <node name="privacy">
                    <properties>
                      <help>Defines the privacy</help>
                    </properties>
                    <children>
                      <leafNode name="encrypted-password">
                        <properties>
                          <help>Defines the encrypted key for privacy protocol</help>
                          <constraint>
                            <regex>[0-9a-f]*</regex>
                          </constraint>
                          <constraintErrorMessage>Encrypted key must only contain hex digits</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      <leafNode name="plaintext-password">
                        <properties>
                          <help>Defines the clear text key for privacy protocol</help>
                          <constraint>
                            <regex>.{8,}</regex>
                          </constraint>
                          <constraintErrorMessage>Key must contain 8 or more characters</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      #include <include/snmp/privacy-type.xml.i>
                    </children>
                  </node>
                  #include <include/snmp/protocol.xml.i>
                  <leafNode name="type">
                    <properties>
                      <help>Specifies the type of notification between inform and trap</help>
                      <completionHelp>
                        <list>inform trap</list>
                      </completionHelp>
                      <valueHelp>
                        <format>inform</format>
                        <description>Use INFORM</description>
                      </valueHelp>
                      <valueHelp>
                        <format>trap</format>
                        <description>Use TRAP</description>
                      </valueHelp>
                      <constraint>
                        <regex>(inform|trap)</regex>
                      </constraint>
                    </properties>
                    <defaultValue>inform</defaultValue>
                  </leafNode>
                  <leafNode name="user">
                    <properties>
                      <help>Defines username for authentication</help>
                      <completionHelp>
                        <path>service snmp v3 user</path>
                      </completionHelp>
                    </properties>
                  </leafNode>
                </children>
              </tagNode>
              <tagNode name="user">
                <properties>
                  <help>Specifies the user with name username</help>
                  <constraint>
                    <regex>[^\(\)\|\-]+</regex>
                  </constraint>
                  <constraintErrorMessage>Illegal characters in name</constraintErrorMessage>
                </properties>
                <children>
                  <node name="auth">
                    <properties>
                      <help>Specifies the auth</help>
                    </properties>
                    <children>
                      <leafNode name="encrypted-password">
                        <properties>
                          <help>Defines the encrypted key for authentication</help>
                          <constraint>
                            <regex>[0-9a-f]*</regex>
                          </constraint>
                          <constraintErrorMessage>Encrypted key must only contain hex digits</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      <leafNode name="plaintext-password">
                        <properties>
                          <help>Defines the clear text key for authentication</help>
                          <constraint>
                            <regex>.{8,}</regex>
                          </constraint>
                          <constraintErrorMessage>Key must contain 8 or more characters</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      #include <include/snmp/authentication-type.xml.i>
                    </children>
                  </node>
                  <leafNode name="group">
                    <properties>
                      <help>Specifies group for user name</help>
                      <completionHelp>
                        <path>service snmp v3 group</path>
                      </completionHelp>
                    </properties>
                  </leafNode>
                  #include <include/snmp/access-mode.xml.i>
                  <node name="privacy">
                    <properties>
                      <help>Defines the privacy</help>
                    </properties>
                    <children>
                      <leafNode name="encrypted-password">
                        <properties>
                          <help>Defines the encrypted key for privacy protocol</help>
                          <constraint>
                            <regex>[0-9a-f]*</regex>
                          </constraint>
                          <constraintErrorMessage>Encrypted key must only contain hex digits</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      <leafNode name="plaintext-password">
                        <properties>
                          <help>Defines the clear text key for privacy protocol</help>
                          <constraint>
                            <regex>.{8,}</regex>
                          </constraint>
                          <constraintErrorMessage>Key must contain 8 or more characters</constraintErrorMessage>
                        </properties>
                      </leafNode>
                      #include <include/snmp/privacy-type.xml.i>
                    </children>
                  </node>
                </children>
              </tagNode>
              <tagNode name="view">
                <properties>
                  <help>Specifies the view with name viewname</help>
                  <constraint>
                    <regex>[^\(\)\|\-]+</regex>
                  </constraint>
                  <constraintErrorMessage>Illegal characters in name</constraintErrorMessage>
                </properties>
                <children>
                  <tagNode name="oid">
                    <properties>
                      <help>Specifies the oid</help>
                      <constraint>
                        <regex>[0-9]+(\.[0-9]+)*</regex>
                      </constraint>
                      <constraintErrorMessage>OID must start from a number</constraintErrorMessage>
                    </properties>
                    <children>
                      <leafNode name="exclude">
                        <properties>
                          <help>Exclude is an optional argument</help>
                        </properties>
                      </leafNode>
                      <leafNode name="mask">
                        <properties>
                          <help>Defines a bit-mask that is indicating which subidentifiers of the associated subtree OID should be regarded as significant</help>
                          <constraint>
                            <regex>[0-9a-f]{2}([\.:][0-9a-f]{2})*</regex>
                          </constraint>
                          <constraintErrorMessage>MASK is a list of hex octets, separated by '.' or ':'</constraintErrorMessage>
                        </properties>
                      </leafNode>
                    </children>
                  </tagNode>
                </children>
              </tagNode>
            </children>
          </node>
          <node name="script-extensions">
            <properties>
              <help>SNMP script extensions</help>
            </properties>
            <children>
              <tagNode name="extension-name">
                <properties>
                  <help>Extension name</help>
                  <constraint>
                    <regex>[a-z0-9\.\-\_]+</regex>
                  </constraint>
                  <constraintErrorMessage>Script extension contains invalid characters</constraintErrorMessage>
                </properties>
                <children>
                  <leafNode name="script">
                    <properties>
                      <help>Script location and name</help>
                      <completionHelp>
                        <script>ls /config/user-data</script>
                      </completionHelp>
                      <constraint>
                        <regex>[a-z0-9\.\-\_\/]+</regex>
                      </constraint>
                      <constraintErrorMessage>Script extension contains invalid characters</constraintErrorMessage>
                    </properties>
                  </leafNode>
                </children>
              </tagNode>
            </children>
          </node>
          #include <include/interface/vrf.xml.i>
        </children>
      </node>
    </children>
  </node>
</interfaceDefinition>