跳到主要内容

2. 定义

2. 定义 (Definitions)

本节给出 SNMPv2-TM MIB module 的 ASN.1 定义. 代码块中的 MODULE-IDENTITY、OBJECT-IDENTITY、TEXTUAL-CONVENTION、OID、DISPLAY-HINT 和 SYNTAX 都是可被实现和工具解析的规范文本, 因此保持原文. 中文说明用于帮助读者理解这些对象如何描述 SNMP transport mappings (SNMP 传输映射) 以及不同传输地址的编码方式.

该模块首先声明 SNMPv2-TM 的模块标识和联系方式, 随后定义 UDP/IPv4、OSI、DDP、IPX 以及兼容 SNMPv1 代理场景中的传输域. 每个地址 textual convention 都用 octets 表说明二进制布局, 包括 IP 地址、UDP 端口、NSAP、TSEL、NBP 名称、IPX 网络号和套接字号等字段.

阅读本节时可以按传输域分组理解: snmpUDPDomain 对应最常用的 SNMP over UDP over IPv4, 地址长度固定为 6 个 octets; snmpCLNSDomainsnmpCONSDomain 使用 OSI 地址格式, 地址由 NSAP 长度、NSAP 值和 TSEL 字符串组成; snmpDDPDomain 使用 AppleTalk NBP 名称, 以 object、type 和 zone 三段字符串表示; snmpIPXDomain 则组合 network-number、physical-address 和 socket-number. 这些 textual conventions 不是普通说明文字, 而是管理信息库中 transport address 的规范表示.

SNMPv2-TM DEFINITIONS ::= BEGIN

IMPORTS
MODULE-IDENTITY, OBJECT-IDENTITY,
snmpModules, snmpDomains, snmpProxys
FROM SNMPv2-SMI
TEXTUAL-CONVENTION
FROM SNMPv2-TC;

snmpv2tm MODULE-IDENTITY
LAST-UPDATED "200210160000Z"
ORGANIZATION "IETF SNMPv3 Working Group"
CONTACT-INFO
"WG-EMail: [email protected]
Subscribe: [email protected]

Co-Chair: Russ Mundy
Network Associates Laboratories
postal: 15204 Omega Drive, Suite 300
Rockville, MD 20850-4601
USA
EMail: [email protected]
phone: +1 301 947-7107

Co-Chair: David Harrington
Enterasys Networks
postal: 35 Industrial Way
P. O. Box 5005
Rochester, NH 03866-5005
USA
EMail: [email protected]
phone: +1 603 337-2614

Editor: Randy Presuhn
BMC Software, Inc.
postal: 2141 North First Street
San Jose, CA 95131
USA
EMail: [email protected]
phone: +1 408 546-1006"
DESCRIPTION
"The MIB module for SNMP transport mappings.

Copyright (C) The Internet Society (2002). This
version of this MIB module is part of RFC 3417;
see the RFC itself for full legal notices.
"
REVISION "200210160000Z"
DESCRIPTION
"Clarifications, published as RFC 3417."
REVISION "199601010000Z"
DESCRIPTION
"Clarifications, published as RFC 1906."
REVISION "199304010000Z"
DESCRIPTION
"The initial version, published as RFC 1449."
::= { snmpModules 19 }

-- SNMP over UDP over IPv4

snmpUDPDomain OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The SNMP over UDP over IPv4 transport domain.
The corresponding transport address is of type
SnmpUDPAddress."
::= { snmpDomains 1 }

SnmpUDPAddress ::= TEXTUAL-CONVENTION
DISPLAY-HINT "1d.1d.1d.1d/2d"
STATUS current
DESCRIPTION
"Represents a UDP over IPv4 address:

octets contents encoding
1-4 IP-address network-byte order
5-6 UDP-port network-byte order
"
SYNTAX OCTET STRING (SIZE (6))

-- SNMP over OSI

snmpCLNSDomain OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The SNMP over CLNS transport domain.
The corresponding transport address is of type
SnmpOSIAddress."
::= { snmpDomains 2 }

snmpCONSDomain OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The SNMP over CONS transport domain.
The corresponding transport address is of type
SnmpOSIAddress."
::= { snmpDomains 3 }

SnmpOSIAddress ::= TEXTUAL-CONVENTION
DISPLAY-HINT "*1x:/1x:"
STATUS current
DESCRIPTION
"Represents an OSI transport-address:

octets contents encoding
1 length of NSAP 'n' as an unsigned-integer
(either 0 or from 3 to 20)
2..(n+1) NSAP concrete binary representation
(n+2)..m TSEL string of (up to 64) octets
"
SYNTAX OCTET STRING (SIZE (1 | 4..85))

-- SNMP over DDP

snmpDDPDomain OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The SNMP over DDP transport domain.
The corresponding transport address is of type
SnmpNBPAddress."
::= { snmpDomains 4 }

SnmpNBPAddress ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents an NBP name:

octets contents encoding
1 length of object 'n' as an unsigned integer
2..(n+1) object string of (up to 32) octets
n+2 length of type 'p' as an unsigned integer
(n+3)..(n+2+p) type string of (up to 32) octets
n+3+p length of zone 'q' as an unsigned integer
(n+4+p)..(n+3+p+q) zone string of (up to 32) octets

For comparison purposes, strings are case-insensitive. All
strings may contain any octet other than 255 (hex ff)."
SYNTAX OCTET STRING (SIZE (3..99))

-- SNMP over IPX

snmpIPXDomain OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The SNMP over IPX transport domain.
The corresponding transport address is of type
SnmpIPXAddress."
::= { snmpDomains 5 }

SnmpIPXAddress ::= TEXTUAL-CONVENTION
DISPLAY-HINT "4x.1x:1x:1x:1x:1x:1x.2d"
STATUS current
DESCRIPTION
"Represents an IPX address:

octets contents encoding
1-4 network-number network-byte order
5-10 physical-address network-byte order
11-12 socket-number network-byte order
"
SYNTAX OCTET STRING (SIZE (12))

-- for proxy to SNMPv1 (RFC 1157)

rfc1157Proxy OBJECT IDENTIFIER ::= { snmpProxys 1 }

rfc1157Domain OBJECT-IDENTITY
STATUS deprecated
DESCRIPTION
"The transport domain for SNMPv1 over UDP over IPv4.
The corresponding transport address is of type
SnmpUDPAddress."
::= { rfc1157Proxy 1 }

END

实现者在使用这些定义时, 应将上面的 ASN.1 视为权威规范文本. 其中的英文描述、对象名和取值范围需要保持精确一致, 因为它们会影响 MIB 编译、管理站与代理之间的互操作, 以及旧版 SNMP over UDP/IPv4 代理的兼容处理.

对于已经标记为 deprecated 的 rfc1157Domain, 读者应理解为兼容性入口, 用于描述 SNMPv1 over UDP over IPv4 的代理场景. 新实现通常不会优先选择它, 但管理系统在桥接旧版代理或解释历史 MIB 数据时仍可能遇到这些对象标识符.

本节的关键结论是: RFC 3417 并不重新定义 SNMP 消息语义, 而是规定不同底层传输如何表达 SNMP 端点地址. 因此, 管理站在选择传输域时需要同时保存 domain OID 和对应地址类型, 否则相同的 octet string 可能在不同传输映射下具有不同含义.

这也是本节包含完整 ASN.1 的原因: 地址大小、字段顺序和对象标识符层级都是互操作条件, 不能用摘要替代.