Home | History | Annotate | Download | only in resolv

Lines Matching refs:packet

44  *  - it takes raw DNS query packet data as input, and returns raw DNS
45 * answer packet data as output
321 /* dump the content of a query of packet to the log */
346 /* reminder: the general format of a DNS packet is the following:
411 * OFFSET : 14 : offset to another part of the DNS packet
413 * The offset is relative to the start of the DNS packet and must point
448 _dnsPacket_init( DnsPacket* packet, const uint8_t* buff, int bufflen )
450 packet->base = buff;
451 packet->end = buff + bufflen;
452 packet->cursor = buff;
456 _dnsPacket_rewind( DnsPacket* packet )
458 packet->cursor = packet->base;
462 _dnsPacket_skip( DnsPacket* packet, int count )
464 const uint8_t* p = packet->cursor + count;
466 if (p > packet->end)
467 p = packet->end;
469 packet->cursor = p;
473 _dnsPacket_readInt16( DnsPacket* packet )
475 const uint8_t* p = packet->cursor;
477 if (p+2 > packet->end)
480 packet->cursor = p+2;
487 /* check bytes in a dns packet. returns 1 on success, 0 on failure.
491 _dnsPacket_checkBytes( DnsPacket* packet, int numBytes, const void* bytes )
493 const uint8_t* p = packet->cursor;
495 if (p + numBytes > packet->end)
501 packet->cursor = p + numBytes;
505 /* parse and skip a given QNAME stored in a query packet,
510 _dnsPacket_checkQName( DnsPacket* packet )
512 const uint8_t* p = packet->cursor;
513 const uint8_t* end = packet->end;
524 packet->cursor = p;
541 /* parse and skip a given QR stored in a packet.
545 _dnsPacket_checkQR( DnsPacket* packet )
549 if (!_dnsPacket_checkQName(packet))
553 if (!_dnsPacket_checkBytes(packet, 2, DNS_TYPE_A) &&
554 !_dnsPacket_checkBytes(packet, 2, DNS_TYPE_PTR) &&
555 !_dnsPacket_checkBytes(packet, 2, DNS_TYPE_MX) &&
556 !_dnsPacket_checkBytes(packet, 2, DNS_TYPE_AAAA) &&
557 !_dnsPacket_checkBytes(packet, 2, DNS_TYPE_ALL))
563 if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN)) {
571 /* check the header of a DNS Query packet, return 1 if it is one
575 _dnsPacket_checkQuery( DnsPacket* packet )
577 const uint8_t* p = packet->base;
580 if (p + DNS_HEADER_SIZE > packet->end) {
581 XLOG("query packet too small");
588 XLOG("query packet flags unsupported");
595 * - there is no point for a query packet sent to a server
617 XLOG("query packet contains non-query records");
622 XLOG("query packet doesn't contain query record");
627 packet->cursor = p + DNS_HEADER_SIZE;
630 if (!_dnsPacket_checkQR(packet))
640 _dnsPacket_bprintQName(DnsPacket* packet, char* bp, char* bend)
642 const uint8_t* p = packet->cursor;
643 const uint8_t* end = packet->end;
655 packet->cursor = p;
680 _dnsPacket_bprintQR(DnsPacket* packet, char* p, char* end)
695 p = _dnsPacket_bprintQName(packet, p, end);
701 if (_dnsPacket_checkBytes(packet, 2, qTypes[nn].typeBytes)) {
710 int typeCode = _dnsPacket_readInt16(packet);
717 _dnsPacket_skip(packet, 2);
721 /* this function assumes the packet has already been checked */
723 _dnsPacket_bprintQuery( DnsPacket* packet, char* p, char* end )
727 if (packet->base[2] & 0x1) {
731 _dnsPacket_skip(packet, 4);
732 qdCount = _dnsPacket_readInt16(packet);
733 _dnsPacket_skip(packet, 6);
736 p = _dnsPacket_bprintQR(packet, p, end);
745 ** THE FOLLOWING CODE ASSUMES THAT THE INPUT PACKET HAS ALREADY
754 _dnsPacket_hashBytes( DnsPacket* packet, int numBytes, unsigned hash )
756 const uint8_t* p = packet->cursor;
757 const uint8_t* end = packet->end;
762 packet->cursor = p;
768 _dnsPacket_hashQName( DnsPacket* packet, unsigned hash )
770 const uint8_t* p = packet->cursor;
771 const uint8_t* end = packet->end;
800 packet->cursor = p;
805 _dnsPacket_hashQR( DnsPacket* packet, unsigned hash )
809 hash = _dnsPacket_hashQName(packet, hash);
810 hash = _dnsPacket_hashBytes(packet, 4, hash); /* TYPE and CLASS */
815 _dnsPacket_hashQuery( DnsPacket* packet )
819 _dnsPacket_rewind(packet);
828 hash = hash*FNV_MULT ^ (packet->base[2] & 1);
831 _dnsPacket_skip(packet, 4);
834 count = _dnsPacket_readInt16(packet);
837 _dnsPacket_skip(packet, 6);
841 hash = _dnsPacket_hashQR(packet, hash);
1034 /* initialize an Entry as a search key, this also checks the input query packet