SNMPv2 getBulkRequest and setRequest
-
I am working on a colleagues code and I am extremely new to this. I am trying to write a setRequest and getBulkRequest function. He has already written the get request function and it's working.
So I have 2 problems:-
I copied his get request method as I understand setrequest should be the same except that that the value in the variable binding instead of being NULL should be the value u wish to set. I did manage to set but in my console there is this message: "QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread"
-
I am not sure how the format of the pdu for getbulkrequest should be written. I have the pdu format online as pdu type, request I'd, non repeaters, max repetitions followed by object name and value. Am I supposed to set a value in non repeaters and max repetition? Or is it supposed to be set by the response? Is the length of the max repetition and non repeaters supposed to be 4 bytes long? Or is it 1byte?
This is the format that I am using, could anyone advise me on whether I am doing it right or not:
switch(pdyType) {
case PdyType::GET_BULK_REQUEST:for (QStringList::ConstIterator iter = oids.begin(); iter != oids.end(); ++iter) { QByteArray keyHolder; //value keyHolder.push_front(QByteArray(1, 0x00)); keyHolder.push_front(QByteArray(1, DataType::DATA_NULL)); //object identifier QByteArray temp = encodeoid(*iter); keyHolder.push_front(temp); keyHolder.push_front(encodeLengthField(temp.size())); keyHolder.push_front(QByteArray(1, DataType::OBJECT_ID)); //varbind keyHolder.push_front(encodeLengthField(keyHolder.size())); keyHolder.push_front(QByteArray(1, DataType::SEQUENCE)); datagram.push_front(keyHolder); } //max-reperitions datagram.push_front(QByteArray(4, 0); datagram.push_front(QByteArray(1, 4); datagram.push_front(QByteArray(1, DataType::INTEGER); //varbind list datagram.push_front(QByteArray(encodeLengthField(datagram.size()); datagram.push_front(QByteArray(1, DataType::SEQUENCE); //non-repeaters datagram.push_front(QByteArray(4, 0); datagram.push_front(QByteArray(1, 4); datagram.push_front(QByteArray(1, DataType::INTEGER); //requestId datagram.push_front(QByteArray(1, requestId)); datagram.push_front(QByteArray(1, 1); datagram.push_front(QByteArray(1, DataType::INTEGER); //pdu datagram.push_front(QByteArray(encodeLengthField(datagram.size())); datagram.push_front(QByteArray(1, (unsigned char)pduType); //community string datagram.push_front(QByteArray(community.toLocal8Bit())); datagram.push_front(QByteArray(encodeLengthField(community.size()); datagram.push_front(QByteArray(1, DataType::OCTET_STRING); //version datagram.push_front(QByteArray(1, 0)); datagram.push_front(QByteArray(1, 1); datagram.push_front(QByteArray(1, DataType::INTEGER); //message type datagram.push_front(QByteArray(encodeLengthField(datagram.size())); datagram.push_front(QByteArray(1, DataType::SEQUENCE); break;
default:
break;
}
return datagram;Is the format correct for getBulkRequest to be set out via QUdpSocket::writeDatagram?
I hope I am able to phrase my issue clearly. As I am not very sure what is going on at the moment and trying to read up more.
-
-
Hi,
Are you using threads in your application ?
-
Setting a QString and using a socket are not exactly the same thing hence my question about the thread.