chiark / gitweb /
changelog: start 0.6.8
[secnet.git] / comm-common.h
index 6dad9ef6c52e7010e9cf669959ad538d300cfd8e..7027ee5f5aadafc9a93c01aae45b89e7d2743264 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ * This file is part of secnet.
+ * See README for full list of copyright holders.
+ *
+ * secnet is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * secnet is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * version 3 along with secnet; if not, see
+ * https://www.gnu.org/licenses/gpl.html.
+ */
 
 #ifndef COMM_COMMON_H
 #define COMM_COMMON_H
@@ -12,7 +30,7 @@ struct comm_notify_entry {
     void *state;
     LIST_ENTRY(comm_notify_entry) entry;
 };
-LIST_HEAD(comm_notify_list, comm_notify_entry) notify;
+LIST_HEAD(comm_notify_list, comm_notify_entry);
 
 struct commcommon { /* must be first so that void* is comm_common* */
     closure_t cl;
@@ -20,23 +38,28 @@ struct commcommon { /* must be first so that void* is comm_common* */
     struct cloc loc;
     struct comm_notify_list notify;
     struct buffer_if *rbuf;
+    struct priomsg why_unwanted;
 };
 
+struct comm_clientinfo *comm_clientinfo_ignore(void *state, dict_t*,
+                                              struct cloc cloc);
 void comm_request_notify(void *commst, void *nst, comm_notify_fn *fn);
 void comm_release_notify(void *commst, void *nst, comm_notify_fn *fn);
 
-bool_t comm_notify(struct comm_notify_list *notify, struct buffer_if *buf,
+bool_t comm_notify(struct commcommon*, struct buffer_if *buf,
                   const struct comm_addr *ca);
   /* Either: returns True, with message delivered and buffer freed.
-   * Or: False, if no-one wanted it - buffer still allocd'd.
-   * Ie, like comm_notify_fn. */
+   * Or: False, if no-one wanted it - buffer still allocd'd;
+   *     in that case, cc->why_unwanted has info
+   * Ie, roughly like comm_notify_fn. */
 
 void comm_apply(struct commcommon *cc, void *st);
 
 #define COMM_APPLY(st,cc,prefix,desc,loc)              \
-    (st)=safe_malloc(sizeof(*(st)), desc "_apply");    \
+    NEW(st);                                           \
     (cc)->loc=loc;                                     \
     (cc)->cl.description=desc;                         \
+    (cc)->ops.clientinfo=comm_clientinfo_ignore;       \
     (cc)->ops.sendmsg=prefix##sendmsg;                 \
     (cc)->ops.addr_to_string=prefix##addr_to_string;   \
     comm_apply((cc),(st))
@@ -103,7 +126,7 @@ void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us);
 const char *af_name(int af);
 void udp_sock_experienced(struct log_if *lg, struct udpcommon *uc,
                          struct udpsocks *socks, struct udpsock *us,
-                         bool_t recvsend, int af /* 0 means any */,
+                         const union iaddr *dest, int af /* 0 means any */,
                          int r, int errnoval);
 
 void udp_socks_register(struct udpcommon *uc, struct udpsocks *socks,