Я почти завершил ее, но их это проблема, которую я не могу решить.
Я успешно запрашиваю одну переменную, отправляя один пакет «Get», но мне нужно запросить несколько переменных, отправив один пакет.
Я пробовал так:
Код: Выделить всё
//variable bindings
p[bytepos++] = 0x30; //variable bindings sequence
p[bytepos++] = Convert.ToByte(6 + oid_len - 1 + 6 + oid_len2 - 1); // Size of variable binding
p[bytepos++] = 0x30; //first variable bindings sequence
p[bytepos++] = Convert.ToByte(4 + oid_len - 1); // size
p[bytepos++] = 0x06; //Object type
p[bytepos++] = Convert.ToByte(oid_len - 1 ); //length
//Start of MIB
p[bytepos++] = 0x2b;
for (i = 2; i < oid_len; i++)
p[bytepos++] = Convert.ToByte(oid[i]);
p[bytepos++] = 0x05; //Null object value
p[bytepos++] = 0x00; //Null
//start of second variable bindings sequence
p[bytepos++] = 0x30; //Second variable bindings sequence
p[bytepos++] = Convert.ToByte(4 + oid_len2 - 1); // size
p[bytepos++] = 0x06; //Object type
p[bytepos++] = Convert.ToByte(oid_len2 - 1); //length
//Start of MIB
p[bytepos++] = 0x2b;
//Place MIB array in packet
for (i2 = 2; i2 < oid_len2; i2++)
p[bytepos++] = Convert.ToByte(oid2[i2]);
p[bytepos++] = 0x05; //Null object value
p[bytepos++] = 0x00; //Null
Подробнее здесь: https://stackoverflow.com/questions/105 ... n-snmp-pdu
Мобильная версия