chiark / gitweb /
WIP DNS bugfixes
[secnet.git] / secnet.h
index 49afd322e83130506da37f96e3036e7ea57efed0..a206d057684ba38be10e2f2edf078b6839926bcf 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -303,16 +303,44 @@ struct rsaprivkey_if {
 
 /* COMM interface */
 
+struct comm_addr {
+    /* This struct is pure data; in particular comm's clients may
+       freely copy it. */
+    /* Everyone is also guaranteed that all padding is set to zero, ie
+       that comm_addrs referring to semantically identical peers will
+       compare equal with memcmp. */
+    struct comm_if *comm;
+    union {
+       struct sockaddr_in sin;
+       uint32_t associd;
+    } priv;
+};
+
 /* Return True if the packet was processed, and shouldn't be passed to
    any other potential receivers. */
 typedef bool_t comm_notify_fn(void *state, struct buffer_if *buf,
-                           struct sockaddr_in *source);
+                             const struct comm_addr *source);
 typedef void comm_request_notify_fn(void *commst, void *nst,
                                    comm_notify_fn *fn);
 typedef void comm_release_notify_fn(void *commst, void *nst,
                                    comm_notify_fn *fn);
 typedef bool_t comm_sendmsg_fn(void *commst, struct buffer_if *buf,
-                              struct sockaddr_in *dest);
+                              const struct comm_addr *dest);
+typedef void *comm_peer_addr_config_fn(void *commst, dict_t*, struct cloc,
+                                      cstring_t desc);
+       /* Checks the config for the peer as specified in dict,
+        * and either returns NULL to mean the relevant parameters
+        * weren't specified, or a non-NULL void* which can be
+        * passed to comm_peer_addr_fn */
+typedef void comm_peer_addr_answer_fn(void *st, const struct comm_addr *ca);
+typedef bool_t comm_peer_addr_request_fn(void *commst, void *from_peer_config,
+                                comm_peer_addr_answer_fn *cb, void *cst);
+       /* Calls comm_peer_addr_answer_fn, either immediately or later,
+        * with a suitable comm_addr.  The caller's cb should
+        * memcpy ca.  On failure, logs error and calls cb with ca=NULL */
+typedef const char *comm_addr_to_string_fn(void *commst,
+                                          const struct comm_addr *ca);
+        /* Returned string is in a static buffer. */
 struct comm_if {
     void *st;
     int32_t min_start_pad;
@@ -320,6 +348,9 @@ struct comm_if {
     comm_request_notify_fn *request_notify;
     comm_release_notify_fn *release_notify;
     comm_sendmsg_fn *sendmsg;
+    comm_peer_addr_config_fn *peer_addr_config;
+    comm_peer_addr_request_fn *peer_addr_request;
+    comm_addr_to_string_fn *addr_to_string;
 };
 
 /* LOG interface */