Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/dns.cpp
Show All 40 Lines | typedef enum { | ||||
TYPE_CNAME = 5, | TYPE_CNAME = 5, | ||||
TYPE_SOA = 6, | TYPE_SOA = 6, | ||||
TYPE_MX = 15, | TYPE_MX = 15, | ||||
TYPE_AAAA = 28, | TYPE_AAAA = 28, | ||||
TYPE_SRV = 33, | TYPE_SRV = 33, | ||||
QTYPE_ANY = 255 | QTYPE_ANY = 255 | ||||
} dns_type; | } dns_type; | ||||
// 0: ok | int parse_name(const uint8_t **inpos, const uint8_t *inend, | ||||
// -1: premature end of input, forward reference, component > 63 char, invalid | |||||
// character | |||||
// -2: insufficient space in output | |||||
static int parse_name(const uint8_t **inpos, const uint8_t *inend, | |||||
const uint8_t *inbuf, char *buf, size_t bufsize) { | const uint8_t *inbuf, char *buf, size_t bufsize) { | ||||
size_t bufused = 0; | size_t bufused = 0; | ||||
int init = 1; | int init = 1; | ||||
do { | do { | ||||
if (*inpos == inend) return -1; | if (*inpos == inend) return -1; | ||||
// read length of next component | // read length of next component | ||||
int octet = *((*inpos)++); | int octet = *((*inpos)++); | ||||
if (octet == 0) { | if (octet == 0) { | ||||
buf[bufused] = 0; | buf[bufused] = 0; | ||||
▲ Show 20 Lines • Show All 547 Lines • Show Last 20 Lines |