*/
uint32_t ldns_rdf2native_int32(ldns_rdf *rd);
+/**
+ * returns the native time_t representation from the rdf.
+ * \param[in] rd the ldns_rdf to operate on
+ * \return time_t the value extracted (32 bits currently)
+ */
+time_t ldns_rdf2native_time_t(ldns_rdf *rd);
+
/**
* converts a ttl value (like 5d2h) to a long.
* \param[in] nptr the start of the string
}
}
+time_t
+ldns_rdf2native_time_t(ldns_rdf *rd)
+{
+ uint32_t data;
+
+ switch(ldns_rdf_get_type(rd)) {
+ case LDNS_RDF_TYPE_TIME:
+ memcpy(&data, ldns_rdf_data(rd), sizeof(data));
+ return (time_t)ntohl(data);
+ default:
+ return 0;
+ }
+}
+
struct sockaddr_storage *
ldns_rdf2native_sockaddr_storage(ldns_rdf *rd, uint16_t port, size_t *size)
{
HEADER = config.h
TESTS = run-test0 run-test7 run-test18 run-test19 run-test20 \
- dname-label-test notify run-test-read-zone
+ dname-label-test notify run-test-read-zone \
+ rrsig-test
.PHONY: all clean realclean
run-test20: run-test20.o
$(LINK) -lssl -o $@ $+
+
+rrsig-test: rrsig-test.o
+ $(LINK) -lssl -o $@ $+
run-test-read-zone: run-test-read-zone.o
$(LINK) -lssl -o $@ $+
--- /dev/null
+/*
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif /* HAVE_STDINT_H */
+
+#include <ldns/dns.h>
+
+int main(void)
+{
+ ldns_rr *sig;
+ ldns_rdf *incep, *expir;
+
+ time_t t_incep, t_expir, t_now;
+
+ sig = ldns_rr_new_frm_str("jelte.nlnetlabs.nl. 18000 IN RRSIG NSEC RSASHA1 3 18000 20050913235001 20050814235001 43791 nlnetlabs.nl. epWGR0WkhWQ1h0eXvU89W57xwI0xuUlWtvvUnABQVmUfZ2nGllIy2KLR5cfgpB5UH7beASrAo78AlPddPCnH50OYNjllesDy9HLderQtjQoi47SPPluLC6v3Fwqq64Zv0wf2fPzJqDSnOOrQPVzIuB3IDv5XD4M5t8Vze8QZ8lA=", 0, NULL);
+
+ ldns_rr_print(stdout, sig);
+
+ t_now = time(NULL);
+ incep = ldns_rr_rrsig_inception(sig);
+ t_incep = ldns_rdf2native_time_t(incep);
+ expir = ldns_rr_rrsig_expiration(sig);
+ t_expir = ldns_rdf2native_time_t(expir);
+
+ printf("inception: [now %d] %d\n", t_now, t_incep);
+ ldns_rdf_print(stdout, incep);
+ printf("\n");
+ printf("expiration: %d\n", t_expir);
+ ldns_rdf_print(stdout, expir);
+ printf("\n");
+}
ldns_key_print(stdout, privkey);
}
- exit(1);
-
dnskey = ldns_key2rr(privkey);
if (dnskey) {
ldns_rr_print(stdout, dnskey);