summaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/gnsrecord.c21
-rw-r--r--src/gnsrecord/plugin_gnsrecord_dns.c7
-rw-r--r--src/gnsrecord/test_gnsrecord_testvectors.c30
3 files changed, 45 insertions, 13 deletions
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c
index e9994a868..52c480ef6 100644
--- a/src/gnsrecord/gnsrecord.c
+++ b/src/gnsrecord/gnsrecord.c
@@ -260,4 +260,25 @@ GNUNET_GNSRECORD_number_to_typename (uint32_t type)
}
+enum GNUNET_GenericReturnValue
+GNUNET_GNSRECORD_is_critical (uint32_t type)
+{
+ struct Plugin *plugin;
+
+ if (GNUNET_GNSRECORD_TYPE_ANY == type)
+ return GNUNET_NO;
+ init ();
+ for (unsigned int i = 0; i < num_plugins; i++)
+ {
+ plugin = gns_plugins[i];
+ if (NULL == plugin->api->is_critical)
+ continue;
+ if (GNUNET_NO == plugin->api->is_critical (plugin->api->cls, type))
+ continue;
+ return GNUNET_YES;
+ }
+ return GNUNET_NO;
+}
+
+
/* end of gnsrecord.c */
diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c
index 123c59905..649133cd1 100644
--- a/src/gnsrecord/plugin_gnsrecord_dns.c
+++ b/src/gnsrecord/plugin_gnsrecord_dns.c
@@ -773,6 +773,12 @@ dns_number_to_typename (void *cls, uint32_t type)
}
+static enum GNUNET_GenericReturnValue
+dns_is_critical (void *cls, uint32_t type)
+{
+ return GNUNET_NO;
+}
+
/**
* Entry point for the plugin.
*
@@ -789,6 +795,7 @@ libgnunet_plugin_gnsrecord_dns_init (void *cls)
api->string_to_value = &dns_string_to_value;
api->typename_to_number = &dns_typename_to_number;
api->number_to_typename = &dns_number_to_typename;
+ api->is_critical = &dns_is_critical;
return api;
}
diff --git a/src/gnsrecord/test_gnsrecord_testvectors.c b/src/gnsrecord/test_gnsrecord_testvectors.c
index 153c56261..6419f9c94 100644
--- a/src/gnsrecord/test_gnsrecord_testvectors.c
+++ b/src/gnsrecord/test_gnsrecord_testvectors.c
@@ -10,11 +10,11 @@
static char *d =
-"50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98";
+ "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98";
static char *zid =
-"00010000677c477d2d93097c85b195c6f96d84ff61f5982c2c4fe02d5a11fedfb0c2901f";
+ "00010000677c477d2d93097c85b195c6f96d84ff61f5982c2c4fe02d5a11fedfb0c2901f";
#define RRCOUNT 2
#define LABEL "test"
@@ -31,12 +31,12 @@ static char *zid =
#define R1_TYPE 65536
#define R1_FLAGS 2
#define R1_DATA \
-"000100000e601be42eb57fb4697610cf3a3b18347b65a33f025b5b174abefb30807bfecf"
+ "000100000e601be42eb57fb4697610cf3a3b18347b65a33f025b5b174abefb30807bfecf"
#define R1_RRBLOCK \
-"000100008e16da87203b5159c5538e9b765742e968c54af9afbc0890dc80205ad14c84e107b0c115fc0089aa38b9c7ab9cbe1d77040d282a51a2ad493f61f3495f02d8170fe473a55ec6bdf9a509ab1701ffc37ea3bb4cac4a672520986df96e67cc1a73000000940000000f0034e53be193799100e4837eb5d04f92903de4b5234e8ccac5736c9793379a59c33375fc8951aca2eb7aad067bf9af60bf26758646a17f5e5c3b6215f94079545b1c4d4f1b2ebb22c2b4dad44126817b6f001530d476401dd67ac0148554e806353da9e4298079f3e1b16942c48d90c4360c61238c40d9d52911aea52cc0037ac7160bb3cf5b2f4a722fd96b"
+ "000100008e16da87203b5159c5538e9b765742e968c54af9afbc0890dc80205ad14c84e107b0c115fc0089aa38b9c7ab9cbe1d77040d282a51a2ad493f61f3495f02d8170fe473a55ec6bdf9a509ab1701ffc37ea3bb4cac4a672520986df96e67cc1a73000000940000000f0034e53be193799100e4837eb5d04f92903de4b5234e8ccac5736c9793379a59c33375fc8951aca2eb7aad067bf9af60bf26758646a17f5e5c3b6215f94079545b1c4d4f1b2ebb22c2b4dad44126817b6f001530d476401dd67ac0148554e806353da9e4298079f3e1b16942c48d90c4360c61238c40d9d52911aea52cc0037ac7160bb3cf5b2f4a722fd96b"
-int parsehex(char *src, char *dst, size_t dstlen, int invert)
+int parsehex (char *src, char *dst, size_t dstlen, int invert)
{
char *line = src;
char *data = line;
@@ -44,7 +44,8 @@ int parsehex(char *src, char *dst, size_t dstlen, int invert)
int read_byte;
int data_len = 0;
- while (sscanf(data, " %02x%n", &read_byte, &off) == 1) {
+ while (sscanf (data, " %02x%n", &read_byte, &off) == 1)
+ {
if (invert)
dst[dstlen - 1 - data_len++] = read_byte;
else
@@ -62,8 +63,8 @@ res_checker (void *cls,
int r1_found = 0;
char r0_data[R0_DATA_SIZE];
char r1_data[R1_DATA_SIZE];
- parsehex(R0_DATA, (char*)r0_data, 0, 0);
- parsehex(R1_DATA, (char*)r1_data, 0, 0);
+ parsehex (R0_DATA, (char*) r0_data, 0, 0);
+ parsehex (R1_DATA, (char*) r1_data, 0, 0);
GNUNET_assert (rd_count == RRCOUNT);
for (int i = 0; i < RRCOUNT; i++)
{
@@ -104,7 +105,7 @@ res_checker (void *cls,
int
-main()
+main ()
{
struct GNUNET_IDENTITY_PrivateKey priv;
struct GNUNET_IDENTITY_PublicKey pub;
@@ -112,13 +113,16 @@ main()
struct GNUNET_GNSRECORD_Block *rrblock;
char *bdata;
- parsehex(d,(char*)&priv.ecdsa_key, sizeof (priv.ecdsa_key), 1);
+ parsehex (d,(char*) &priv.ecdsa_key, sizeof (priv.ecdsa_key), 1);
priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
- parsehex(zid,(char*)&pub_parsed, 0, 0);
- GNUNET_IDENTITY_key_get_public(&priv, &pub);
+ parsehex (zid,(char*) &pub_parsed, 0, 0);
+ GNUNET_IDENTITY_key_get_public (&priv, &pub);
GNUNET_assert (0 == memcmp (&pub, &pub_parsed, sizeof (pub)));
rrblock = GNUNET_malloc (strlen (R1_RRBLOCK) / 2);
- parsehex(R1_RRBLOCK, (char*)rrblock, 0, 0);
+ parsehex (R1_RRBLOCK, (char*) rrblock, 0, 0);
+ GNUNET_assert (GNUNET_YES
+ == GNUNET_GNSRECORD_is_critical_record_type (
+ GNUNET_GNSRECORD_TYPE_PKEY));
GNUNET_GNSRECORD_block_decrypt (rrblock,
&pub_parsed,
LABEL,