Lines Matching refs:offp
84 dns_label_parse_(const uint8_t *buf, unsigned mlen, unsigned *NONNULL offp, const char *file, int line)
86 uint8_t llen = buf[*offp];
90 if (*offp + llen + 1 > mlen) {
91 DEBUG("claimed length of label is too long: %u > %u.\n", *offp + llen + 1, mlen);
103 *offp + llen + 1, *offp + llen + 1, &buf[*offp + 1]);
108 memcpy(rv->data, &buf[*offp + 1], llen);
110 *offp += llen + 1;
116 unsigned *NONNULL offp, unsigned base, const char *file, int line)
120 if (*offp == len) {
125 if ((buf[*offp] & 0xC0) == 0xC0) {
127 if (*offp + 2 > len) {
128 DEBUG("incomplete compression pointer: %u > %u", *offp + 2, len);
131 pointer = (((unsigned)buf[*offp] & 0x3f) << 8) | (unsigned)buf[*offp + 1];
132 *offp += 2;
150 if (buf[pointer] + pointer >= base || buf[pointer] + pointer >= *offp) {
160 if (buf[*offp] & 0xC0) {
161 DEBUG("invalid label type: %x\n", buf[*offp]);
165 rv = dns_label_parse_(buf, len, offp, file, line);
175 return dns_name_parse_in(&rv->next, buf, len, offp, base, file, line);
180 unsigned len, unsigned *NONNULL offp, unsigned base, const char *file, int line)
184 if (!dns_name_parse_in(&rv, buf, len, offp, base, file, line)) {
196 dns_u8_parse(const uint8_t *buf, unsigned len, unsigned *NONNULL offp, uint8_t *NONNULL ret)
199 if (*offp + 1 > len) {
200 DEBUG("dns_u8_parse: not enough room: %u > %u.\n", *offp + 1, len);
204 rv = buf[*offp];
205 *offp += 1;
211 dns_u16_parse(const uint8_t *buf, unsigned len, unsigned *NONNULL offp, uint16_t *NONNULL ret)
214 if (*offp + 2 > len) {
215 DEBUG("dns_u16_parse: not enough room: %u > %u.\n", *offp + 2, len);
219 rv = (uint16_t)(buf[*offp] << 8) | (uint16_t)(buf[*offp + 1]);
220 *offp += 2;
226 dns_u32_parse(const uint8_t *buf, unsigned len, unsigned *NONNULL offp, uint32_t *NONNULL ret)
229 if (*offp + 4 > len) {
230 DEBUG("dns_u32_parse: not enough room: %u > %u.\n", *offp + 4, len);
234 rv = (((uint32_t)(buf[*offp]) << 24) | ((uint32_t)(buf[*offp + 1]) << 16) |
235 ((uint32_t)(buf[*offp + 2]) << 8) | (uint32_t)(buf[*offp + 3]));
236 *offp += 4;
242 dns_u64_parse(const uint8_t *buf, unsigned len, unsigned *NONNULL offp, uint64_t *NONNULL ret)
245 if (*offp + 8 > len) {
246 DEBUG("dns_u64_parse: not enough room: %u > %u.\n", *offp + 8, len);
250 rv = (((uint64_t)(buf[*offp] ) << 56) | ((uint64_t)(buf[*offp + 1]) << 48) |
251 ((uint64_t)(buf[*offp + 2]) << 40) | ((uint64_t)(buf[*offp + 3]) << 32) |
252 ((uint64_t)(buf[*offp + 4]) << 24) | ((uint64_t)(buf[*offp + 5]) << 16) |
253 ((uint64_t)(buf[*offp + 6]) << 8) | ((uint64_t)(buf[*offp + 7])));
254 *offp += 8;
412 dns_rdata_parse_data_(dns_rr_t *NONNULL rr, const uint8_t *buf, unsigned *NONNULL offp, unsigned target, uint16_t rdlen,
415 if (target < *offp) {
416 DEBUG("target %u < *offp %u", target, *offp);
421 if (!dns_u16_parse(buf, target, offp, &rr->data.key.flags) ||
422 !dns_u8_parse(buf, target, offp, &rr->data.key.protocol) ||
423 !dns_u8_parse(buf, target, offp, &rr->data.key.algorithm)) {
426 rr->data.key.len = (unsigned)(target - *offp);
435 memcpy(rr->data.key.key, &buf[*offp], rr->data.key.len);
436 *offp += rr->data.key.len;
441 if (!dns_u16_parse(buf, target, offp, &rr->data.sig.type) ||
442 !dns_u8_parse(buf, target, offp, &rr->data.sig.algorithm) ||
443 !dns_u8_parse(buf, target, offp, &rr->data.sig.label) ||
444 !dns_u32_parse(buf, target, offp, &rr->data.sig.rrttl) ||
445 !dns_u32_parse(buf, target, offp, &rr->data.sig.expiry) ||
446 !dns_u32_parse(buf, target, offp, &rr->data.sig.inception) ||
447 !dns_u16_parse(buf, target, offp, &rr->data.sig.key_tag) ||
448 !dns_name_parse_(&rr->data.sig.signer, buf, target, offp, *offp, file, line)) {
453 rr->data.sig.len = target - *offp;
462 memcpy(rr->data.sig.signature, &buf[*offp], rr->data.sig.len);
463 *offp += rr->data.sig.len;
467 if (!dns_u16_parse(buf, target, offp, &rr->data.srv.priority) ||
468 !dns_u16_parse(buf, target, offp, &rr->data.srv.weight) ||
469 !dns_u16_parse(buf, target, offp, &rr->data.srv.port))
479 if (!dns_name_parse_(&rr->data.ptr.name, buf, target, offp, *offp, file, line)) {
485 offp, *offp, file, line)) {
488 if (!dns_name_parse_(&rr->data.soa.rname, buf, target, offp, *offp, file, line)) {
491 if (!dns_u32_parse(buf, target, offp, &rr->data.soa.serial) ||
492 !dns_u32_parse(buf, target, offp, &rr->data.soa.refresh) ||
493 !dns_u32_parse(buf, target, offp, &rr->data.soa.retry) ||
494 !dns_u32_parse(buf, target, offp, &rr->data.soa.expire) ||
495 !dns_u32_parse(buf, target, offp, &rr->data.soa.minimum))
506 memcpy(&rr->data.a, &buf[*offp], rdlen);
507 *offp = target;
515 memcpy(&rr->data.aaaa, &buf[*offp], rdlen);
516 *offp = target;
521 unsigned left = target - *offp;
538 memcpy(rr->data.txt.data, &buf[*offp], rr->data.txt.len);
539 *offp = target;
553 memcpy(rr->data.unparsed.data, &buf[*offp], rdlen);
556 *offp = target;
559 if (*offp != target) {
560 DEBUG("dns_rdata_parse: parse for rrtype %d not fully contained: %u %u", rr->type, target, *offp);
568 const uint8_t *buf, unsigned len, unsigned *NONNULL offp, unsigned rrstart, const char *file, int line)
573 if (!dns_u16_parse(buf, len, offp, &rdlen)) {
576 target = *offp + rdlen;
580 return dns_rdata_parse_data_(rr, buf, offp, target, rdlen, rrstart, file, line);
584 dns_rr_parse_(dns_rr_t *NONNULL rr, const uint8_t *buf, unsigned len, unsigned *NONNULL offp, bool rrdata_expected,
587 unsigned rrstart = *offp; // Needed to mark the start of the SIG RR for SIG(0).
590 if (!dns_name_parse_(&rr->name, buf, len, offp, *offp, file, line)) {
594 if (!dns_u16_parse(buf, len, offp, &rr->type)) {
598 if (!dns_u16_parse(buf, len, offp, &rr->qclass)) {
603 if (!dns_u32_parse(buf, len, offp, &rr->ttl)) {
606 if (!dns_rdata_parse_(rr, buf, len, offp, rrstart, file, line)) {