#include "squid.h"
#include "dns/rfc1035.h"
#include "dns/rfc2671.h"
#include "util.h"
#include <cassert>
#include <cstring>
Go to the source code of this file.
Macros | |
#define | RFC1035_MAXLABELSZ 63 |
#define | rfc1035_unpack_error 15 |
#define | RFC1035_UNPACK_DEBUG (void)0 |
Functions | |
int | rfc1035HeaderPack (char *buf, size_t sz, rfc1035_message *hdr) |
static int | rfc1035LabelPack (char *buf, size_t sz, const char *label) |
static int | rfc1035NamePack (char *buf, size_t sz, const char *name) |
int | rfc1035QuestionPack (char *buf, const size_t sz, const char *name, const unsigned short type, const unsigned short _class) |
int | rfc1035HeaderUnpack (const char *buf, size_t sz, unsigned int *off, rfc1035_message *h) |
static int | rfc1035NameUnpack (const char *buf, size_t sz, unsigned int *off, unsigned short *rdlength, char *name, size_t ns, int rdepth) |
int | rfc1035RRPack (char *buf, const size_t sz, const rfc1035_rr *RR) |
static int | rfc1035RRUnpack (const char *buf, size_t sz, unsigned int *off, rfc1035_rr *RR) |
const char * | rfc1035ErrorMessage (int n) |
void | rfc1035RRDestroy (rfc1035_rr **rr, int n) |
static int | rfc1035QueryUnpack (const char *buf, size_t sz, unsigned int *off, rfc1035_query *query) |
void | rfc1035MessageDestroy (rfc1035_message **msg) |
int | rfc1035QueryCompare (const rfc1035_query *a, const rfc1035_query *b) |
int | rfc1035MessageUnpack (const char *buf, size_t sz, rfc1035_message **answer) |
ssize_t | rfc1035BuildAQuery (const char *hostname, char *buf, size_t sz, unsigned short qid, rfc1035_query *query, ssize_t edns_sz) |
ssize_t | rfc1035BuildPTRQuery (const struct in_addr addr, char *buf, size_t sz, unsigned short qid, rfc1035_query *query, ssize_t edns_sz) |
void | rfc1035SetQueryID (char *buf, unsigned short qid) |
Macro Definition Documentation
◆ RFC1035_MAXLABELSZ
#define RFC1035_MAXLABELSZ 63 |
Definition at line 40 of file rfc1035.cc.
◆ RFC1035_UNPACK_DEBUG
#define RFC1035_UNPACK_DEBUG (void)0 |
Definition at line 46 of file rfc1035.cc.
◆ rfc1035_unpack_error
#define rfc1035_unpack_error 15 |
Definition at line 41 of file rfc1035.cc.
Function Documentation
◆ rfc1035BuildAQuery()
ssize_t rfc1035BuildAQuery | ( | const char * | hostname, |
char * | buf, | ||
size_t | sz, | ||
unsigned short | qid, | ||
rfc1035_query * | query, | ||
ssize_t | edns_sz | ||
) |
Definition at line 658 of file rfc1035.cc.
References _rfc1035_message::arcount, assert, _rfc1035_message::id, int, _rfc1035_query::name, _rfc1035_message::opcode, _rfc1035_query::qclass, _rfc1035_message::qdcount, _rfc1035_message::qr, _rfc1035_query::qtype, _rfc1035_message::rd, RFC1035_CLASS_IN, RFC1035_TYPE_A, rfc1035HeaderPack(), rfc1035QuestionPack(), rfc2671RROptPack(), and xstrncpy().
◆ rfc1035BuildPTRQuery()
ssize_t rfc1035BuildPTRQuery | ( | const struct in_addr | addr, |
char * | buf, | ||
size_t | sz, | ||
unsigned short | qid, | ||
rfc1035_query * | query, | ||
ssize_t | edns_sz | ||
) |
Definition at line 697 of file rfc1035.cc.
References _rfc1035_message::arcount, assert, _rfc1035_message::id, int, _rfc1035_query::name, _rfc1035_message::opcode, _rfc1035_query::qclass, _rfc1035_message::qdcount, _rfc1035_message::qr, _rfc1035_query::qtype, _rfc1035_message::rd, RFC1035_CLASS_IN, RFC1035_TYPE_PTR, rfc1035HeaderPack(), rfc1035QuestionPack(), rfc2671RROptPack(), and xstrncpy().
◆ rfc1035ErrorMessage()
const char * rfc1035ErrorMessage | ( | int | n | ) |
Definition at line 444 of file rfc1035.cc.
References rfc1035_unpack_error.
Referenced by idnsCheckQueue(), idnsGrokReply(), and TestRfc1035::testBugPacketHeadersOnly().
◆ rfc1035HeaderPack()
int rfc1035HeaderPack | ( | char * | buf, |
size_t | sz, | ||
rfc1035_message * | hdr | ||
) |
Definition at line 56 of file rfc1035.cc.
References _rfc1035_message::aa, _rfc1035_message::ancount, _rfc1035_message::arcount, assert, _rfc1035_message::id, _rfc1035_message::nscount, _rfc1035_message::opcode, _rfc1035_message::qdcount, _rfc1035_message::qr, _rfc1035_message::ra, _rfc1035_message::rcode, _rfc1035_message::rd, and _rfc1035_message::tc.
Referenced by rfc1035BuildAQuery(), rfc1035BuildPTRQuery(), and rfc3596BuildHostQuery().
◆ rfc1035HeaderUnpack()
int rfc1035HeaderUnpack | ( | const char * | buf, |
size_t | sz, | ||
unsigned int * | off, | ||
rfc1035_message * | h | ||
) |
Definition at line 180 of file rfc1035.cc.
References _rfc1035_message::aa, _rfc1035_message::ancount, _rfc1035_message::arcount, assert, _rfc1035_message::id, _rfc1035_message::nscount, _rfc1035_message::opcode, _rfc1035_message::qdcount, _rfc1035_message::qr, _rfc1035_message::ra, _rfc1035_message::rcode, _rfc1035_message::rd, and _rfc1035_message::tc.
Referenced by rfc1035MessageUnpack(), TestRfc1035::testBugPacketEndingOnCompressionPtr(), TestRfc1035::testBugPacketHeadersOnly(), and TestRfc1035::testHeaderUnpack().
◆ rfc1035LabelPack()
Definition at line 101 of file rfc1035.cc.
References assert, and RFC1035_MAXLABELSZ.
Referenced by rfc1035NamePack().
◆ rfc1035MessageDestroy()
void rfc1035MessageDestroy | ( | rfc1035_message ** | msg | ) |
Definition at line 530 of file rfc1035.cc.
References rfc1035RRDestroy(), and xfree.
Referenced by idns_query::~idns_query(), idnsGrokReply(), rfc1035MessageUnpack(), TestRfc1035::testBugPacketEndingOnCompressionPtr(), and TestRfc1035::testParseAPacket().
◆ rfc1035MessageUnpack()
int rfc1035MessageUnpack | ( | const char * | buf, |
size_t | sz, | ||
rfc1035_message ** | answer | ||
) |
Definition at line 584 of file rfc1035.cc.
References _rfc1035_message::ancount, _rfc1035_message::answer, int, _rfc1035_message::qdcount, _rfc1035_message::query, _rfc1035_message::rcode, RFC1035_UNPACK_DEBUG, rfc1035_unpack_error, rfc1035HeaderUnpack(), rfc1035MessageDestroy(), rfc1035QueryUnpack(), rfc1035RRUnpack(), xcalloc(), and xfree.
Referenced by idnsGrokReply(), TestRfc1035::testBugPacketEndingOnCompressionPtr(), TestRfc1035::testBugPacketHeadersOnly(), and TestRfc1035::testParseAPacket().
◆ rfc1035NamePack()
Definition at line 126 of file rfc1035.cc.
References assert, rfc1035LabelPack(), xfree, and xstrdup.
Referenced by rfc1035QuestionPack(), and rfc1035RRPack().
◆ rfc1035NameUnpack()
|
static |
Definition at line 243 of file rfc1035.cc.
References assert, RFC1035_MAXLABELSZ, RFC1035_UNPACK_DEBUG, rfc1035NameUnpack(), and size_t.
Referenced by rfc1035NameUnpack(), rfc1035QueryUnpack(), and rfc1035RRUnpack().
◆ rfc1035QueryCompare()
int rfc1035QueryCompare | ( | const rfc1035_query * | a, |
const rfc1035_query * | b | ||
) |
Definition at line 550 of file rfc1035.cc.
References _rfc1035_query::name, _rfc1035_query::qclass, and _rfc1035_query::qtype.
Referenced by idnsGrokReply().
◆ rfc1035QueryUnpack()
|
static |
Definition at line 507 of file rfc1035.cc.
References _rfc1035_query::name, _rfc1035_query::qclass, _rfc1035_query::qtype, RFC1035_MAXHOSTNAMESZ, RFC1035_UNPACK_DEBUG, and rfc1035NameUnpack().
Referenced by rfc1035MessageUnpack().
◆ rfc1035QuestionPack()
int rfc1035QuestionPack | ( | char * | buf, |
const size_t | sz, | ||
const char * | name, | ||
const unsigned short | type, | ||
const unsigned short | _class | ||
) |
Definition at line 149 of file rfc1035.cc.
References assert, and rfc1035NamePack().
Referenced by rfc1035BuildAQuery(), rfc1035BuildPTRQuery(), and rfc3596BuildHostQuery().
◆ rfc1035RRDestroy()
void rfc1035RRDestroy | ( | rfc1035_rr ** | rr, |
int | n | ||
) |
◆ rfc1035RRPack()
int rfc1035RRPack | ( | char * | buf, |
const size_t | sz, | ||
const rfc1035_rr * | RR | ||
) |
Definition at line 325 of file rfc1035.cc.
References rfc1035_rr::_class, assert, rfc1035_rr::name, rfc1035_rr::rdata, rfc1035_rr::rdlength, rfc1035NamePack(), rfc1035_rr::ttl, and rfc1035_rr::type.
Referenced by rfc2671RROptPack().
◆ rfc1035RRUnpack()
|
static |
Definition at line 369 of file rfc1035.cc.
References rfc1035_rr::_class, assert, rfc1035_rr::name, rfc1035_rr::rdata, rfc1035_rr::rdlength, RFC1035_MAXHOSTNAMESZ, RFC1035_TYPE_A, RFC1035_TYPE_PTR, RFC1035_UNPACK_DEBUG, rfc1035NameUnpack(), rfc1035_rr::ttl, rfc1035_rr::type, xfree, and xmalloc.
Referenced by rfc1035MessageUnpack().
◆ rfc1035SetQueryID()
void rfc1035SetQueryID | ( | char * | buf, |
unsigned short | qid | ||
) |
Definition at line 739 of file rfc1035.cc.