2012-05-24 18:44:48 +02:00
|
|
|
#include "../src/hammer.h"
|
|
|
|
|
#include "dns_common.h"
|
|
|
|
|
#include "rr.h"
|
|
|
|
|
|
|
|
|
|
#define false 0
|
|
|
|
|
#define true 1
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_cname() {
|
|
|
|
|
static const HParser *cname = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (cname)
|
|
|
|
|
return cname;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
cname = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return cname;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_hinfo() {
|
|
|
|
|
static const HParser *hinfo = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (hinfo)
|
|
|
|
|
return hinfo;
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* cstr = init_character_string();
|
2012-05-24 18:44:48 +02:00
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
hinfo = h_sequence(cstr,
|
|
|
|
|
cstr,
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return hinfo;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_mb() {
|
|
|
|
|
static const HParser *mb = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (mb)
|
|
|
|
|
return mb;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
mb = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return mb;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_md() {
|
|
|
|
|
static const HParser *md = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (md)
|
|
|
|
|
return md;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
md = h_sequence(init_domain(),
|
|
|
|
|
h_end_p,
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return md;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_mf() {
|
|
|
|
|
static const HParser *mf = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (mf)
|
|
|
|
|
return mf;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
mf = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return mf;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_mg() {
|
|
|
|
|
static const HParser *mg = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (mg)
|
|
|
|
|
return mg;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
mg = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return mg;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_minfo() {
|
|
|
|
|
static const HParser *minfo = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (minfo)
|
|
|
|
|
return minfo;
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* domain = init_domain();
|
2012-05-24 18:44:48 +02:00
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
minfo = h_sequence(domain,
|
|
|
|
|
domain,
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return minfo;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_mr() {
|
|
|
|
|
static const HParser *mr = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (mr)
|
|
|
|
|
return mr;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
mr = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return mr;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_mx() {
|
|
|
|
|
static const HParser *mx = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (mx)
|
|
|
|
|
return mx;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
mx = h_sequence(h_uint16(),
|
|
|
|
|
init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return mx;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
bool validate_null(HParseResult *p) {
|
2012-05-24 18:44:48 +02:00
|
|
|
if (TT_SEQUENCE != p->ast->token_type)
|
|
|
|
|
return false;
|
|
|
|
|
return (65536 > p->ast->seq->used);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_null() {
|
|
|
|
|
static const HParser *null_ = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (null_)
|
|
|
|
|
return null_;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
null_ = h_attr_bool(h_many(h_uint8()), validate_null);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return null_;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_ns() {
|
|
|
|
|
static const HParser *ns = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (ns)
|
|
|
|
|
return ns;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
ns = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return ns;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_ptr() {
|
|
|
|
|
static const HParser *ptr = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (ptr)
|
|
|
|
|
return ptr;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
ptr = h_sequence(init_domain(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_soa() {
|
|
|
|
|
static const HParser *soa = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (soa)
|
|
|
|
|
return soa;
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser *domain = init_domain();
|
2012-05-24 18:44:48 +02:00
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
soa = h_sequence(domain, // MNAME
|
|
|
|
|
domain, // RNAME
|
|
|
|
|
h_uint32(), // SERIAL
|
|
|
|
|
h_uint32(), // REFRESH
|
|
|
|
|
h_uint32(), // RETRY
|
|
|
|
|
h_uint32(), // EXPIRE
|
|
|
|
|
h_uint32(), // MINIMUM
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return soa;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_txt() {
|
|
|
|
|
static const HParser *txt = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (txt)
|
|
|
|
|
return txt;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
txt = h_sequence(h_many1(init_character_string()),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return txt;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_a() {
|
|
|
|
|
static const HParser *a = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (a)
|
|
|
|
|
return a;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
a = h_sequence(h_uint32(),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 13:23:00 +02:00
|
|
|
const HParser* init_wks() {
|
|
|
|
|
static const HParser *wks = NULL;
|
2012-05-24 18:44:48 +02:00
|
|
|
if (wks)
|
|
|
|
|
return wks;
|
|
|
|
|
|
2012-05-26 14:27:12 +02:00
|
|
|
wks = h_sequence(h_uint32(),
|
|
|
|
|
h_uint8(),
|
|
|
|
|
h_many(h_uint8()),
|
|
|
|
|
h_end_p(),
|
|
|
|
|
NULL);
|
2012-05-24 18:44:48 +02:00
|
|
|
|
|
|
|
|
return wks;
|
|
|
|
|
}
|