chiark / gitweb /
Makefile.in: Move settings of various directories above CFLAGS etc.
[secnet.git] / comm-common.h
index 714a536b91e56c0a260be677ebc77149feaeb685..5ab6e467f4ed2c5ed105404dc6193d0e742119a4 100644 (file)
@@ -53,14 +53,20 @@ void comm_apply(struct commcommon *cc);
 
 #define UDP_MAX_SOCKETS 3 /* 2 ought to do really */
 
+#define MAX_AF (AF_INET6>AF_INET?AF_INET6:AF_INET)
+
 struct udpsock {
     union iaddr addr;
     int fd;
+    bool_t experienced[/*0=recv,1=send*/2][MAX_AF+1][/*success?*/2];
 };
 
 struct udpsocks {
     int n_socks;
     struct udpsock socks[UDP_MAX_SOCKETS];
+    /* private for udp_socks_* */
+    struct udpcommon *uc; /* link to parent, for cfg, notify list, etc. */
+    struct poll_interest *interest;
 };
 
 struct udpcommon {
@@ -71,12 +77,21 @@ struct udpcommon {
     union iaddr proxy;
 };
 
-int udp_socks_beforepoll(struct udpsocks *s,
-                        struct pollfd *fds, int *nfds_io,
-                        int *timeout_io);
+bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us,
+                      int failmsgclass);
+  /* Fills in us->fd.  Logs any errors with lg_[v]perror. */
+
+void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us);
+  /* Idempotent.  No errors are possible. */
+
+const char *af_name(int af);
+void udp_sock_experienced(struct log_if *lg, struct udpcommon *uc,
+                         const char *socksdesc, struct udpsock *us,
+                         bool_t recvsend, int af /* 0 means any */,
+                         int r, int errnoval);
 
-void udp_socks_afterpoll(struct udpcommon *u, struct udpsocks *s,
-                        struct pollfd *fds, int nfds);
+void udp_socks_register(struct udpcommon *uc, struct udpsocks *socks);
+void udp_socks_deregister(struct udpcommon *uc, struct udpsocks *socks);
 
 #define UDP_APPLY_STANDARD(st,uc,desc)                                 \
     (uc)->use_proxy=False;                                             \