mirror of https://github.com/getdnsapi/getdns.git
Make special handlers for rdf work
+ bugfix in repetition of rdf blocks
This commit is contained in:
parent
bea4b50422
commit
9b90ced595
|
@ -55,12 +55,12 @@ template_dict_set_value(getdns_dict *dict, uint8_t *rdf)
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
static getdns_return_t
|
static getdns_return_t
|
||||||
template_list_set_value(getdns_list *list, uint8_t *rdf)
|
template_list_append_value(getdns_list *list, uint8_t *rdf)
|
||||||
{
|
{
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
static priv_getdns_rdf_special template = {
|
static priv_getdns_rdf_special template = {
|
||||||
template_rdf_end, template_dict_set_value, template_list_set_value
|
template_rdf_end, template_dict_set_value, template_list_append_value
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -75,12 +75,12 @@ apl_n_dict_set_value(getdns_dict *dict, uint8_t *rdf)
|
||||||
return getdns_dict_set_int(dict, "n", (*rdf >> 7));
|
return getdns_dict_set_int(dict, "n", (*rdf >> 7));
|
||||||
}
|
}
|
||||||
static getdns_return_t
|
static getdns_return_t
|
||||||
apl_n_list_set_value(getdns_list *list, uint8_t *rdf)
|
apl_n_list_append_value(getdns_list *list, uint8_t *rdf)
|
||||||
{
|
{
|
||||||
return getdns_list_append_int(list, (*rdf >> 7));
|
return getdns_list_append_int(list, (*rdf >> 7));
|
||||||
}
|
}
|
||||||
static priv_getdns_rdf_special apl_n = {
|
static priv_getdns_rdf_special apl_n = {
|
||||||
apl_n_rdf_end, apl_n_dict_set_value, apl_n_list_set_value
|
apl_n_rdf_end, apl_n_dict_set_value, apl_n_list_append_value
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t *
|
static uint8_t *
|
||||||
|
@ -96,13 +96,14 @@ apl_afdpart_dict_set_value(getdns_dict *dict, uint8_t *rdf)
|
||||||
return getdns_dict_set_bindata(dict, "afdpart", &bindata);
|
return getdns_dict_set_bindata(dict, "afdpart", &bindata);
|
||||||
}
|
}
|
||||||
static getdns_return_t
|
static getdns_return_t
|
||||||
apl_afdpart_list_set_value(getdns_list *list, uint8_t *rdf)
|
apl_afdpart_list_append_value(getdns_list *list, uint8_t *rdf)
|
||||||
{
|
{
|
||||||
getdns_bindata bindata = { (rdf[-1] & 0x7F), rdf };
|
getdns_bindata bindata = { (rdf[-1] & 0x7F), rdf };
|
||||||
return getdns_list_append_bindata(list, &bindata);
|
return getdns_list_append_bindata(list, &bindata);
|
||||||
}
|
}
|
||||||
static priv_getdns_rdf_special apl_afdpart = {
|
static priv_getdns_rdf_special apl_afdpart = {
|
||||||
apl_afdpart_rdf_end, apl_afdpart_dict_set_value, apl_afdpart_list_set_value
|
apl_afdpart_rdf_end,
|
||||||
|
apl_afdpart_dict_set_value, apl_afdpart_list_append_value
|
||||||
};
|
};
|
||||||
|
|
||||||
static priv_getdns_rdata_def a_rdata[] = {
|
static priv_getdns_rdata_def a_rdata[] = {
|
||||||
|
|
|
@ -40,13 +40,13 @@ typedef uint8_t *(*priv_getdns_rdf_end_t)(
|
||||||
/* Limit checks are already done with priv_getdns_rdf_end_t */
|
/* Limit checks are already done with priv_getdns_rdf_end_t */
|
||||||
typedef getdns_return_t (*priv_getdns_rdf_dict_set_value_t)(
|
typedef getdns_return_t (*priv_getdns_rdf_dict_set_value_t)(
|
||||||
getdns_dict *dict, uint8_t *rdf);
|
getdns_dict *dict, uint8_t *rdf);
|
||||||
typedef getdns_return_t (*priv_getdns_rdf_list_set_value_t)(
|
typedef getdns_return_t (*priv_getdns_rdf_list_append_value_t)(
|
||||||
getdns_list *list, uint8_t *rdf);
|
getdns_list *list, uint8_t *rdf);
|
||||||
|
|
||||||
typedef struct priv_getdns_rdf_special {
|
typedef struct priv_getdns_rdf_special {
|
||||||
priv_getdns_rdf_end_t rdf_end;
|
priv_getdns_rdf_end_t rdf_end;
|
||||||
priv_getdns_rdf_dict_set_value_t dict_set_value;
|
priv_getdns_rdf_dict_set_value_t dict_set_value;
|
||||||
priv_getdns_rdf_list_set_value_t list_set_value;
|
priv_getdns_rdf_list_append_value_t list_append_value;
|
||||||
} priv_getdns_rdf_special;
|
} priv_getdns_rdf_special;
|
||||||
|
|
||||||
/* draft-levine-dnsextlang'ish type rr and rdata definitions */
|
/* draft-levine-dnsextlang'ish type rr and rdata definitions */
|
||||||
|
|
|
@ -214,10 +214,10 @@ rdf_iter_find_nxt(priv_getdns_rdf_iter *i)
|
||||||
assert(i->rdd_pos);
|
assert(i->rdd_pos);
|
||||||
|
|
||||||
if (!i->rdd_repeat && (i->rdd_pos->type & GETDNS_RDF_REPEAT)) {
|
if (!i->rdd_repeat && (i->rdd_pos->type & GETDNS_RDF_REPEAT)) {
|
||||||
|
i->rdd_repeat = i->rdd_pos;
|
||||||
if (i->rdd_pos->type == GETDNS_RDF_REPEAT &&
|
if (i->rdd_pos->type == GETDNS_RDF_REPEAT &&
|
||||||
++i->rdd_pos == i->rdd_end)
|
++i->rdd_pos == i->rdd_end)
|
||||||
goto done;
|
goto done;
|
||||||
i->rdd_repeat = i->rdd_pos;
|
|
||||||
}
|
}
|
||||||
if (i->rdd_pos->type & GETDNS_RDF_FIXEDSZ)
|
if (i->rdd_pos->type & GETDNS_RDF_FIXEDSZ)
|
||||||
i->nxt = i->pos + (i->rdd_pos->type & GETDNS_RDF_FIXEDSZ);
|
i->nxt = i->pos + (i->rdd_pos->type & GETDNS_RDF_FIXEDSZ);
|
||||||
|
@ -241,7 +241,11 @@ rdf_iter_find_nxt(priv_getdns_rdf_iter *i)
|
||||||
} else if (*pos & 0xC0) /* Uknown label type */
|
} else if (*pos & 0xC0) /* Uknown label type */
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else
|
else if ((i->rdd_pos->type & GETDNS_RDF_SPECIAL) && i->rdd_pos->special) {
|
||||||
|
if (!(i->nxt = i->rdd_pos->special->rdf_end(
|
||||||
|
i->pkt, i->pkt_end, i->pos)))
|
||||||
|
i->nxt = i->end;
|
||||||
|
} else
|
||||||
i->nxt = i->end;
|
i->nxt = i->end;
|
||||||
|
|
||||||
if (i->nxt <= i->end)
|
if (i->nxt <= i->end)
|
||||||
|
@ -298,6 +302,8 @@ priv_getdns_rdf_iter_next(priv_getdns_rdf_iter *i)
|
||||||
goto done; /* Out of rdata */
|
goto done; /* Out of rdata */
|
||||||
if (i->rdd_pos >= i->rdd_end && !(i->rdd_pos = i->rdd_repeat))
|
if (i->rdd_pos >= i->rdd_end && !(i->rdd_pos = i->rdd_repeat))
|
||||||
goto done; /* Remaining rdata, but out of definitions! */
|
goto done; /* Remaining rdata, but out of definitions! */
|
||||||
|
if (i->rdd_pos->type == GETDNS_RDF_REPEAT)
|
||||||
|
i->rdd_pos += 1;
|
||||||
|
|
||||||
return rdf_iter_find_nxt(i);
|
return rdf_iter_find_nxt(i);
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -422,7 +422,10 @@ priv_getdns_rr_iter2rr_dict(getdns_context *context, priv_getdns_rr_iter *i)
|
||||||
bindata.data = rdf->pos;
|
bindata.data = rdf->pos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else if (rdf->rdd_pos->type == GETDNS_RDF_SPECIAL)
|
||||||
|
/* Abuse t_dict for special values */
|
||||||
|
val_type = t_dict;
|
||||||
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
||||||
if (! rdf->rdd_repeat) {
|
if (! rdf->rdd_repeat) {
|
||||||
|
@ -437,12 +440,16 @@ priv_getdns_rr_iter2rr_dict(getdns_context *context, priv_getdns_rr_iter *i)
|
||||||
rdf->rdd_pos->name, &bindata))
|
rdf->rdd_pos->name, &bindata))
|
||||||
goto rdata_error;
|
goto rdata_error;
|
||||||
break;
|
break;
|
||||||
|
case t_dict:
|
||||||
|
if (rdf->rdd_pos->special->dict_set_value(
|
||||||
|
rdata_dict, rdf->pos))
|
||||||
|
goto rdata_error;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
} else if (rdf->rdd_pos == rdf->rdd_repeat) {
|
if (rdf->rdd_pos == rdf->rdd_repeat) {
|
||||||
/* list with rdf values */
|
/* list with rdf values */
|
||||||
|
|
||||||
if (! repeat_list && !(repeat_list =
|
if (! repeat_list && !(repeat_list =
|
||||||
|
@ -460,16 +467,22 @@ priv_getdns_rr_iter2rr_dict(getdns_context *context, priv_getdns_rr_iter *i)
|
||||||
&bindata))
|
&bindata))
|
||||||
goto rdata_error;
|
goto rdata_error;
|
||||||
break;
|
break;
|
||||||
|
case t_dict:
|
||||||
|
if (rdf->rdd_pos->special->list_append_value(
|
||||||
|
repeat_list, rdf->pos))
|
||||||
|
goto rdata_error;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* list with dicts with rdf values */
|
|
||||||
if (rdf->rdd_pos == rdf->rdd_repeat + 1) {
|
if (rdf->rdd_pos == rdf->rdd_repeat + 1) {
|
||||||
|
|
||||||
if (repeat_dict) {
|
if (repeat_dict) {
|
||||||
|
if (! repeat_list && !(repeat_list =
|
||||||
|
getdns_list_create_with_context(context)))
|
||||||
|
goto rdata_error;
|
||||||
|
|
||||||
if (getdns_list_append_dict(
|
if (getdns_list_append_dict(
|
||||||
repeat_list, repeat_dict))
|
repeat_list, repeat_dict))
|
||||||
goto rdata_error;
|
goto rdata_error;
|
||||||
|
@ -493,6 +506,10 @@ priv_getdns_rr_iter2rr_dict(getdns_context *context, priv_getdns_rr_iter *i)
|
||||||
rdf->rdd_pos->name, &bindata))
|
rdf->rdd_pos->name, &bindata))
|
||||||
goto rdata_error;
|
goto rdata_error;
|
||||||
break;
|
break;
|
||||||
|
case t_dict:
|
||||||
|
if (rdf->rdd_pos->special->dict_set_value(
|
||||||
|
repeat_dict, rdf->pos))
|
||||||
|
goto rdata_error;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue