]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Class specifier in --dnskey, instead of hardwiring C_IN.
authorSimon Kelley <simon@thekelleys.org.uk>
Sat, 25 Jan 2014 17:59:14 +0000 (17:59 +0000)
committerSimon Kelley <simon@thekelleys.org.uk>
Sat, 25 Jan 2014 17:59:14 +0000 (17:59 +0000)
src/cache.c
src/dns-protocol.h
src/dnsmasq.h
src/option.c

index d5e91b0f18b43e11200451777dd6fb35be532d66..01fee3f299bb6b00122522b1f26134df17e4caad 100644 (file)
@@ -1003,7 +1003,7 @@ void cache_reload(void)
        cache->addr.key.algo = key->algo;
        cache->addr.key.flags = key->flags;
        cache->addr.key.keytag = dnskey_keytag(key->algo, key->flags, (unsigned char *)key->key, key->keylen);
-       cache->uid = C_IN; /* TODO - in option? */
+       cache->uid = key->class;
        cache_hash(cache);
       }
 #endif
index 6507642e43e8d6f479622d76d00b8342e2809c43..a3ad14b8bd98176888f37a463962b67cbdceb431 100644 (file)
@@ -36,6 +36,7 @@
 
 #define C_IN            1               /* the arpa internet */
 #define C_CHAOS         3               /* for chaos net (MIT) */
+#define C_HESIOD        4               /* hesiod */
 #define C_ANY           255             /* wildcard match */
 
 #define T_A            1
index f919222585ffbea90a02c0fecfb6e3043a9fe500..c5436f5509949c6b8adecd1537e6ec5bd81655ed 100644 (file)
@@ -297,7 +297,7 @@ struct cname {
 
 struct dnskey {
   char *name, *key;
-  int keylen, algo, flags;
+  int keylen, class, algo, flags;
   struct dnskey *next;
 };
 
index 88a569d3a0ccadf9b5c5daacdabf4e54b124d7c5..22edeca8d7d6fd42e068ab162867e272607f4788 100644 (file)
@@ -3682,13 +3682,32 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
       {
        struct dnskey *new = opt_malloc(sizeof(struct dnskey));
        char *key64, *algo;
-               if (!(comma = split(arg)) || !(algo = split(comma)) || !(key64 = split(algo)) ||
-             !atoi_check16(comma, &new->flags) || !atoi_check16(algo, &new->algo) ||
-             !(new->name = canonicalise_opt(arg)))
-         ret_err(_("bad DNSKEY"));
-       
+       
+       new->class = C_IN;
 
+       if ((comma = split(arg)) && (algo = split(comma)))
+         {
+           int class = 0;
+           if (strcmp(comma, "IN") == 0)
+             class = C_IN;
+           else if (strcmp(comma, "CH") == 0)
+             class = C_CHAOS;
+           else if (strcmp(comma, "HS") == 0)
+             class = C_HESIOD;
+           
+           if (class != 0)
+             {
+               new->class = class;
+               comma = algo;
+               algo = split(comma);
+             }
+         }
+                 
+               if (!comma || !algo || !(key64 = split(algo)) ||
+           !atoi_check16(comma, &new->flags) || !atoi_check16(algo, &new->algo) ||
+           !(new->name = canonicalise_opt(arg)))
+         ret_err(_("bad DNSKEY"));
+           
        /* Upper bound on length */
        new->key = opt_malloc((3*strlen(key64)/4)+1);
        unhide_metas(key64);