chiark / gitweb /
site: Support multiple addresses
[secnet.git] / secnet.h
index 1c88e3a0c744ce5251a6085c38fdad56a189ec89..8a60ee30546ed4382c191f872e2f9cc04f32dc90 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -3,6 +3,8 @@
 #ifndef secnet_h
 #define secnet_h
 
+#define ADNS_FEATURE_MANYAF
+
 #include "config.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -33,6 +35,9 @@ typedef _Bool bool_t;
 union iaddr {
     struct sockaddr sa;
     struct sockaddr_in sin;
+#ifdef CONFIG_IPV6
+    struct sockaddr_in6 sin6;
+#endif
 };
 
 #define ASSERT(x) do { if (!(x)) { fatal("assertion failed line %d file " \
@@ -111,7 +116,7 @@ extern cstring_t *dict_keys(dict_t *dict);
 
 /* List-manipulation functions */
 extern list_t *list_new(void);
-extern int32_t list_length(list_t *a);
+extern int32_t list_length(const list_t *a);
 extern list_t *list_append(list_t *a, item_t *i);
 extern list_t *list_append_list(list_t *a, list_t *b);
 /* Returns an item from the list (index starts at 0), or NULL */
@@ -133,6 +138,14 @@ extern uint32_t dict_read_number(dict_t *dict, cstring_t key, bool_t required,
   /* return value can safely be assigned to int32_t */
 extern bool_t dict_read_bool(dict_t *dict, cstring_t key, bool_t required,
                             cstring_t desc, struct cloc loc, bool_t def);
+const char **dict_read_string_array(dict_t *dict, cstring_t key,
+                                   bool_t required, cstring_t desc,
+                                   struct cloc loc, const char *const *def);
+  /* Return value is a NULL-terminated array obtained from malloc;
+   * Individual string values are still owned by config file machinery
+   * and must not be modified or freed.  Returns NULL if key not
+   * found. */
+
 struct flagstr {
     cstring_t name;
     uint32_t value;
@@ -290,7 +303,10 @@ struct buffer_if;
    will be freed once resolve_answer_fn returns. It is in network byte
    order. */
 typedef void resolve_answer_fn(void *st, const struct comm_addr *addrs,
-                              int naddrs);
+                              int naddrs, const char *name,
+                              const char *failwhy);
+  /* name is the same ptr as passed to request, so its lifetime must
+   * be suitable*/
 typedef bool_t resolve_request_fn(void *st, cstring_t name,
                                  int remoteport, struct comm_if *comm,
                                  resolve_answer_fn *cb, void *cst);
@@ -339,6 +355,7 @@ struct comm_addr {
        equivalent. */
     struct comm_if *comm;
     union iaddr ia;
+    int ix;
 };
 
 /* Return True if the packet was processed, and shouldn't be passed to
@@ -566,5 +583,6 @@ extern void log_from_fd(int fd, cstring_t prefix, struct log_if *log);
 #define STRING(x) STRING2(x)
 
 #define FILLZERO(obj) (memset(&(obj),0,sizeof((obj))))
+#define ARRAY_SIZE(ary) (sizeof(ary)/sizeof(ary[0]))
 
 #endif /* secnet_h */