Commit 458824dc authored by Giovanni Bajo's avatar Giovanni Bajo Committed by Simon Kelley

Helper function to walk through keydata chained blocks.

parent a7338645
...@@ -1364,6 +1364,23 @@ struct keydata *keydata_alloc(char *data, size_t len) ...@@ -1364,6 +1364,23 @@ struct keydata *keydata_alloc(char *data, size_t len)
return ret; return ret;
} }
size_t keydata_walk(struct keydata **key, unsigned char **p, size_t cnt)
{
size_t ret;
if (*p == NULL)
*p = (*key)->key;
else if (*p == (*key)->key + KEYBLOCK_LEN)
{
*key = (*key)->next;
if (*key == NULL)
return 0;
*p = (*key)->key;
}
return MIN(cnt, (*key)->key + KEYBLOCK_LEN - (*p));
}
void keydata_free(struct keydata *blocks) void keydata_free(struct keydata *blocks)
{ {
struct keydata *tmp; struct keydata *tmp;
......
...@@ -925,6 +925,7 @@ char *cache_get_name(struct crec *crecp); ...@@ -925,6 +925,7 @@ char *cache_get_name(struct crec *crecp);
struct crec *cache_enumerate(int init); struct crec *cache_enumerate(int init);
#ifdef HAVE_DNSSEC #ifdef HAVE_DNSSEC
struct keydata *keydata_alloc(char *data, size_t len); struct keydata *keydata_alloc(char *data, size_t len);
size_t keydata_walk(struct keydata **key, unsigned char **p, size_t cnt);
void keydata_free(struct keydata *blocks); void keydata_free(struct keydata *blocks);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment