rfc1228.txt
来自「RFC 的详细文档!」· 文本 代码 · 共 1,641 行 · 第 1/5 页
TXT
1,641 行
+----------------------------------------------------------------------+
The formula to calculate the length field "pdu_length" is as follows:
pdu_length = length of version field and string tag (4 bytes)
Carpenter & Wijnen [Page 6]
RFC 1228 SNMP-DPI May 1991
+ length of community length field (1 byte)
+ length of community name (depends...)
+ length of SNMP GET request (29 bytes)
= 34 + length of community name
Carpenter & Wijnen [Page 7]
RFC 1228 SNMP-DPI May 1991
SNMP PDU CONTAINING THE RESPONSE TO THE GET
Assuming that no errors occured, then the port is returned in the last 2
octets of the received packet. The format of the packet is shown below:
+----------------------------------------------------------------------+
| Table 2. SNMP RESPONSE PDU for GET of Agent's DPI port. This is the |
| layout of an SNMP RESPONSE PDU for GET DPI_port |
+-----------------+-----------------+----------------------------------+
| OFFSET | VALUE | FIELD |
+-----------------+-----------------+----------------------------------+
| 0 | 0x30 | ASN.1 header |
+-----------------+-----------------+----------------------------------+
| 1 | 36 + len | length, see formula below |
+-----------------+-----------------+----------------------------------+
| 2 | 0x02 0x01 0x00 | version (integer, length=1, |
| | 0x04 | value=0), community name |
| | | (string) |
+-----------------+-----------------+----------------------------------+
| 6 | len | length of community name |
+-----------------+-----------------+----------------------------------+
| 7 | community name | |
+-----------------+-----------------+----------------------------------+
| 7 + len | 0xa2 0x1d | SNMP RESPONSE: |
| | | request_type=0xa2, length=0x1d |
+-----------------+-----------------+----------------------------------+
| 7 + len + 2 | 0x02 0x01 0x01 | SNMP request ID: integer, |
| | | length=1, ID=1 |
+-----------------+-----------------+----------------------------------+
| 7 + len + 5 | 0x02 0x01 0x00 | SNMP error status: integer, |
| | | length=1, error=0 |
+-----------------+-----------------+----------------------------------+
| 7 + len + 8 | 0x02 0x01 0x00 | SNMP index: integer, length=1, |
| | | index=0 |
+-----------------+-----------------+----------------------------------+
| 7 + len + 11 | 0x30 0x12 | Varbind list, length=0x12 |
+-----------------+-----------------+----------------------------------+
| 7 + len + 13 | 0x30 0x10 | Varbind, length=0x10 |
+-----------------+-----------------+----------------------------------+
| 7 + len + 15 | 0x06 0x0a | Object ID, length=0x0a |
+-----------------+-----------------+----------------------------------+
+----------------------------------------------------------------------+
Carpenter & Wijnen [Page 8]
RFC 1228 SNMP-DPI May 1991
+----------------------------------------------------------------------+
| Table 2. SNMP RESPONSE PDU for GET of Agent's DPI port. This is the |
| layout of an SNMP RESPONSE PDU for GET DPI_port |
+-----------------+-----------------+----------------------------------+
| OFFSET | VALUE | FIELD |
+-----------------+-----------------+----------------------------------+
| 7 + len + 17 | 0x2b 0x06 0x01 | Object instance: |
| | 0x04 0x01 0x02 | 1.3.6.1.4.1.2.2.1.1.0 |
| | 0x02 0x01 0x01 | |
| | 0x00 | |
+-----------------+-----------------+----------------------------------+
| 7 + len + 27 | 0x02 0x02 | integer, length=2 |
+-----------------+-----------------+----------------------------------+
| 7 + len + 29 | msb lsb | port number (msb, lsb) |
+-----------------+-----------------+----------------------------------+
+----------------------------------------------------------------------+
The formula to calculate the length field "pdu_length" is as follows:
pdu_length = length of version field and string tag (4 bytes)
+ length of community length field (1 byte)
+ length of community name (depends...)
+ length of SNMP RESPONSE (31 bytes)
= 36 + length of community name
SNMP DPI PACKET FORMATS
Each request to or response from the agent is constructed as a
"packet" and is written to the stream.
Each packet is prefaced with the length of the data remaining in the
packet. The length is stored in network byte order (most significant
byte first, least significant last). The receiving side will read
the packet by doing something similar to:
unsigned char len_bfr[2];
char *bfr;
int len;
read(fd,len_bfr,2);
len = len_bfr[0] * 256 + len_bfr[1];
bfr = malloc(len);
read(fd,bfr,len);
NOTE: the above example makes no provisions for error handling or a
read returning less than the requested amount of data. This is not a
suggested coding style.
Carpenter & Wijnen [Page 9]
RFC 1228 SNMP-DPI May 1991
The first part of every packet identifies the application protocol
being used, as well as some version information. The protocol major
version is intended to indicate in broad terms what version of the
protocol is used. The protocol minor version is intended to identify
major incompatible versions of the protocol. The protocol release is
intended to indicate incremental modifications to the protocol. The
constants that are valid for these fields are defined in Table 10 on
page 18.
The next (common) field in all packets is the packet type. This
field indicates what kind of packet we're dealing with (SNMP DPI GET,
GET-NEXT, SET, TRAP, RESPONSE or REGISTER). The permitted values for
this field are defined in Table 11 on page 18.
+----------------------------------------------------------------------+
| Table 3. SNMP DPI packet header. This header is present in all |
| packets. |
+-------------+--------------------------------------------------------+
| OFFSET | FIELD |
+-------------+--------------------------------------------------------+
| 0 | packet length to follow (MSB) |
+-------------+--------------------------------------------------------+
| 1 | packet length to follow (LSB) |
+-------------+--------------------------------------------------------+
| 2 | protocol major version |
+-------------+--------------------------------------------------------+
| 3 | protocol minor version |
+-------------+--------------------------------------------------------+
| 4 | protocol release |
+-------------+--------------------------------------------------------+
| 5 | packet type |
+-------------+--------------------------------------------------------+
+----------------------------------------------------------------------+
>From this point onwards, the contents of the packet are defined by the
protocol being used. The remainder of this section describes:
o the structure of packets for the SNMP DPI protocol, version 1.0.
o The constants as defined with this version of the protocol.
Carpenter & Wijnen [Page 10]
RFC 1228 SNMP-DPI May 1991
REGISTER
In order to register a branch in the MIB tree, an SNMP sub-agent
sends an SNMP DPI REGISTER packet to the agent.
Such a packet contains the standard SNMP DPI header plus REGISTER-
specific data, which basically is a null terminated string
representing the object ID in dotted ASN.1 notation (with a trailing
dot!).
+----------------------------------------------------------------------+
| Table 4. SNMP DPI REGISTER packet. This is the layout of an SNMP |
| DPI REGISTER packet |
+-------------+--------------------------------------------------------+
| OFFSET | FIELD |
+-------------+--------------------------------------------------------+
| 0 | packet length to follow (MSB) |
+-------------+--------------------------------------------------------+
| 1 | packet length to follow (LSB) |
+-------------+--------------------------------------------------------+
| 2 | protocol major version |
+-------------+--------------------------------------------------------+
| 3 | protocol minor version |
+-------------+--------------------------------------------------------+
| 4 | protocol release |
+-------------+--------------------------------------------------------+
| 5 | packet type = SNMP_DPI_REGISTER |
+-------------+--------------------------------------------------------+
| 6 | null terminated object ID |
+-------------+--------------------------------------------------------+
+----------------------------------------------------------------------+
Carpenter & Wijnen [Page 11]
RFC 1228 SNMP-DPI May 1991
GET
When the SNMP agent receives a PDU containing an SNMP GET request for
a variable that a sub-agent registered with the agent, it passes an
SNMP DPI GET packet to the sub-agent.
Such a packet contains the standard SNMP DPI header plus GET-specific
data, which is basically a null terminated string representing the
object ID in dotted ASN.1 notation.
+----------------------------------------------------------------------+
| Table 5. SNMP DPI GET packet. This is the layout of an SNMP DPI GET |
| packet |
+-------------+--------------------------------------------------------+
| OFFSET | FIELD |
+-------------+--------------------------------------------------------+
| 0 | packet length to follow (MSB) |
+-------------+--------------------------------------------------------+
| 1 | packet length to follow (LSB) |
+-------------+--------------------------------------------------------+
| 2 | protocol major version |
+-------------+--------------------------------------------------------+
| 3 | protocol minor version |
+-------------+--------------------------------------------------------+
| 4 | protocol release |
+-------------+--------------------------------------------------------+
| 5 | packet type = SNMP_DPI_GET |
+-------------+--------------------------------------------------------+
| 6 | null terminated object ID |
+-------------+--------------------------------------------------------+
+----------------------------------------------------------------------+
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?