跳到主要内容

2. 概览 (Overview)

本节概览 RFC 9911 在 ietf-yang-typesietf-inet-types 两个 YANG modules 中定义或更新的 common YANG data types (通用 YANG 数据类型). 表格列出每个类型的名称, 派生自哪个 base type (基础类型), 以及最早引入该类型的 RFC.

下方 RFC 原文保留英文表格和类型名, 因为这些标识符会直接出现在 YANG module, IANA registry 和实现代码中. 读者可重点关注两类映射关系: 一类是 RFC 9911 新增或更新的时间, 语言标签, 协议号, 主机名和地址前缀类型; 另一类是这些 YANG 类型与 SMIv2 类型之间的等价关系, 用于帮助 SNMP/SMIv2 数据模型迁移到 YANG.

表 1 覆盖 ietf-yang-types 中的通用类型, 例如 counter, gauge, object identifier, date/time, duration 单位, timestamp, MAC/物理地址, UUID, dotted-quad, language-tag 和 yang-identifier. 表 2 覆盖 ietf-inet-types 中与互联网协议族相关的类型, 包括 IP version, DSCP, IPv6 flow label, port number, protocol number, AS number, IP address, prefix, host, URI 和 email address. 表 3 和表 4 则说明哪些 YANG 类型与 SMIv2 textual conventions 在取值集合和语义上等价, 这对从 SNMP 管理模型复用语义尤其重要.

从版本演进看, 标注为 RFC 6021 的类型来自最初的 common YANG data types, 标注为 RFC 6991 的类型来自第一次修订, 标注为 RFC 9911 的类型是本次新增或调整的重点. 这能帮助模块作者判断某个 typedef 是否需要声明较新的依赖, 也能帮助实现者在加载旧模型时识别兼容性边界.

概览表不是新的注册表, 而是阅读后续 YANG 源码的索引. 真正的类型语义仍以后面 ietf-yang-typesietf-inet-types 模块中的 typedef 定义为准, 包括 pattern, range, units, union 分支和 reference 语句.

如果只想快速判断某个类型来自哪一版规范, 可先查本节表格; 如果要实现校验逻辑, 则必须继续阅读后续章节的完整 typedef. 这种分层阅读方式能避免把表格中的名称列表误当成完整语义.

本节还提示了 RFC 9911 的兼容性策略: 新类型被加入标准模块, 旧有类型继续保留, 并通过表格展示与历史 RFC 的关系. 这样既能让新模型使用更精确的数据类型, 也能让已有模型在升级引用时保持可理解的来源链路.

规范文本

2.  Overview

Tables 1 and 2 list the types defined in the YANG modules "ietf-yang-
types" and "ietf-inet-types". For each type, the name of the type,
the base type it was derived from, and the RFC introducing the type
is listed.

+=======================+===================+===============+
| Type | Base Type | Introduced in |
+=======================+===================+===============+
| counter32 | uint32 | RFC 6021 |
+-----------------------+-------------------+---------------+
| zero-based-counter32 | uint32 | RFC 6021 |
+-----------------------+-------------------+---------------+
| counter64 | uint64 | RFC 6021 |
+-----------------------+-------------------+---------------+
| zero-based-counter64 | uint64 | RFC 6021 |
+-----------------------+-------------------+---------------+
| gauge32 | uint32 | RFC 6021 |
+-----------------------+-------------------+---------------+
| gauge64 | uint64 | RFC 6021 |
+-----------------------+-------------------+---------------+
| object-identifier | string | RFC 6021 |
+-----------------------+-------------------+---------------+
| object-identifier-128 | object-identifier | RFC 6021 |
+-----------------------+-------------------+---------------+
| date-and-time | string | RFC 6021 |
+-----------------------+-------------------+---------------+
| date | string | RFC 9911 |
+-----------------------+-------------------+---------------+
| date-no-zone | string | RFC 9911 |
+-----------------------+-------------------+---------------+
| time | string | RFC 9911 |
+-----------------------+-------------------+---------------+
| time-no-zone | string | RFC 9911 |
+-----------------------+-------------------+---------------+
| hours32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| minutes32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| seconds32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| centiseconds32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| milliseconds32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| microseconds32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| microseconds64 | int64 | RFC 9911 |
+-----------------------+-------------------+---------------+
| nanoseconds32 | int32 | RFC 9911 |
+-----------------------+-------------------+---------------+
| nanoseconds64 | int64 | RFC 9911 |
+-----------------------+-------------------+---------------+
| timeticks | int32 | RFC 6021 |
+-----------------------+-------------------+---------------+
| timestamp | timeticks | RFC 6021 |
+-----------------------+-------------------+---------------+
| phys-address | string | RFC 6021 |
+-----------------------+-------------------+---------------+
| mac-address | string | RFC 6021 |
+-----------------------+-------------------+---------------+
| xpath1.0 | string | RFC 6021 |
+-----------------------+-------------------+---------------+
| hex-string | string | RFC 6991 |
+-----------------------+-------------------+---------------+
| uuid | string | RFC 6991 |
+-----------------------+-------------------+---------------+
| dotted-quad | string | RFC 6991 |
+-----------------------+-------------------+---------------+
| language-tag | string | RFC 9911 |
+-----------------------+-------------------+---------------+
| yang-identifier | string | RFC 6991 |
+-----------------------+-------------------+---------------+

Table 1: Types Defined in the "ietf-yang-types" Module

+=============================+=================+===============+
| Type | Base Type | Introduced in |
+=============================+=================+===============+
| ip-version | enum | RFC 6021 |
+-----------------------------+-----------------+---------------+
| dscp | uint8 | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ipv6-flow-label | uint32 | RFC 6021 |
+-----------------------------+-----------------+---------------+
| port-number | uint16 | RFC 6021 |
+-----------------------------+-----------------+---------------+
| protocol-number | uint8 | RFC 9911 |
+-----------------------------+-----------------+---------------+
| upper-layer-protocol-number | protocol-number | RFC 9911 |
+-----------------------------+-----------------+---------------+
| as-number | uint32 | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ip-address | union | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ipv4-address | string | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ipv6-address | string | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ip-address-no-zone | union | RFC 6991 |
+-----------------------------+-----------------+---------------+
| ipv4-address-no-zone | ipv4-address | RFC 6991 |
+-----------------------------+-----------------+---------------+
| ipv6-address-no-zone | ipv6-address | RFC 6991 |
+-----------------------------+-----------------+---------------+
| ip-address-link-local | union | RFC 9911 |
+-----------------------------+-----------------+---------------+
| ipv4-address-link-local | ipv4-address | RFC 9911 |
+-----------------------------+-----------------+---------------+
| ipv6-address-link-local | ipv6-address | RFC 9911 |
+-----------------------------+-----------------+---------------+
| ip-prefix | union | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ipv4-prefix | string | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ipv6-prefix | string | RFC 6021 |
+-----------------------------+-----------------+---------------+
| ip-address-and-prefix | union | RFC 9911 |
+-----------------------------+-----------------+---------------+
| ipv4-address-and-prefix | string | RFC 9911 |
+-----------------------------+-----------------+---------------+
| ipv6-address-and-prefix | string | RFC 9911 |
+-----------------------------+-----------------+---------------+
| domain-name | string | RFC 6021 |
+-----------------------------+-----------------+---------------+
| host-name | domain-name | RFC 9911 |
+-----------------------------+-----------------+---------------+
| host | union | RFC 6021 |
+-----------------------------+-----------------+---------------+
| uri | string | RFC 6021 |
+-----------------------------+-----------------+---------------+
| email-address | string | RFC 9911 |
+-----------------------------+-----------------+---------------+

Table 2: Types Defined in the "ietf-inet-types" Module

Some types have an equivalent Structure of Management Information
Version 2 (SMIv2) [RFC2578] [RFC2579] data type. A YANG data type is
equivalent to an SMIv2 data type if the data types have the same set
of values and the semantics of the values are equivalent.

Table 3 lists the types defined in the "ietf-yang-types" YANG module
with their corresponding SMIv2 types, and Table 4 lists the types
defined in the "ietf-inet-types" module with their corresponding
SMIv2 types.

+=======================+================================+
| YANG type | Equivalent SMIv2 type (module) |
+=======================+================================+
| counter32 | Counter32 (SNMPv2-SMI) |
+-----------------------+--------------------------------+
| zero-based-counter32 | ZeroBasedCounter32 (RMON2-MIB) |
+-----------------------+--------------------------------+
| counter64 | Counter64 (SNMPv2-SMI) |
+-----------------------+--------------------------------+
| zero-based-counter64 | ZeroBasedCounter64 (HCNUM-TC) |
+-----------------------+--------------------------------+
| gauge32 | Gauge32 (SNMPv2-SMI) |
+-----------------------+--------------------------------+
| gauge64 | CounterBasedGauge64 (HCNUM-TC) |
+-----------------------+--------------------------------+
| object-identifier-128 | OBJECT IDENTIFIER |
+-----------------------+--------------------------------+
| centiseconds32 | TimeInterval (SNMPv2-TC) |
+-----------------------+--------------------------------+
| timeticks | TimeTicks (SNMPv2-SMI) |
+-----------------------+--------------------------------+
| timestamp | TimeStamp (SNMPv2-TC) |
+-----------------------+--------------------------------+
| phys-address | PhysAddress (SNMPv2-TC) |
+-----------------------+--------------------------------+
| mac-address | MacAddress (SNMPv2-TC) |
+-----------------------+--------------------------------+
| language-tag | LangTag (LANGTAG-TC-MIB) |
+-----------------------+--------------------------------+

Table 3: Equivalent SMIv2 Types for the "ietf-yang-
types" Module

+=================+===============================================+
| YANG type | Equivalent SMIv2 type (module) |
+=================+===============================================+
| ip-version | InetVersion (INET-ADDRESS-MIB) |
+-----------------+-----------------------------------------------+
| dscp | Dscp (DIFFSERV-DSCP-TC) |
+-----------------+-----------------------------------------------+
| ipv6-flow-label | IPv6FlowLabel (IPV6-FLOW-LABEL-MIB) |
+-----------------+-----------------------------------------------+
| port-number | InetPortNumber (INET-ADDRESS-MIB) |
+-----------------+-----------------------------------------------+
| as-number | InetAutonomousSystemNumber (INET-ADDRESS-MIB) |
+-----------------+-----------------------------------------------+
| uri | Uri (URI-TC-MIB) |
+-----------------+-----------------------------------------------+

Table 4: Equivalent SMIv2 Types for the "ietf-inet-types" Module