
Untitled
By: a guest on
May 25th, 2012 | syntax:
C++ | size: 0.82 KB | hits: 17 | expires: Never
static void parse_elements2(struct mgmt_body_t *pbody, const u_char *p, int offset, int len) {
pbody->numTags = 0;
for(;;) {
if (!TTEST2(*(p + offset), 2)) // there are at least 2 bytes to read
return;
int length = *(p + offset + 1); // 2nd byte
if (!TTEST2(*(p + offset), 2 + length))
return;
tag newTag(*(p + offset), *(p + offset + 1)); // key, size
newTag.setValue(p + offset + 2); // value (the next 'size' variables)
/*printf("%d)\t", pbody->numTags);
printf("[%d]\t", newTag.key);
printf("%d\t", newTag.length);
for (int i = 0; i < newTag.length; i++)
printf("%x ", newTag.value[i]);
printf("\n");*/
pbody->numTags++;
offset += 2 + length;
}
}