Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: C++  |  size: 0.82 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. static void parse_elements2(struct mgmt_body_t *pbody, const u_char *p, int offset, int len) {
  2.  
  3.     pbody->numTags = 0;
  4.     for(;;) {
  5.         if  (!TTEST2(*(p + offset), 2)) // there are at least 2 bytes to read
  6.             return;
  7.  
  8.         int length = *(p + offset + 1); // 2nd byte
  9.  
  10.         if (!TTEST2(*(p + offset), 2 + length))
  11.             return;
  12.  
  13.         tag newTag(*(p + offset), *(p + offset + 1)); // key, size
  14.         newTag.setValue(p + offset + 2);              // value (the next 'size' variables)
  15.  
  16.         /*printf("%d)\t", pbody->numTags);
  17.         printf("[%d]\t", newTag.key);
  18.         printf("%d\t", newTag.length);
  19.         for (int i = 0; i < newTag.length; i++)
  20.             printf("%x ", newTag.value[i]);
  21.         printf("\n");*/
  22.         pbody->numTags++;
  23.  
  24.         offset += 2 + length;
  25.     }
  26. }