Writing a getBulkRequest function using SNMPv2 and c++
<p>I am writing a getBulkRequest function which is supposed to allow me to request for a list of information at one go.</p>

<p>For now, I would like to do something simple, using the GetBulkRequest to just sequentially getNextRequest by setting the "Non-Repetition" to "0" in getBulkRequest.</p>

<ul>
<li><strong>Am I writing the format correctly?</strong></li>
<li><strong>For the Oid, do I only need to input ONE Oid(the first item of the Bulk)?</strong></li>
<li><strong>If I wish to get a bulk request starting from the stated Oid, and the following 4 items after the first, do I simply set the "Max-Repetition" to 5?</strong></li>
</ul>

<p>This is the format that I am using, could anyone advise me on whether I am doing it right or not:</p>

<pre><code>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-repetitions
datagram.push_front(QByteArray(1, 5);
datagram.push_front(QByteArray(1, 1);
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(1, 0);
datagram.push_front(QByteArray(1, 1);
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;
</code></pre>

<p>Is the format correct for getBulkRequest to be set out via QUdpSocket::writeDatagram?</p>

<p>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.</p>