! \brief Skips over a domain name in a dns message * (it can be a sequence of labels ending in \\0, a pointer or * a sequence of labels ending in a pointer -- see rfc1035 * returns pointer after the domain name or null on error */
| 765 | * returns pointer after the domain name or null on error |
| 766 | */ |
| 767 | unsigned char* dns_skipname(unsigned char* p, unsigned char* end) |
| 768 | { |
| 769 | while(p<end) { |
| 770 | /* check if \0 (root label length) */ |
| 771 | if (*p==0){ |
| 772 | p+=1; |
| 773 | break; |
| 774 | } |
| 775 | /* check if we found a pointer */ |
| 776 | if (((*p)&0xc0)==0xc0){ |
| 777 | /* if pointer skip over it (2 bytes) & we found the end */ |
| 778 | p+=2; |
| 779 | break; |
| 780 | } |
| 781 | /* normal label */ |
| 782 | p+=*p+1; |
| 783 | } |
| 784 | return (p>=end)?0:p; |
| 785 | } |
| 786 | |
| 787 | |
| 788 |