Created
July 16, 2020 18:28
-
-
Save DRiKE/06a98eabdbb5682a3c3bada84a8d300c to your computer and use it in GitHub Desktop.
XDP blog, post 1 gist 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static __always_inline | |
uint8_t *parse_dname(struct cursor *c, uint8_t *pkt) | |
{ | |
uint8_t *dname = c->pos; | |
int i; | |
for (i = 0; i < 128; i++) { /* Maximum 128 labels */ | |
uint8_t o; | |
if (c->pos + 1 > c->end) | |
return 0; | |
o = *(uint8_t *)c->pos; | |
if ((o & 0xC0) == 0xC0) { | |
/* Compression label, Only back references! */ | |
if ((o | 0x3F) >= (dname - pkt)) | |
return 0; | |
/* Compression label is the last label of a dname. */ | |
c->pos += 1; | |
break; | |
} else if (o & 0xC0) | |
/* Unknown label type */ | |
return 0; | |
c->pos += o + 1; | |
if (!o) | |
break; | |
} | |
return dname; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be
o & 0x3F
on line 16.