rfc1592.txt

来自「<VC++网络游戏建摸与实现>源代码」· 文本 代码 · 共 1,404 行 · 第 1/5 页

TXT
1,404
字号
RFC 1592                        SNMP-DPI                      March 1994   the same information.3.1.1  SNMP PDU TO GET THE AGENT'S DPI PORT   As noted, before a TCP/UDP connection to the SNMP agent can be made,   the sub-agent must learn which port that the agent is listening on.   To do so, it can issue an SNMP GET for the variable dpiPortForTCP.0   (1.3.6.1.4.1.2.2.1.1.1.0) or variable dpiPortForUDP.0   (1.3.6.1.4.1.2.2.1.1.2.0).   The SNMP PDU can be constructed as shown below.  This PDU must be   sent to UDP port 161 on the host where the agent runs (probably the   same host where the sub-agent runs).   The (SNMPv1) packet shown below is for the TCP port.Wijnen, Carpenter, Curran, Sehgal & Waters                     [Page 11]RFC 1592                        SNMP-DPI                      March 1994     +-----------------------------------------------------------------+     | Table 1 (Page 1 of 2). SNMP GET PDU for dpiPortForTCP.0         |     +---------------+----------------+--------------------------------+     | OFFSET        | VALUE          | FIELD                          |     +---------------+----------------+--------------------------------+     | 0             | 0x30           | ASN.1 header                   |     +---------------+----------------+--------------------------------+     | 1             | 37 + len       | PDU_length, see formula below  |     +---------------+----------------+--------------------------------+     | 2             | 0x02 0x01 0x00 | SNMP version:                  |     |               |                | (integer,length=1,value=0)     |     +---------------+----------------+--------------------------------+     | 5             | 0x04           | community name (string)        |     +---------------+----------------+--------------------------------+     | 6             | len            | length of community name       |     +---------------+----------------+--------------------------------+     | 7             | community name | varies                         |     +---------------+----------------+--------------------------------+     | 7 + len       | 0xa0 0x1c      | SNMP GET request:              |     |               |                | request_type=0xa0,length=0x1c  |     +---------------+----------------+--------------------------------+     | 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 0x11      | varBind list, length=0x11      |     +---------------+----------------+--------------------------------+     | 7 + len + 13  | 0x30 0x0f      | varBind, length=0x0f           |     +---------------+----------------+--------------------------------+     | 7 + len + 15  | 0x06 0x0b      | Object ID, length=0x0b         |     +---------------+----------------+--------------------------------+Wijnen, Carpenter, Curran, Sehgal & Waters                     [Page 12]RFC 1592                        SNMP-DPI                      March 1994     +-----------------------------------------------------------------+     | Table 1 (Page 2 of 2). SNMP GET PDU for dpiPortForTCP.0         |     +---------------+----------------+--------------------------------+     | OFFSET        | VALUE          | FIELD                          |     +---------------+----------------+--------------------------------+     | 7 + len + 17  | 0x2b 0x06 0x01 | Object-ID:                     |     |               | 0x04 0x01 0x02 | 1.3.6.1.4.1.2.2.1.1.1          |     |               | 0x02 0x01 0x01 | Object-instance: 0             |     |               | 0x01 0x00      |                                |     +---------------+----------------+--------------------------------+     | 7 + len + 28  | 0x05 0x00      | null value, length=0           |     +---------------+----------------+--------------------------------+     | NOTE:  Formula to calculate "PDU_length":                       |     |                                                                 |     |   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 GET request (32 bytes)           |     |                                                                 |     |              =  37 + length of community name                   |     +-----------------------------------------------------------------+3.1.2  SNMP PDU CONTAINING THE RESPONSE TO THE GET   Assuming that no errors occurred, the port is returned in the last   few octets of the received packet.  In the simple case, where the   port number will be between 1024 and 16,385, the format of the packet   is shown below.   Note: In practice, the port number can be any positive number in the   range from 1 through 65,535.  A port number of 0 means that the agent   does not have a dpiPort defined for the requested protocol.  So the   actual port value maybe in the last 1, 2 or 3 octets.  The sample   implementation code shows how to handle the response to cover all   those cases, including error conditions.   Note: The (SNMPv1) packet shown below is for the TCP port.     +-----------------------------------------------------------------+     | Table 2 (Page 1 of 3). SNMP RESPONSE PDU for dpiPortForTCP.0    |     +---------------+----------------+--------------------------------+     | OFFSET        | VALUE          | FIELD                          |     +---------------+----------------+--------------------------------+     | 0             | 0x30           | ASN.1 header                   |     +---------------+----------------+--------------------------------+     | 1             | 39 + len       | length, see formula below      |     +---------------+----------------+--------------------------------+Wijnen, Carpenter, Curran, Sehgal & Waters                     [Page 13]RFC 1592                        SNMP-DPI                      March 1994     +-----------------------------------------------------------------+     | Table 2 (Page 2 of 3). SNMP RESPONSE PDU for dpiPortForTCP.0    |     +---------------+----------------+--------------------------------+     | OFFSET        | VALUE          | FIELD                          |     +---------------+----------------+--------------------------------+     | 2             | 0x02 0x01 0x00 | version                        |     |               |                | (integer,length=1,value=0)     |     +---------------+----------------+--------------------------------+     | 5             | 0x04           | community name (string)        |     +---------------+----------------+--------------------------------+     | 6             | len            | length of community name       |     +---------------+----------------+--------------------------------+     | 7             | community name |                                |     +---------------+----------------+--------------------------------+     | 7 + len       | 0xa2 0x1e      | SNMP RESPONSE:                 |     |               |                | request_type=0xa2,length=0x1e  |     +---------------+----------------+--------------------------------+     | 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 0x13      | varBind list, length=0x13      |     +---------------+----------------+--------------------------------+     | 7 + len + 13  | 0x30 0x11      | varBind, length=0x11           |     +---------------+----------------+--------------------------------+     | 7 + len + 15  | 0x06 0x0b      | Object ID, length=0x0b         |     +---------------+----------------+--------------------------------+     | 7 + len + 17  | 0x2b 0x06 0x01 | Object-ID:                     |     |               | 0x04 0x01 0x02 | 1.3.6.1.4.1.2.2.1.1.1          |     |               | 0x02 0x01 0x01 | Object-instance: 0             |     |               | 0x01 0x00      |                                |     +---------------+----------------+--------------------------------+     | 7 + len + 28  | 0x02 0x02      | integer, length=2              |     +---------------+----------------+--------------------------------+     | 7 + len + 30  | MSB LSB        | port number (MSB, LSB)         |     +---------------+----------------+--------------------------------+Wijnen, Carpenter, Curran, Sehgal & Waters                     [Page 14]RFC 1592                        SNMP-DPI                      March 1994     +-----------------------------------------------------------------+     | Table 2 (Page 3 of 3). SNMP RESPONSE PDU for dpiPortForTCP.0    |     +---------------+----------------+--------------------------------+     | NOTE:  Formula to calculate "PDU_length":                       |     |                                                                 |     |   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 (34 bytes)              |     |                                                                 |     |              =  39 + length of community name                   |     +-----------------------------------------------------------------+3.2  SNMP DPI PACKET FORMATS   Each request to, or response from, the agent or sub-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, the most   significant byte (MSB) first, least significant byte (LSB) last.  If   we consider a stream connection (like TCP), the receiving side will   read the packet by doing something similar to:          unsigned char len_bfr[2];          unsigned 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,and it is not   intended to be used literally.3.2.1  DPI PACKET HEADER   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 15.Wijnen, Carpenter, Curran, Sehgal & Waters                     [Page 15]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?